Skip to content
Snippets Groups Projects
Commit a2ee088b authored by Diego Pasqualin's avatar Diego Pasqualin
Browse files

Initial Commit

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 523 additions and 0 deletions
common.sh 0 → 100644
#!/bin/bash
# Copyright (C) 2004-2010 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-base
#
# le-base is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# This script is included in others scripts to use common functions
DIR=$(readlink -f "$0")
PREFIX=`dirname "$(echo "$DIR")"`
checkStatus()
{
if [ -n "$(grep "$DEVICE" /etc/mtab)" ]; then
echo "Error: /dev/$DEVICE is mounted according with mtab"
return 1
fi
return 0
}
checkUser()
{
if ! [ -w /dev/$DEVICE ]; then
echo "Error: Please, execute this script as root!"
return 1
fi
return 0
}
loadConf()
{
if [ $# -gt 1 -a -f "$1" ]; then
conf=$(readlink -f "$1")
elif [ -f "$PREFIX/"*.conf ]; then
conf="$PREFIX/"*.conf
else
echo "Error: Config file for $2 not found."
exit 1
fi
host=true
mirror=true
if [ ! -z "$LEHOST" ];
then
host="false"
fi
if [ ! -z "$LEMIRROR" ];
then
mirror="false"
fi
#read config file and declares only valid vars.
BASENAME=`basename $(echo "$2")`
while read var; do
if egrep -qi "^[a-z_]+=" <<< "$var";
then
varname="$(echo $var | cut -d"=" -f 1)"
if [ "$varname" != "LEHOST" ] && [ "$varname" != "LEMIRROR" ];
then
eval "export $(echo $var | sed -e "s@DISTNAME@$2@g" -e "s/BASENAME/$BASENAME/g")"
elif [ "$varname" == "LEHOST" ];
then
$host && eval "export $(echo $var)"
elif [ "$varname" == "LEMIRROR" ];
then
$mirror && eval "export $(echo $var)"
fi
fi
done < "$conf"
return 0
}
removeMountList()
{
grep -v "$1" "$MOUNTLIST" > "$MOUNTLIST".tmp
mv -f "$MOUNTLIST".tmp "$MOUNTLIST"
}
checkMountedFS()
{
touch "$MOUNTLIST"
for file in $(sort -r "$MOUNTLIST"); do
if ! ( umount -l $file && removeMountList $file ); then
echo "Error: While umounting $file"
return 1
fi
done
return 0
}
TMP="/dev/shm/tmp/DISTNAME"
LOGDIR="$PREFIX/log/DISTNAME"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/enabled-scripts/DISTNAME"
INSTLIST="$PREFIX/pckg-list/DISTNAME/install.list"
RMLIST="$PREFIX/pckg-list/DISTNAME/remove.list"
CDDIR="$TMP/extract-cd"
CHROOTDIR="$TMP/live-image"
MOUNTLIST="$TMP/mountlist"
SQUASHIMAGE="$PREFIX/squashfs-root"
DISTROISO="$PREFIX/iso/DISTNAME/$DISTRO-BASENAME-i386"
TEMPLATES="$PREFIX/templates/DISTNAME"
LEHOST="windu.c3sl.ufpr.br/le5"
LEMIRROR="le5-testing"
TMP="/dev/shm/tmp/DISTNAME"
LOGDIR="$PREFIX/log/DISTNAME"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/enabled-scripts/DISTNAME"
INSTLIST="$PREFIX/pckg-list/DISTNAME/install.list"
RMLIST="$PREFIX/pckg-list/DISTNAME/remove.list"
CDDIR="$TMP/extract-cd"
CHROOTDIR="$TMP/live-image"
MOUNTLIST="$TMP/mountlist"
SQUASHIMAGE="$PREFIX/squashfs-root"
DISTROISO="$PREFIX/iso/DISTNAME/$DISTRO-BASENAME-i386"
TEMPLATES="$PREFIX/templates/DISTNAME"
LEHOST="windu.c3sl.ufpr.br/le5"
LEMIRROR="le5-testing"
TMP="/dev/shm/tmp/tmp-DISTNAME"
LOGDIR="$PREFIX/log/DISTNAME"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/enabled-scripts/DISTNAME"
INSTLIST="$PREFIX/pckg-list/DISTNAME/install.list"
RMLIST="$PREFIX/pckg-list/DISTNAME/remove.list"
CDDIR="$TMP/extract-cd"
CHROOTDIR="$TMP/live-image"
MOUNTLIST="$TMP/mountlist"
SQUASHIMAGE="$PREFIX/squashfs-root"
DISTROISO="$PREFIX/iso/DISTNAME/$DISTRO-BASENAME-i386"
TEMPLATES="$PREFIX/templates/DISTNAME"
LEHOST="windu.c3sl.ufpr.br/mc"
LEMIRROR="mc-testing"
DEBIAN_FRONTEND="noninteractive"
\ No newline at end of file
TMP="/dev/shm/tmp/tmp-DISTNAME"
LOGDIR="$PREFIX/log/DISTNAME"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/enabled-scripts/DISTNAME"
INSTLIST="$PREFIX/pckg-list/DISTNAME/install.list"
RMLIST="$PREFIX/pckg-list/DISTNAME/remove.list"
CDDIR="$TMP/extract-cd"
CHROOTDIR="$TMP/live-image"
MOUNTLIST="$TMP/mountlist"
SQUASHIMAGE="$PREFIX/squashfs-root"
DISTROISO="$PREFIX/iso/DISTNAME/$DISTRO-BASENAME-i386"
TEMPLATES="$PREFIX/templates/DISTNAME"
LEHOST="windu.c3sl.ufpr.br/mc"
LEMIRROR="mc-testing"
DEBIAN_FRONTEND="noninteractive"
\ No newline at end of file
#!/bin/bash
sudo ./create-iso.sh --$FAZER iso/$ISO --dist $DISTRO <<< y
DFOLDER=(`echo $DISTRO | awk -F'/' '{ print $1 }'`)
DNAME=(`echo $DISTRO | awk -F'/' '{ print $2 }'`)
DATE=(`date +"%d-%m"`)
scp iso/$DFOLDER/$DNAME/Linux_Educacional_5-${DNAME}-i386.iso seed2@colombard.c3sl.ufpr.br:/var/www/isos/${DFOLDER}/Linux_Educacional_5-${DNAME}-i386-${DATE}.iso
scp iso/$DFOLDER/$DNAME/Linux_Educacional_5-${DNAME}-i386.md5 seed2@colombard.c3sl.ufpr.br:/var/www/isos/${DFOLDER}/Linux_Educacional_5-${DNAME}-i386-${DATE}.md5
TMP="/dev/shm/tmp/tmp-DISTNAME"
LOGDIR="$PREFIX/log"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/enabled-scripts"
INSTLIST="$PREFIX/pckg-list/install.list-DISTNAME"
RMLIST="$PREFIX/pckg-list/remove.list"
CDDIR="$TMP/extract-cd"
CHROOTDIR="$TMP/live-image"
MOUNTLIST="$TMP/mountlist"
SQUASHIMAGE="$PREFIX/squashfs-root"
DISTROISO="$PREFIX/iso/$DISTRO-DISTNAME-i386"
TEMPLATES="$PREFIX/templates"
LEHOST="windu.c3sl.ufpr.br/le5"
LEMIRROR="le5-testing"
#!/bin/bash
# Copyright (C) 2004-2010 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-base
#
# le-base is free software; you can redistNameribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distNameributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#------------------------------------------------------------------------------
export DEBIAN_FRONTEND=noninteractive
editDistro()
{
log "Editing $DISTROBASE ..."
initFiles
# Edits live image
for file in $(ls "$SCRIPTSDIR"); do
if [ -x "$SCRIPTSDIR/$file" ] && egrep -q '^[0-9]{2}-[a-z-]+' <<< "$file"; then
echo "$file"
#read -p "PAUSADO ..."
if ! "$SCRIPTSDIR/$file" $1; then
log "Error: While running the "$SCRIPTSDIR/$file""
return 1
fi
fi
done
return 0
}
regenerateManifest()
{
log "Regenerating manifest list ..."
chmod +w "$CDDIR"/casper/filesystem.manifest
chroot "$CHROOTDIR" dpkg-query -W --showformat='${Package} ${Version}\n' > \
"$CDDIR"/casper/filesystem.manifest
#cp $CDDIR/casper/filesystem.manifest \
# $CDDIR/casper/filesystem.manifest-desktop
cat "$INSTLIST"-remove >> "$CDDIR"/casper/filesystem.manifest-remove
#for package in $(cat "$CDDIR"/casper/filesystem.manifest-remove | cut -d '=' -f1 | grep -v "^#"); do
# if ! grep -q "^$package " "$CDDIR"/casper/filesystem.manifest; then
# sed -i "/$package/d" "$CDDIR"/casper/filesystem.manifest-remove
# fi
#done
#for package in $(cat $INSTLIST-desktop | cut -d '=' -f1 | grep -v "^#"); do
# ( printf "$package "; chroot $CHROOTDIR apt-cache showpkg $package |
# grep "^[0-9]" | tail -n1 | cut -d ' ' -f1 ) >> \
# $CDDIR/casper/filesystem.manifest-desktop
#done
return 0
}
compressFS()
{
log "Compressing squash image ..."
if [ -n "$(cat $MOUNTLIST)" ]; then
log "Error to umount $(cat $MOUNTLIST | tr '\n' ' ')"
return 1
fi
rm -f "$CDDIR"/casper/filesystem.squashfs
mksquashfs "$CHROOTDIR" "$CDDIR"/casper/filesystem.squashfs -comp gzip
du -sx --block-size=1 "$CHROOTDIR" | cut -f1 > "$CDDIR"/casper/filesystem.size
return 0
}
extractISO()
{
log "Extracting $1 ..."
initFiles
mount -o loop $1 "$TMP"/"$DISTROBASE" && log "$TMP/$DISTROBASE" >> "$MOUNTLIST"
rsync --exclude=/casper/filesystem.squashfs -a "$TMP"/"$DISTROBASE"/ "$CDDIR"\
|| return 1
unsquashfs "$TMP"/"$DISTROBASE"/casper/filesystem.squashfs || return 1
mv -f "$SQUASHIMAGE" "$CHROOTDIR" || return 1
umount "$TMP"/"$DISTROBASE" && removeMountList "$TMP"/"$DISTROBASE"
return 0
}
createISO()
{
log "Generating live ISO ..."
# Calculates MD5
cd "$CDDIR"/
rm -f md5sum.txt
find -type f -print0 | xargs -0 md5sum |
egrep -v 'isolinux/boot.cat|md5sum.txt' | tee md5sum.txt
# Generates ISO file
mkisofs -D -r -V "$DISTRO" -cache-inodes -J -l -b \
isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size \
4 -boot-info-table -o "$DISTROISO".iso "$CDDIR"
log "Generating iso checksum ..."
md5sum "$DISTROISO.iso" > "$DISTROISO.md5"
}
initFiles()
{
mkdir -p "$TMP" || return 1
mkdir -p "$TMP"/"$DISTROBASE" "$CDDIR" "$LOGDIR" || return 1
touch "$MOUNTLIST" || return 1
}
replaceIso()
{
if [ -e "$CDDIR" ]; then
log "Want to replace the current image? [y/N]"
read ack
if [ "$ack" == "y" ]; then
log "Cleaning temporary directory ..."
rm -rf "$TMP"/* "$CHROOTDIR" "$CDDIR" "$SQUASHIMAGE" || return 6
#$0 --clean --dist $1 || exit 6
else
log "Extraction canceled!"
return 1
fi
fi
return 0
}
log()
{
if "$LOGINFO" && [ "$1" ]; then
echo "$@" | tee -a "$LOGFILE"
logger -t le-gera-iso "$@"
elif [ "$1" ]; then
echo "$@"
else
tee -a "$LOGFILE"
fi
}
#------------------------------------------------------------------------------
# Sets configuration variables
DIR=$(readlink -f "$0")
. "`dirname "$(echo "$DIR")"`/common.sh"
nextDist=false
nextAll=false
iso=false
clean=false
all=false
dist=false
edit=false
host=false
mirror=false
nextHost=false
nextMirror=false
for opc in $*; do
case "$opc" in
--dist)
dist=true
nextDist=true
;;
--all)
all=true
nextAll=true
;;
--edit)
edit=true
;;
--iso)
iso=true
;;
--clean)
clean=true
;;
-bash)
bash
exit 0
;;
--host)
host=true
nextHost=true
;;
--mirror)
mirror=true
nextMirror=true
;;
*)
$nextHost && export LEHOST="$opc" && nextHost=false
$nextMirror && export LEMIRROR="$opc" && nextMirror=false
$nextDist && distName="$opc" && nextDist=false
$nextAll && baseIso="$opc" && nextAll=false
esac
done
if (($iso || $clean || $all || $edit) && (! $dist || [ -z "$distName" ])) ||
!($iso || $clean || $all || $edit); then
echo "Use: $0 OPTION [SRC_IMAGE] --dist DIST_RELEASE"
echo " OPTION:"
echo " --clean Cleaning temporary files and old iso"
echo " --iso Uses old temporary files to generates a new LE iso"
echo " --all Generate a new LE iso using the SRC_IMAGE file of base iso"
echo " --edit Executes the edit scripts using old temporary files"
exit 2
fi
loadConf "$PREFIX/conf/$distName/create-iso.conf" $distName
#------------------------------------------------------------------------------
# Check ambient integrity
LOGDIR="$LOGDIR"
LOGFILE="$LOGDIR/$(date +"%y-%m-%d_%T_")`basename "$(echo "$distName")"`_$LEMIRROR.log"
checkUser || exit 1
initFiles || exit 2
checkMountedFS || exit 7
#------------------------------------------------------------------------------
# Init routines
if $iso; then
if ! regenerateManifest | log; then
log "Error to regenarate manifest file"
exit 3
fi
if ! compressFS | log; then
log "Error to create squash image"
exit 4
fi
if ! createISO | log; then
log "Error to create ISO image"
exit 5
fi
elif $edit; then
if ! editDistro $distName | log; then
log "Error to edit Squash image"
exit 2
fi
elif $clean; then
log "Cleaning temporary directory ..."
rm -rf "$TMP"/* "$CHROOTDIR" "$CDDIR" "$SQUASHIMAGE" || exit 6
elif $all; then
replaceIso $distName || exit 6
if ! extractISO $baseIso | log; then
log "Error to extract $2"
exit 1
fi
if ! editDistro $distName | log; then
log "Error to edit Squash image"
exit 2
fi
if ! regenerateManifest | log; then
log "Error to regenarate manifest file"
exit 3
fi
if ! compressFS | log; then
log "Error to create squash image"
exit 4
fi
if ! createISO | log; then
log "Error to create ISO image"
exit 5
fi
fi
#/root/teste_ram/rsync.sh
exit 0
../../../scripts/00-update
\ No newline at end of file
../../../scripts/10-remove
\ No newline at end of file
../../../scripts/20-install
\ No newline at end of file
../../../scripts/40-configure_le5
\ No newline at end of file
../../../scripts/60-update-initrd_le5
\ No newline at end of file
../../../scripts/common-functions.sh
\ No newline at end of file
../../../scripts/00-update
\ No newline at end of file
../../../scripts/10-remove
\ No newline at end of file
../../../scripts/20-install
\ No newline at end of file
../../../scripts/40-configure_le5
\ No newline at end of file
../../../scripts/60-update-initrd_le5
\ No newline at end of file
../../../scripts/common-functions.sh
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment