# Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2 or any later version.
-# Latest change: Mon Nov 05 09:24:45 CET 2007 [mika]
+# Latest change: Mon Nov 26 15:13:41 CET 2007 [mika]
################################################################################
# read configuration files, set some misc variables {{{
# exit on any error:
set -e
-GRML_LIVE_VERSION='0.0.7'
+GRML_LIVE_VERSION='0.0.11'
CMDLINE="$0 $@"
ISO_DATE="$(date +%Y-%m-%d)"
exit 1
fi
+# see #449236
if [ -r /var/run/fai/fai_softupdate_is_running ] ; then
echo "/usr/sbin/fai softupdate already running or was aborted before.">&2
echo "You may remove /var/run/fai/fai_softupdate_is_running and try again.">&2
log "------------------------------------------------------------------------------"
exit "$EXIT"
}
+# trap bailout 1 2 3 6 9 14 15
trap bailout 1 2 3 15
# }}}
touch $LOGFILE
chown root:adm $LOGFILE
chmod 640 $LOGFILE
-# clean/zero logfile:
+# clean/zero grml-live logfile:
if [ -n "$ZERO_LOGFILE" ] ; then
echo -n > $LOGFILE
fi
+# clean/zero/remove old FAI directory:
+if [ -n "$ZERO_FAI_LOGFILE" ] ; then
+ if [ -d /var/log/fai/"$HOSTNAME" ] ; then
+ rm -rf /var/log/fai/"$HOSTNAME"/"$(readlink /var/log/fai/"$HOSTNAME"/last)"
+ fi
+fi
+
NFSROOT_CONF=/etc/grml/fai/make-fai-nfsroot.conf
# }}}
# command line parsing {{{
-while getopts "a:c:g:i:o:r:s:t:v:FhuV" opt; do
+while getopts "a:C:c:g:i:o:r:s:t:v:FhuV" opt; do
case "$opt" in
a) ARCH="$OPTARG" ;;
c) CLASSES="$OPTARG" ;;
+ C) CONFIG="$OPTARG" ;;
g) GRML_NAME="$OPTARG" ;;
i) ISO_NAME="$OPTARG" ;;
o) OUTPUT="$OPTARG"
echo
echo " FAI classes: $CLASSES"
echo " main directory: $OUTPUT"
+ [ -n "$CONFIG" ] && echo " configuration: $CONFIG"
[ -n "$CHROOT_OUTPUT" ] && echo " chroot target: $CHROOT_OUTPUT"
[ -n "$BUILD_OUTPUT" ] && echo " build target: $BUILD_OUTPUT"
[ -n "$ISO_OUTPUT" ] && echo " ISO target: $ISO_OUTPUT"
echo
fi
+# read local (non-packaged) configuration:
+LOCAL_CONFIG=/etc/grml/grml-live.local
+if [ -r "$LOCAL_CONFIG" ] ; then
+ log "Sourcing $LOCAL_CONFIG"
+ . $LOCAL_CONFIG
+else
+ LOCAL_CONFIG=''
+fi
+
+if [ -n "$CONFIG" ] ; then
+ if ! [ -f "$CONFIG" ] ; then
+ log "Sorry, $CONFIG could not be read. Exiting. [$(date)]"
+ eerror "Sorry, $CONFIG could not be read. Exiting."
+ bailout 1
+ else
+ log "Sourcing $CONFIG"
+ . $CONFIG
+ fi
+fi
+
start_seconds=$(cut -d . -f 1 /proc/uptime)
log "------------------------------------------------------------------------------"
log "Starting grml-live [${GRML_LIVE_VERSION}] run on $(date)"
-log "Executed command line: $CMDLINE"
+log "Executed grml-live command line:"
+log "$CMDLINE"
einfo "Logging actions to logfile $LOGFILE"
# }}}
# 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
+ for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
+ if [ -n "$file" ] ; 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/" $file
+ fi
+ done
+
sed -i "s/\(deb .\+\)\([ \t]+\)$DIST\([ \t]+\)\(main \)/\1\2 $SUITE \3\4/" /etc/grml/fai/apt/sources.list
# notice: activate grml-live pool only if we are building against unstable:
if grep -qe unstable -qe sid /etc/grml/fai/apt/sources.list ; then
sed -i 's/.*grml-live.*/# removed grml-live repository/' /etc/grml/fai/apt/sources.list
fi
- sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" $LIVE_CONF
+ for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
+ if [ -n "$file" ] ; then
+ sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file"
+ fi
+ done
sed -i "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" $NFSROOT_CONF
fi
ewarn "$CHROOT_OUTPUT exists already, skipping stage 'fai dirinstall'" ; eend 0
else
mkdir -p "$CHROOT_OUTPUT" || bailout 5 "Problem with creating $CHROOT_OUTPUT for FAI"
+
if [ -n "${MIRROR_DIRECTORY}" ] ; then
mkdir -p "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
mount --bind "${MIRROR_DIRECTORY}" "${CHROOT_OUTPUT}/${MIRROR_DIRECTORY}"
fi
+
+ log "Executed FAI command line:"
+ log "fai $VERBOSE -C $GRML_FAI_CONFIG -c$CLASSES -u $HOSTNAME $FAI_ACTION $CHROOT_OUTPUT $FAI_ARGS"
fai $VERBOSE -C "$GRML_FAI_CONFIG" -c"$CLASSES" -u "$HOSTNAME" $FAI_ACTION "$CHROOT_OUTPUT" $FAI_ARGS | tee -a $LOGFILE
log "Setting /etc/grml_version to $GRML_NAME $VERSION Release Codename $RELEASENAME [$ISO_DATE]"
# notice: 'fai dirinstall' does not seem to exit appropriate, so:
ERROR=''
- if [ -n "$UPDATE" ] ; then
- CHECKLOG=/var/log/fai/current/
- else
- CHECKLOG=/var/log/fai/dirinstall/$HOSTNAME/
- fi
+ CHECKLOG=/var/log/fai/$HOSTNAME/last
if [ -r "$CHECKLOG/software.log" ] ; then
# 1 errors during executing of commands
# Unable to write mmap - msync (28 No space left on device)
INITRD="$(ls $CHROOT_OUTPUT/boot/initrd* 2>/dev/null| grep -v '.bak$' | sort -r | head -1)"
if [ -n "$INITRD" ] ; then
cp $INITRD "$BUILD_OUTPUT"/boot/isolinux/initrd.gz
+ find $CHROOT_OUTPUT/boot/ -name initrd\*.bak -exec rm {} \;
else
log "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting"
eerror "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
fi
KERNEL_IMAGE="$(ls $CHROOT_OUTPUT/boot/vmlinuz* 2>/dev/null | sort -r | head -1)"
- if [ -n "$INITRD" ] ; then
+ if [ -n "$KERNEL_IMAGE" ] ; then
cp "$KERNEL_IMAGE" "$BUILD_OUTPUT"/boot/isolinux/linux26
else
log "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting"
ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0
else
[ -d "$BUILD_OUTPUT"/live ] || mkdir "$BUILD_OUTPUT"/live
+ # make sure we don't leave (even an empty) base.tgz:
+ [ -f "$CHROOT_OUTPUT/base.tgz" ] && rm -f "$CHROOT_OUTPUT/base.tgz"
+
+ # execute squashfs:
+ log "mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/grml.squashfs -noappend"
mksquashfs $CHROOT_OUTPUT/* $BUILD_OUTPUT/live/grml.squashfs -noappend
log "Finished execution of stage 'squashfs' [$(date)]"
einfo "Finished execution of stage 'squashfs'" ; eend 0
mkdir -p "$ISO_OUTPUT" || bailout 6 "Problem with creating $ISO_OUTPUT for stage 'iso build'"
CURRENT_DIR=$(pwd)
cd "$BUILD_OUTPUT" &&
+ log "mkisofs -V grml $VERSION -publisher 'grml-live | grml.org' -l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b $BOOT_FILE -o ${ISO_OUTPUT}/${ISO_NAME} ."
mkisofs -V "grml $VERSION" -publisher 'grml-live | grml.org' \
-l -r -J -no-emul-boot -boot-load-size 4 -boot-info-table \
-b $BOOT_FILE \