--- trunk/scripts/make-fai-nfsroot 2005/04/06 19:04:41 2758 +++ trunk/bin/make-fai-nfsroot 2007/09/13 09:39:53 4564 @@ -6,7 +6,7 @@ # make-fai-nfsroot -- create nfsroot directory and add additional packages # # This script is part of FAI (Fully Automatic Installation) -# (c) 2000-2005 by Thomas Lange, lange@informatik.uni-koeln.de +# (c) 2000-2007 by Thomas Lange, lange@informatik.uni-koeln.de # Universitaet zu Koeln # #********************************************************************* @@ -27,42 +27,77 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #********************************************************************* +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +usage() { + + cat <<-EOF + Copyright (C) 1999-2007 Thomas Lange + Report bugs to . + + Usage: make-fai-nfsroot [OPTIONS] + Create an NFSROOT for FAI. + Read the man pages pages make-fai-nfsroot(8). +EOF + exit 0 +} +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +die() { + + echo "ERROR: $@" + exit 99 +} +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin -if [ `id -u` -ne 0 ]; then - echo "Run this program as root." - exit 9 +kfile="vmlinuz" # some architectures use different names +merror="properly" +sshpreserve=0 +divert=1 + +if [ -f /etc/lsb-release ]; then + . /etc/lsb-release + case "$DISTRIB_ID" in + Ubuntu) divert=0 ;; + esac fi -merror="properly" # option e currently does nothing -while getopts ervc:f:kK opt ; do +while getopts hervC:f:kKpU opt ; do case "$opt" in - c) cfdir=$OPTARG ;; + C) cfdir=$OPTARG ;; v) verbose=1 ; v=-v ;; r) recover=1 ;; - f) cfg=$OPTARG ;; + f) die "Option -f is not supported any more. Use option -C instead" ;; k) kinstall=1 ;; - K) kremove=1; kinstall=1 ;; - e) expert=1 ;; + K) kremove=1;; + h) usage ;; + e) expert=1 ;; # a dummy option, that only fai-setup uses + p) sshpreserve=1 ;; + U) divert=0 ;; ?) exit 5 ;; # error in option parsing esac done +if [ $(id -u) != "0" ]; then + echo "Run this program as root." + exit 9 +fi + set -e -[ -z "$cfdir" ] && cfdir=/etc/fai +# use FAI_ETC_DIR from environment variable +if [ -n "$FAI_ETC_DIR" -a -z "$cfdir" ]; then + echo "Using environment variable \$FAI_ETC_DIR." +fi +[ -z "$cfdir" ] && cfdir=${FAI_ETC_DIR:=/etc/fai} +cfdir=$(readlink -f $cfdir) # canonicalize path if [ ! -d "$cfdir" ]; then echo "$cfdir is not a directory" exit 6 fi -[ "$verbose" ] && echo "Using configuration files from directory $cfdir" -if [ -n "$cfg" ]; then - . $cfdir/$cfg -else - . $cfdir/fai.conf -fi +[ "$verbose" ] && echo "Using configuration files from $cfdir" +. $cfdir/fai.conf # read config file for this tool if [ -f "$cfdir/make-fai-nfsroot.conf" ]; then @@ -72,55 +107,24 @@ exit 8 fi -if [ -z "$NFSROOT" ]; then - echo "\$NFSROOT is not set. Please check your settings in $cfdir/fai.conf." - exit 4 -fi - -if [ "$FAI_SOURCES_LIST" ]; then - echo "The usage of the variable \$FAI_SOURCES_LIST is deprecated. Please use sources.list now." - exit 3 -fi +# IMO this may be removed, since all information should be included into sources.list +[ -n "$FAI_LOCAL_REPOSITORY" ] && die "The use of \$FAI_LOCAL_REPOSITORY is now deprecated. Please include this information into sources.list." +[ -n "$packages" ] && die "The use of \$packages in make-fai-nfsroot.conf is now deprecated. Please include this information into $cfdir/NFSROOT." +[ -n "$NFSROOT_PACKAGES" ] && die "The use of \$NFSROOT_PACKAGES in make-fai-nfsroot.conf is now deprecated. Please include this information into $cfdir/NFSROOT." +[ -n "$FAI_SOURCES_LIST" ] && die "The use of \$FAI_SOURCES_LIST is deprecated. Please use sources.list now." -if [ ! -s "$cfdir/sources.list" -a ! -f /etc/apt/sources.list ]; then - echo "Neither $cfdir/sources.list nor /etc/apt/sources.list exists." - echo "I think something is wrong. Can't continue." - exit 7 -fi +[ -z "$NFSROOT" ] && die "\$NFSROOT is not set. Please check your settings in $cfdir/fai.conf." +[ ! -d "$cfdir/apt" ] && die "$cfdir/apt/ does not exists. Can't continue." -kfile="vmlinuz" -case `dpkg --print-installation-architecture` in - i386|amd64) - arch_packages="grub lilo read-edid kudzu hwtools dmidecode" ;; - - ia64) - arch_packages="elilo gnu-efi efibootmgr" ;; - - sparc) - arch_packages="silo sparc-utils" ;; - - powerpc) - arch_packages="" - kfile="vmlinux" ;; - - alpha) - arch_packages="aboot" ;; - - *) arch_packages="" ;; -esac -packages="$packages -$arch_packages" - +NFSROOT="$NFSROOT/live/filesystem.dir" ROOTCMD="chroot $NFSROOT" RUNDIR=/var/run/fai/make-fai-nfsroot -[ ! -d $RUNDIR ] && mkdir -p $RUNDIR -LIBFAI=/usr/lib/fai -SHAREFAI=/usr/share/fai +mkdir -p $RUNDIR export DEBIAN_FRONTEND=noninteractive [ "$recover" ] || rm -rf $RUNDIR/* -trap "umount_dirs" EXIT +trap 'echo "Aborting";umount_dirs' EXIT trap "bad_exit" ERR # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bad_exit() { @@ -130,12 +134,6 @@ echo "Please fix the error or try make-fai-nfsroot -v" } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -die() { - - echo "$@" - exit 99 -} -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call_with_stamp() { local func=$1 @@ -157,32 +155,32 @@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - install_kernel_nfsroot() { - rm -rf $NFSROOT/boot/*-$KERNELVERSION $NFSROOT/lib/modules/$KERNELVERSION - # since woody we can install the kernel using dpkg -i - echo "do_boot_enable=no" > $NFSROOT/etc/kernel-img.conf - dpkg -x $KERNELPACKAGE $NFSROOT - # if $NFROOT/proc/modules exists, then update-modules calls depmod -a without - # these special flags; so umount first - [ -e $NFSROOT/proc/modules ] && umount $NFSROOT/proc - chroot $NFSROOT update-modules - chroot $NFSROOT depmod -qaF /boot/System.map-$KERNELVERSION $KERNELVERSION || true + if [ $divert = 1 ]; then + rm $NFSROOT/usr/sbin/update-initramfs + LC_ALL=C $ROOTCMD dpkg-divert --rename --remove /usr/sbin/update-initramfs + $ROOTCMD update-initramfs -k all -t -u + fi } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - setup_ssh() { # nothing to do if no ssh is available in nfsroot - [ -f $NFSROOT/var/lib/dpkg/info/ssh.list ] || return 0 + [ -f $NFSROOT/usr/bin/ssh ] || return 0 + if [ $sshpreserve = 1 ]; then + tar -C $NFSROOT -xf $tmptar + rm $tmptar + return 0 + fi + mkdir -p -m 700 $NFSROOT/root/.ssh if [ -n "$LOGUSER" ] ; then loguserhome=`eval "cd ~$LOGUSER 2>/dev/null && pwd;true"` - # is copying of *.pub important? [ -f $loguserhome/.ssh/known_hosts ] && cp $loguserhome/.ssh/known_hosts $NFSROOT/root/.ssh/known_hosts [ -d $loguserhome/.ssh ] && { [ -f $loguserhome/.ssh/id_dsa ] && cp -p $loguserhome/.ssh/id_dsa* $NFSROOT/root/.ssh/ [ -f $loguserhome/.ssh/id_rsa ] && cp -p $loguserhome/.ssh/id_rsa* $NFSROOT/root/.ssh/ - cp -p $loguserhome/.ssh/*.pub $NFSROOT/root/.ssh/ } fi @@ -198,34 +196,31 @@ copy_fai_files() { # copy to nfsroot - perl -pi -e "s#^root::#root:${FAI_ROOTPW}:#" etc/passwd - mkdir -p $NFSROOT/$SHAREFAI $NFSROOT/$LIBFAI $NFSROOT/etc/fai - cd $NFSROOT - fdivert /etc/dhcp3/dhclient-script /etc/dhcp3/dhclient.conf - cp -p $SHAREFAI/etc/dhclient.conf etc/dhcp3 + echo "root:$FAI_ROOTPW" | $ROOTCMD chpasswd --encrypted cp -Rpv $cfdir/* $NFSROOT/etc/fai + # append additional variables to fai.conf for the install clients + [ -z "$FAI_CONFIG_SRC" ] && echo "FAI_CONFIG_SRC=nfs://`hostname`$FAI_CONFIGDIR" >> $NFSROOT/etc/fai/fai.conf + # remove some files that should not be copied rm -f $NFSROOT/etc/fai/make-fai-nfsroot.conf [ -f $cfdir/.cvspass ] && cp -p $v $cfdir/.cvspass $NFSROOT/.cvspass - cp -p $LIBFAI/sbin/* sbin/ - cp -p /usr/sbin/fai usr/sbin/ - mv sbin/dhclient-script etc/dhcp3 - cp -p /usr/sbin/{ftar,fcopy,install_packages} usr/sbin/ - cp -p /usr/bin/{fai-do-scripts,fai-class,fai-debconf} usr/bin/ - cp -p $LIBFAI/* usr/lib/fai 2>/dev/null || true # cp will complain about directories - cp -p $SHAREFAI/etc/fai_modules_off etc/modutils/ - - cp -p $SHAREFAI/subroutines* usr/share/fai - cp -p $v $SHAREFAI/etc/apt.conf $NFSROOT/etc/apt - cp -p /usr/share/perl5/Debian/Fai.pm usr/share/perl5/Debian/ $ROOTCMD shadowconfig on } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - call_debootstrap() { - echo "Creating nfsroot for $1 using debootstrap" - [ "$verbose" ] && echo "Calling debootstrap $1 $NFSROOT $2" - yes '' | LC_ALL=C call_verbose debootstrap $FAI_DEBOOTSTRAP_OPTS $1 $NFSROOT $2 || true + local dversion=$(dpkg -l debootstrap | grep debootstrap | cut -f7 -d' ') + echo "Creating base system using debootstrap version $dversion" + echo "Calling debootstrap $1 $NFSROOT $2" + yes '' | LC_ALL=C call_verbose debootstrap $FAI_DEBOOTSTRAP_OPTS $1 $NFSROOT $2 +} +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +add_all_host_entries() { + + local ips=$(ifconfig | grep -w inet | cut -d : -f 2 | cut -d ' ' -f 1 | grep -v 127.0.0.1) + for eth in $ips; do + getent hosts $eth >> etc/hosts || true + done } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - create_base() { @@ -235,7 +230,8 @@ $ROOTCMD apt-get clean rm -f $NFSROOT/etc/resolv.conf echo "Creating base.tgz" - tar -l -C $NFSROOT -cf - --exclude var/tmp/base.tgz . | gzip > $NFSROOT/var/tmp/base.tgz + tar --one-file-system -C $NFSROOT -cf - --exclude var/tmp/base.tgz . | gzip > $NFSROOT/var/tmp/base.tgz + touch $NFSROOT/.THIS_IS_THE_FAI_NFSROOT else die "\$FAI_DEBOOTSTRAP not defined." fi @@ -244,12 +240,11 @@ create_nfsroot() { mkdir -p $NFSROOT/$FAI - cd $NFSROOT || die "Error: Can't cd to $NFSROOT" + cd $NFSROOT || die "Can't cd to $NFSROOT" call_with_stamp create_base # save the list of all packages in the base.tgz $ROOTCMD dpkg --get-selections | egrep 'install$' | awk '{print $1}' > var/tmp/base-pkgs.lis - echo $arch_packages > $NFSROOT/var/tmp/packages.arch if [ "$FAI_DEBMIRROR" ]; then [ "$verbose" ] && echo "Mounting $FAI_DEBMIRROR to $NFSROOT/$MNTPOINT." @@ -262,27 +257,26 @@ # liloconfig, dump and raidtool2 needs these files echo "# UNCONFIGURED FSTAB FOR BASE SYSTEM" > etc/fstab > etc/raidtab - mkdir -p lib/modules/$KERNELVERSION # dirty trick to hoax lvm - > lib/modules/$KERNELVERSION/modules.dep # dirty trick to hoax lvm echo 'NTPSERVERS=""' > etc/default/ntp-servers - [ -d $NFSROOT/var/state ] || mkdir $NFSROOT/var/state - [ "$verbose" ] && echo "Try to copy $cfdir/sources.list or /etc/apt/sources.list." - cp -v $cfdir/sources.list $NFSROOT/etc/apt/sources.list || \ - cp -v /etc/apt/sources.list $NFSROOT/etc/apt/sources.list || \ - { echo "No sources.list file found." - echo "I think something is wrong. But I'll try to continue." - } - - echo "127.0.0.1 localhost" >> etc/hosts - echo "$NFSROOT_ETC_HOSTS" >> etc/hosts - [ -f /etc/apt/preferences ] && cp -v /etc/apt/preferences $NFSROOT/etc/apt - [ -f $cfdir/preferences ] && cp -v $cfdir/preferences $NFSROOT/etc/apt + # live.conf will set hostname to debian + cp /dev/null etc/live.conf + + cp -a $cfdir/apt $NFSROOT/etc + + ainsl -as $NFSROOT/etc/hosts "127.0.0.1 localhost" + ainsl $NFSROOT/etc/hosts "$NFSROOT_ETC_HOSTS" + add_all_host_entries + + # we need these option before installing the first package. So we + # can't put this into fai-nfsroot /etc/apt/apt.conf.d/90fai + cat <$NFSROOT/etc/apt/apt.conf.d/10fai +APT::Get::AllowUnauthenticated "true"; +Aptitude::CmdLine::Ignore-Trust-Violations yes; +EOF echo "Upgrading $NFSROOT" LC_ALL=C call_verbose call_with_stamp upgrade_nfsroot - echo "Adding additional packages to $NFSROOT:" - echo "$packages" - LC_ALL=C call_verbose call_with_stamp add_packages_nfsroot + LC_ALL=C call_with_stamp add_packages_nfsroot call_with_stamp copy_fai_files # set timezone in nfsroot @@ -290,87 +284,69 @@ echo $timezone > etc/timezone rm -f etc/localtime && ln -sf /usr/share/zoneinfo/$timezone etc/localtime - # make little changes to nfsroot, because nfsroot is - # read only for the install clients - rm -rf etc/mtab var/run etc/sysconfig - ln -s /proc/mounts etc/mtab - ln -s /tmp/var/run var/run - ln -sf /tmp/var/state/discover var/state/discover - ln -sf /tmp/var/lib/discover var/lib/discover - ln -s /tmp/etc/syslogsocket dev/log - ln -sf /tmp/etc/resolv.conf etc/resolv.conf - ln -sf /tmp etc/sysconfig + rm etc/mtab && ln -s /proc/mounts etc/mtab ln -s /usr/sbin/fai etc/init.d/rcS - ln -sf /dev/null etc/network/ifstate # for nis - [ -d var/yp ] && ln -s /tmp/binding var/yp/binding - - # turn off logging of loading kernel modules - [ -d var/log/ksymoops/ ] && rmdir var/log/ksymoops/ - ln -s /dev/null var/log/ksymoops +# [ -d var/yp ] && ln -s /tmp/binding var/yp/binding # definition for loopback device echo "iface lo inet loopback" > etc/network/interfaces - echo "*.* /tmp/fai/syslog.log" > etc/syslog.conf cat >> root/.profile <<-EOF PATH=/usr/local/sbin:/usr/local/bin:/usr/lib/fai:/bin:/sbin:/usr/bin:/usr/sbin: export PATH - . $SHAREFAI/subroutines - . $SHAREFAI/subroutines-$OS_TYPE + . /usr/lib/fai/subroutines + . /usr/lib/fai/subroutines-linux set -a - . /tmp/fai/variables.sh 2>/dev/null + . /tmp/fai/variables.log 2>/dev/null EOF call_verbose call_with_stamp setup_ssh - - cat >$NFSROOT/etc/rc2.d/S01fai_abort <<-EOF - #!/bin/sh - echo FAI: installation aborted. - echo reboot with: faireboot - echo or after a logout - sh - cd / - umount -ar - reboot -dfi -EOF - chmod a+rx $NFSROOT/etc/rc2.d/S01fai_abort - - echo -e "\n$FAI_LOCAL_REPOSITORY" >> etc/apt/sources.list } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - upgrade_nfsroot() { - cp -p $v /etc/resolv.conf $NFSROOT/etc/resolv.conf-installserver - cp -p $v /etc/resolv.conf $NFSROOT/etc/resolv.conf # this is needed during make-fai-nfsroot + if [ -f /etc/resolv.conf ]; then + cp -p $v /etc/resolv.conf $NFSROOT/etc/resolv.conf-installserver + cp -p $v /etc/resolv.conf $NFSROOT/etc/resolv.conf # this is needed during make-fai-nfsroot + fi $ROOTCMD apt-get update - $ROOTCMD apt-get -fyu install + $ROOTCMD apt-get -fy install fai-nfsroot $ROOTCMD apt-get check rm -rf $NFSROOT/etc/apm mount -t proc /proc $NFSROOT/proc - # fake start-stop-dameon - fdivert /etc/init.d/rcS /sbin/start-stop-daemon /sbin/discover-modprobe - cp /sbin/fai-start-stop-daemon $NFSROOT/sbin/ - ln -s /sbin/fai-start-stop-daemon $NFSROOT/sbin/start-stop-daemon + if [ $divert = 1 ]; then + fdivert /usr/sbin/update-initramfs + ln -s /bin/true $NFSROOT/usr/sbin/update-initramfs + fi + fdivert /sbin/start-stop-daemon /sbin/discover-modprobe + cp -p /sbin/fai-start-stop-daemon $NFSROOT/sbin + cp -p /sbin/fai-start-stop-daemon $NFSROOT/sbin/start-stop-daemon $ROOTCMD apt-get -y dist-upgrade } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - add_packages_nfsroot() { - $ROOTCMD apt-get -y --fix-missing install $packages $NFSROOT/etc/kernel-img.conf << EOF +do_bootloader = No +do_initrd = No +warn_initrd = No +EOF + install_packages -l -p$cfdir > $NFSROOT/var/tmp/packages.nfsroot + echo "Adding additional packages to $NFSROOT:" + cat $NFSROOT/var/tmp/packages.nfsroot + call_verbose install_packages $v -p$cfdir } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - umount_dirs() { [ -f $NFSROOT/usr/sbin/dpkg-divert ] && - LC_ALL=C $ROOTCMD dpkg-divert --package fai --rename --remove /sbin/discover-modprobe + LC_ALL=C $ROOTCMD dpkg-divert --rename --remove /sbin/discover-modprobe cd / - sleep 2 [ -d $NFSROOT/proc/self ] && umount $NFSROOT/proc [ -d $NFSROOT/proc/self ] && umount $NFSROOT/dev/pts if [ "$FAI_DEBMIRROR" ]; then @@ -383,14 +359,19 @@ get_kernel_version() { local package=$1 - KERNELVERSION=`dpkg --info $package | grep "Package: kernel-image" | sed -e 's/.*kernel-image-'//` + + KERNELVERSION=`dpkg --info $package | grep ' Package: '` + KERNELVERSION=${KERNELVERSION/*-image-/} } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - setup_bootp(){ + mkdir -p $TFTPROOT if [ -x "`which mkelf-linux`" ]; then - mkelf-linux --ip=any --output=/boot/fai/installimage \ - $NFSROOT/boot/$kfile-$KERNELVERSION + # does not work any mork if we do not know the excatly kernel name +: +# mkelf-linux --ip=any --output=$TFTPROOT/installimage \ +# $NFSROOT/boot/$kfile-$KERNELVERSION else echo "Command mkelf-linux not found. Can not set up BOOTP booting. Please install the package mknbi and rerun fai-setup." return @@ -399,7 +380,7 @@ # imggen is free software from 3com - use ver1.00: 1.01 produces "Image too Big" errors. # it converts netboot images to images which are bootable by 3com network cards if [ -x "`which imggen`" ]; then - imggen -a /boot/fai/installimage /boot/fai/installimage_3com + imggen -a $TFTPROOT/installimage $TFTPROOT/installimage_3com fi echo "BOOTP environment prepared." } @@ -409,9 +390,11 @@ # pxe and dhcp environment local pxebin=/usr/lib/syslinux/pxelinux.0 - cp -p $NFSROOT/boot/$kfile-$KERNELVERSION /boot/fai/$kfile-install - [ -f $pxebin ] && cp $pxebin /boot/fai - [ -d /boot/fai/pxelinux.cfg ] || mkdir -p /boot/fai/pxelinux.cfg || true + rm -f $NFSROOT/boot/*.bak + mkdir -p $TFTPROOT/pxelinux.cfg + cp -pv $NFSROOT/boot/$kfile-* $TFTPROOT + cp -pv $NFSROOT/boot/initrd.img-* $TFTPROOT + [ -f $pxebin ] && cp $pxebin $TFTPROOT echo "DHCP environment prepared. If you want to use it, you have to enable the dhcpd and the tftp-hpa daemon." } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -419,16 +402,13 @@ local item for item in "$@"; do - LC_ALL=C $ROOTCMD dpkg-divert --quiet --package fai --add --rename $item + LC_ALL=C $ROOTCMD dpkg-divert --quiet --add --rename $item done } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - kernel_install() { # Install the kernel package -if [ -f $KERNELPACKAGE ]; then - # determine kernel version - get_kernel_version $KERNELPACKAGE # create tftp boot images call_with_stamp install_kernel_nfsroot @@ -446,33 +426,40 @@ echo "Unknown boot option" ;; esac done -else - merror="with errors" - echo "Error. Kernel package $KERNELPACKAGE not found." - echo "No install kernel installed in /boot/fai." - echo "No kernel modules available in nfsroot." -fi } -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# - - - - - - - - - - - - - - - - - - - - - - - - - - # main routine # remove all kernels from nfsroot [ -n "$kremove" ] && { echo "Removing all kernels from NFSROOT." - rm -f $NFSROOT/boot/{System.map,vmlinuz,config}* - rm -rf $NFSROOT/lib/modules/2.* + $ROOTCMD aptitude -y purge ~nlinux-image + exit } + # just install a new kernel to the nfsroot [ -n "$kinstall" ] && { trap "true" EXIT echo "Installing new kernel into the nfsroot." + if [ $divert = 1 ]; then + fdivert /usr/sbin/update-initramfs + ln -s /bin/true $NFSROOT/usr/sbin/fai + fi + LC_ALL=C add_packages_nfsroot kernel_install - echo "New kernel from $KERNELPACKAGE installed into the nfsroot." exit } -echo Creating FAI nfsroot can take a long time and will -echo need more than $nfssize disk space in $NFSROOT. +echo "Creating FAI nfsroot in $NFSROOT." +echo "By default it needs more than 330 MBytes disk space." +echo "This may take a long time." + +if [ $sshpreserve = 1 ]; then + # save old .ssh directory + tmptar=$(mktemp) || exit 12 + # should we set the umask before? Does it influence the other parts? + tar -C $NFSROOT -cvf $tmptar root/.ssh +fi # Kill the directory if not in recover mode if [ -d $NFSROOT/$FAI -a ! "$recover" ] @@ -481,10 +468,13 @@ umount $NFSROOT/dev/pts 1>/dev/null 2>&1 || true rm -rf $NFSROOT/.??* $NFSROOT/* # also remove files $NFSROOT/.? but not . and .. - find $NFSROOT ! -type d -xdev -maxdepth 1 | xargs -r rm -f + find $NFSROOT -xdev -maxdepth 1 ! -type d | xargs -r rm -f fi # Create a new nfsroot +if [ ! -x "`which debootstrap`" ]; then + die "Can't find debootstrap command. Aborting." +fi call_with_stamp create_nfsroot kernel_install