#! /bin/sh # $Id$ #********************************************************************* # # make-fai-nfsroot -- create nfsroot directory and add additional packages # # This script is part of FAI (Fully Automatic Installation) # (c) 2000 by Thomas Lange, lange@informatik.uni-koeln.de # Universitaet zu Koeln # #********************************************************************* # This program 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. # # A copy of the GNU General Public License is available as # `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution # or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You # can also obtain it by writing to the Free Software Foundation, Inc., # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #********************************************************************* # Thomas Lange, Universitaet Koeln, 2000 # configuration of some packages will need some interactive input # lilo, netbase,... will not be set up correctly, but that doesn't matter # apt-get must been working on your server (sources.list must be OK) PATH=/bin:/sbin:/usr/bin:/usr/sbin while getopts v opt ; do case "$opt" in v) verbose=1 ;; esac done . /etc/fai.conf conffile=$NFSROOT/etc/rcS_fai.conf aptconf=$LIBFAI/etc/apt.conf.nfsroot # Additional packages that are install to nfsroot packages="$NFSROOT_PACKAGES perl-5.005 dhcp-client file rdate cfengine bootpc wget rsh-client less ssh dump ext2resize raidtools2 lvm strace expect5.31" export DEBIAN_FRONTEND=Noninteractive if [ "$verbose" ]; then devnull=/dev/tty else devnull=/dev/null fi # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - setup_ssh() { # enable root login perl -pi -e 's/PermitRootLogin no/PermitRootLogin yes/' $NFSROOT/etc/ssh/sshd_config if [ -f "$SSH_IDENTITY" ]; then mkdir -p -m 700 $NFSROOT/root/.ssh cp -p $SSH_IDENTITY $NFSROOT/root/.shh/authorized_keys echo You can log in install clients without password using $SSH_IDENTITY fi } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - copy_fai_files() { perl -pi -e "s/^root::/root:${ROOTPW}:/" etc/passwd mkdir -p $NFSROOT/fai/fai_config $NFSROOT/usr/share/fai cp -p $LIBFAI/sbin/dhclient-script $LIBFAI/etc/dhclient.conf $NFSROOT/etc cp -p $LIBFAI/sbin/* $NFSROOT/sbin cp -p /usr/share/fai/* $NFSROOT/usr/share/fai cp -p $LIBFAI/etc/apt.conf $NFSROOT/etc/apt cp -p /usr/lib/perl5/Debian/Fai.pm $NFSROOT/usr/lib/perl5/Debian/ cp -p /etc/fai.conf $NFSROOT/etc echo "# rcS_fai.conf -- created by make-fai-nfsroot" >> $conffile [ "LOGUSER" ] && echo "export LOGUSER=$LOGUSER" >> $conffile } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - create_nfsroot() { mkdir -p $NFSROOT cd $NFSROOT get_basetgz echo -n "Unpacking " ; ls /tmp/base?_?.tgz tar zxpf /tmp/base?_?.tgz mknod dev/boot255 c 0 255 # hoaks some packages touch etc/fstab etc/raidtab # dump and raidtool2 needs these files mkdir -p lib/modules/`uname -r` # dirty trick to hoax lvm touch lib/modules/`uname -r`/modules.dep # dirty trick to hoax lvm mkdir -p $NFSROOT/etc/ssh ; touch $NFSROOT/etc/ssh/NOSERVER upgrade_nfsroot copy_fai_files # set timezone rm -f $NFSROOT/etc/localtime cp -dp /etc/localtime $NFSROOT/etc cp -dp /etc/timezone $NFSROOT/etc # make little changes to nfsroot, because most file systems are read only rm -rf etc/mtab etc/apt/sources.list var/run mv $NFSROOT/etc/init.d/rcS $NFSROOT/etc/init.d/rcS.orig ln -s /proc/mounts $NFSROOT/etc/mtab ln -s /tmp/var/run $NFSROOT/var/run ln -s /tmp/etc/resolv.conf $NFSROOT/etc/resolv.conf ln -s /sbin/rcS_fai $NFSROOT/etc/init.d/rcS # kernel with modules do not log loading of modules rmdir $NFSROOT/var/log/ksymoops/ ln -s /dev/null $NFSROOT/var/log/ksymoops setup_ssh cat >$NFSROOT/etc/rcS.d/S01fai_abort < $devnull echo "Adding additional packages to $NFSROOT:" echo "$packages" { apt-get -c $aptconf -y --fix-missing install $packages $devnull } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - get_basetgz() { [ -f /tmp/base?_?.tgz ] && return case $BASETGZ in ftp:*|http:*) echo "Getting $BASETGZ via wget. This may take some time." wget -q -P/tmp $BASETGZ ;; *) cd /tmp ; ln -s $BASETGZ ;; esac } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - install_kernel_nfsroot() { rm -rf /boot/*-$KERNELVERSION $NFSROOT/lib/modules/$KERNELVERSION dpkg -x $KERNELPACKAGE $NFSROOT chroot $NFSROOT depmod -a -F /boot/System.map-$KERNELVERSION } # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if [ -d $NFSROOT/fai ]; then echo $NFSROOT already exists. Removing $NFSROOT umount $NFSROOT/dev/pts 2>/dev/null rm -rf $NFSROOT fi create_nfsroot install_kernel_nfsroot mk3comimage $NFSROOT/boot/vmlinuz-$KERNELVERSION /boot/fai/installimage $NFSROOT/dev/nfs exit 0