#! /bin/bash # I found it necessary to modify the default behaviour, because # fai has some quirks I don't like. # - if base.tgz exists then always use it instead of bootstrapping # - find a valid base image via a class # this class is used nowhere else and doesn't have # other uses. # (- always state a Debian base archive is being extracted) # - fai barfs on debootstraps exit code 141 # (this still needs a proper analysis) # read additional information from the environment or from the # identityfile, values given in identityfile have preference! # this file must contain: # FAI_OSTYPE - which OS to install (Debian, Ubuntu, SuSE?) # FAI_OSVERS - which version to install? (etch, lenny, sid, hardy, 10SP2) # FAI_OSARCH - x86_32 or x86_64? if [ -r ${IDENTITYFILE} ] ; then source ${IDENTITYFILE} fi ## Preparation - lenny's grub has a small cosmetic flaw ## it always tries to read the device map from the root ## device - but an nfsroot doesn't have / need a device map # PATCHLOCATION is defined in class/DEFAULT # may have been overwritten by a later definition cat $PATCHLOCATION/grub-install.patch | patch -p 1 ## Step 1 - check for debootstrap options or create new ones if [ -z ${FAI_DEBOOTSTRAP} ] ; then case ${OS_TYPE} in Debian) FAI_DEBOOTSTRAP="${OS_VERS} http://ftp.de.debian.org/debian/" ;; Ubuntu) FAI_DEBOOTSTRAP="${OS_VERS} http://de.archive.ubuntu.com/ubuntu/" ;; esac fi if [ -z ${FAI_DEBOOTSTRAP_OPTS} ] ; then # make sure debootstrap contains correct architecture case ${OS_ARCH} in X86_32) ARCH="--arch=i386" ;; X86_64) ARCH="--arch=amd64" ;; esac # make sure ubuntu is installed with aptitude # the intrepid-script on Debian/Lenny doesn't include it if [[ ${OS_TYPE} = "Ubuntu" ]] ; then INCLUDE="--include=aptitude" fi # don't install dhcp-client or dhcp3-client # it's only installed when requested EXCLUDE="--exclude=dhcp3-client,dhcp-client" FAI_DEBOOTSTRAP_OPTS="$ARCH $INCLUDE $EXCLUDE $FAI_DEBOOTSTRAP_OPTS" fi # this code is copied from task_extrbase() found in # /usr/lib/fai/subroutines-linux # changes: # - don't lie about installing debian # - if IGNOREBASETGZ is set, the base.tgz is ignored # - regard debootstraps exit code 141 as valid echo "Installing ${OS_TYPE} base archive." fs=$FAI_ROOT/etc/fstab if [[ $SWREPO != "" ]] ; then wget -q -P /tmp/ "$SWREPO/basefiles/BASE_${OS_TYPE}-${OS_VERS}-${OS_ARCH}.tar.gz" basefile=/tmp/BASE_${OS_TYPE}-${OS_VERS}-${OS_ARCH}.tar.gz else basefile=$FAI/basefiles/BASE_${OS_TYPE}-${OS_VERS}-${OS_ARCH}.tar.gz fi # find & extract the base file if [ -r ${basefile} ] ; then echo "Unpacking ${basefile}" tar xzf ${basefile} -C ${target} else # or use base.tgz (if allowed) / call debootstrap echo "Could not find BASE_${OS_TYPE}-${OS_VERS}-${OS_ARCH}.tar.gz in $FAI/basefiles/" [ $do_init_tasks -eq 0 ] && basefile=$NFSROOT/live/filesystem.dir/var/tmp/base.tgz if [ -f $basefile ] && [[ $IGNOREBASETGZ = 0 ]] ; then # extract the tar file which was the result of debootstrap echo "Extracting $basefile" gzip -dc $basefile | tar -C $FAI_ROOT -xpf - else echo "Calling debootstrap." [ -z "$FAI_DEBOOTSTRAP" ] && die "$FAI_DEBOOTSTRAP undefined. Aborting" call_debootstrap $FAI_DEBOOTSTRAP $FAI_DEBOOTSTRAP_OPTS RETVAL=$? [[ $verbose = 1 ]] && echo "debootstrap return value: $RETVAL" # debootstrap completes with the following message: # "I: Base system installed successfully." but the return code is 141 if [ $RETVAL = 141 ] ; then RETVAL=0 fi task_error 801 $RETVAL fi fi # now we can copy fstab [ -f $fs ] && mv $fs $fs.old [ -f $LOGDIR/fstab ] && cp -p $LOGDIR/fstab $fs # no need for task_extrbase() anymore, everything's set up skiptask extrbase