X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=grml-live;h=0b228406dbd8e9fe88bf9b41798488f4ab50ea70;hb=ada9ee0154c453dc6f1236527e1a7ed82890ba4b;hp=53e19c8139e015731891b3453c0a20e831ca7160;hpb=4c620ad88db563c696d498f40bf045052c46ae05;p=grml-live.git diff --git a/grml-live b/grml-live index 53e19c8..0b22840 100755 --- a/grml-live +++ b/grml-live @@ -4,7 +4,7 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2 or any later version. -# Latest change: Tue Sep 18 09:11:50 CEST 2007 [mika] +# Latest change: Tue Sep 18 22:46:28 CEST 2007 [mika] ################################################################################ # read configuration files, set some misc variables {{{ @@ -26,7 +26,8 @@ VERBOSE='' FORCE='' # source main configuration file: -. /etc/grml/grml-live.conf +LIVE_CONF=/etc/grml/grml-live.conf +. $LIVE_CONF PN=$(basename $0) # TMPFILE=$(mktemp) @@ -35,6 +36,7 @@ PN=$(basename $0) # clean exit {{{ bailout() { # rm -f "$TMPFILE" + [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_TARGET}/${MIRROR_DIRECTORY}" [ -n "$1" ] && EXIT="$1" || EXIT="1" [ -n "$2" ] && echo "$2">&2 exit "$EXIT" @@ -47,7 +49,7 @@ trap bailout 1 2 3 15 [ -n "$HOSTNAME" ] || HOSTNAME=grml [ -n "$USERNAME" ] || USERNAME=grml [ -n "$CLASSES" ] || CLASSES="GRML,I386" -[ -n "$TARGET" ] || bailout 1 "${PN}: \$TARGET not specified. Please adjust /etc/grml/grml-live.conf. Exiting." +[ -n "$TARGET" ] || bailout 1 "${PN}: \$TARGET not specified. Please adjust $LIVE_CONF. Exiting." # }}} # usage information {{{ @@ -61,8 +63,8 @@ Usage: $PN [-c ] [-t ] [-s [-Fvh] Usage examples: $PN - $PN -c GRMLBASE,I386 -t /dev/shm/grml $PN -c GRMLBASE,GRML_X,I386 -t /grml/ + $PN -c GRMLBASE,I386 -t /dev/shm/grml $PN -c GRMLBASE,GRML_SMALL,I386 $PN -s sid -c GRMLBASE,I386 @@ -80,7 +82,6 @@ http://grml.org/bugs/ while getopts "c:s:t:Fhv" opt; do case "$opt" in c) CLASSES="$OPTARG" ;; - # f) FLAVOUR="$OPTARG" ;; # TODO F) FORCE=1 ;; h) usage ; bailout 0 ;; s) SUITE="$OPTARG" ;; @@ -98,9 +99,9 @@ shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter # }}} # some misc checks before executing FAI {{{ -[ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in /etc/grml/grml-live.conf or +[ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in $LIVE_CONF or specify it on the command line using the -c|--classes option." -[ -n "$TARGET" ] || bailout 1 "Error: \$TARGET unset, please set it in /etc/grml/grml-live.conf or +[ -n "$TARGET" ] || bailout 1 "Error: \$TARGET unset, please set it in $LIVE_CONF or specify it on the command line using the -t|--target option." # }}} @@ -128,21 +129,34 @@ fi # }}} # on-the-fly configuration {{{ -if [ -n "$GRML_LIVE_SOURCES" ] ; then +if [ -n "$MIRROR_DIRECTORY" ] ; then + if ! [ -d "$MIRROR_DIRECTORY/debian" ] ; then + echo "Sorry, $MIRROR_DIRECTORY/debian does not seem to exist. Exiting.">&2 + bailout 1 + fi + echo "$MIRROR_SOURCES" > /etc/grml/fai/apt/sources.list + if [ -n "$GRML_LIVE_SOURCES" ] ; then + echo "$GRML_LIVE_SOURCES" >> /etc/grml/fai/apt/sources.list + fi +elif [ -n "$GRML_LIVE_SOURCES" ] ; then echo "$GRML_LIVE_SOURCES" > /etc/grml/fai/apt/sources.list fi -# this heuristic is broken as it works exactly *once* by default :-/ -# TODO / FIXME -if [ -n "$SUITE" ] ; then - sed -i "s#etch #$SUITE #" /etc/grml/fai/make-fai-nfsroot.conf - sed -i "s#etch #$SUITE #" /etc/grml/grml-live.conf - sed -i "s# etch # $SUITE #" /etc/grml/grml-live.conf - sed -i "s# etch # $SUITE #" /etc/grml/fai/apt/sources.list +if [ -n "$FAI_DEBOOTSTRAP" ] ; then + sed -i "s#^FAI_DEBOOTSTRAP=.*#FAI_DEBOOTSTRAP=\"$FAI_DEBOOTSTRAP\"#" /etc/grml/fai/make-fai-nfsroot.conf fi -if [ -n "$FAI_DEBOOTSTRAP" ] ; then - sed -i "s#^FAI_DEBOOTSTRAP#FAI_DEBOOTSTRAP=$FAI_DEBOOTSTRAP#" /etc/grml/fai/make-fai-nfsroot.conf +# does this suck? YES! +if [ -n "$SUITE" ] ; then + sed -i "s/SUITE=.*/SUITE=\"$SUITE\"/" $LIVE_CONF + + DIST="\|\ etch\ \|\ stable\ \|\ lenny\ \|\ testing\ \|\ sid\ \|\ unstable\ " + sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" $LIVE_CONF + sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" /etc/grml/fai/apt/sources.list + + DIST='\"etch\|=\"stable=\"lenny=\"testing=\"sid=\"unstable' + sed -i "s#FAI_DEBOOTSTRAP=$DIST#FAI_DEBOOTSTRAP=\"$SUITE#" $LIVE_CONF + sed -i "s#FAI_DEBOOTSTRAP=$DIST#FAI_DEBOOTSTRAP=\"$SUITE#" /etc/grml/fai/make-fai-nfsroot.conf fi # }}} @@ -150,19 +164,32 @@ fi [ -n "$CHROOT_TARGET" ] || CHROOT_TARGET="$TARGET/grml_chroot" if [ -d "$CHROOT_TARGET" ] ; then - echo " [x] $CHROOT_TARGET exists already, skipping the stage 'fai dirnstall'" + echo " [x] $CHROOT_TARGET exists already, skipping the stage 'fai dirinstall'" else - mkdir "$CHROOT_TARGET" || bailout 5 "Problem with creating $CHROOT_TARGET for FAI" + mkdir -p "$CHROOT_TARGET" || bailout 5 "Problem with creating $CHROOT_TARGET for FAI" + if [ -n "${MIRROR_DIRECTORY}" ] ; then + mkdir -p "${CHROOT_TARGET}/${MIRROR_DIRECTORY}" + mount --bind "${MIRROR_DIRECTORY}" "${CHROOT_TARGET}/${MIRROR_DIRECTORY}" + fi fai $VERBOSE -C "$GRML_FAI_CONFIG" -c"$CLASSES" dirinstall "$CHROOT_TARGET" $FAI_ARGS umount $CHROOT_TARGET/proc 2>/dev/null || /bin/true umount $CHROOT_TARGET/sys 2>/dev/null || /bin/true - # notice: 'fai dirinstall' does not seem to exit appropriate -> - # we need better error handling - if [ -r "$CHROOT_TARGET"/etc/grml_cd ] ; then - echo " [*] Finished execution of stage 'fai dirinstall'" - else + [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_TARGET}/${MIRROR_DIRECTORY}" + + # notice: 'fai dirinstall' does not seem to exit appropriate, so: + ERROR='' + [ -r "/var/log/fai/dirinstall/$HOSTNAME/software.log" ] && + grep -q 'dpkg: error processing' /var/log/fai/dirinstall/$HOSTNAME/software.log && ERROR=1 + + [ -r "/var/log/fai/dirinstall/$HOSTNAME/shell.log" ] && + grep -q 'FAILED with exit code' /var/log/fai/dirinstall/$HOSTNAME/shell.log && ERROR=2 + + if [ -n "$ERROR" ] ; then echo " [!] There was an error during execution of stage 'fai dirinstall'" + echo " Check out /var/log/fai/dirinstall/$HOSTNAME/... for details. [exit ${ERROR}]" exit 1 + else + echo " [*] Finished execution of stage 'fai dirinstall'" fi fi # }}}