| 1 |
#! /bin/sh
|
| 2 |
|
| 3 |
# $Id$
|
| 4 |
#*********************************************************************
|
| 5 |
#
|
| 6 |
# make-fai-nfsroot -- create nfsroot directory and add additional packages
|
| 7 |
#
|
| 8 |
# This script is part of FAI (Fully Automatic Installation)
|
| 9 |
# (c) 2000 by Thomas Lange, lange@informatik.uni-koeln.de
|
| 10 |
# Universitaet zu Koeln
|
| 11 |
#
|
| 12 |
#*********************************************************************
|
| 13 |
# This program is free software; you can redistribute it and/or modify
|
| 14 |
# it under the terms of the GNU General Public License as published by
|
| 15 |
# the Free Software Foundation; either version 2 of the License, or
|
| 16 |
# (at your option) any later version.
|
| 17 |
#
|
| 18 |
# This program is distributed in the hope that it will be useful, but
|
| 19 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 20 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 21 |
# General Public License for more details.
|
| 22 |
#
|
| 23 |
# A copy of the GNU General Public License is available as
|
| 24 |
# `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
|
| 25 |
# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
|
| 26 |
# can also obtain it by writing to the Free Software Foundation, Inc.,
|
| 27 |
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
| 28 |
#*********************************************************************
|
| 29 |
|
| 30 |
# Thomas Lange, Universitaet Koeln, 2000
|
| 31 |
|
| 32 |
# configuration of some packages will need some interactive input
|
| 33 |
# lilo, netbase,... will not be set up correctly, but that doesn't matter
|
| 34 |
# apt-get must been working on your server (sources.list must be OK)
|
| 35 |
|
| 36 |
PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
| 37 |
|
| 38 |
while getopts v opt ; do
|
| 39 |
case "$opt" in
|
| 40 |
v) verbose=1 ;;
|
| 41 |
esac
|
| 42 |
done
|
| 43 |
|
| 44 |
. /etc/fai.conf
|
| 45 |
|
| 46 |
conffile=$NFSROOT/etc/rcS_fai.conf
|
| 47 |
aptconf=$LIBFAI/etc/apt.conf.nfsroot
|
| 48 |
|
| 49 |
# Additional packages that are install to nfsroot
|
| 50 |
packages="$NFSROOT_PACKAGES perl-5.005 dhcp-client file rdate cfengine bootpc wget rsh-client less ssh dump ext2resize raidtools2 lvm strace expect5.31"
|
| 51 |
|
| 52 |
export DEBIAN_FRONTEND=Noninteractive
|
| 53 |
|
| 54 |
if [ "$verbose" ]; then
|
| 55 |
devnull=/dev/tty
|
| 56 |
else
|
| 57 |
devnull=/dev/null
|
| 58 |
fi
|
| 59 |
|
| 60 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 61 |
setup_ssh() {
|
| 62 |
|
| 63 |
# enable root login
|
| 64 |
perl -pi -e 's/PermitRootLogin no/PermitRootLogin yes/' $NFSROOT/etc/ssh/sshd_config
|
| 65 |
if [ -f "$SSH_IDENTITY" ]; then
|
| 66 |
mkdir -p -m 700 $NFSROOT/root/.ssh
|
| 67 |
cp -p $SSH_IDENTITY $NFSROOT/root/.shh/authorized_keys
|
| 68 |
echo You can log in install clients without password using $SSH_IDENTITY
|
| 69 |
fi
|
| 70 |
}
|
| 71 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 72 |
copy_fai_files() {
|
| 73 |
|
| 74 |
perl -pi -e "s/^root::/root:${ROOTPW}:/" etc/passwd
|
| 75 |
mkdir -p $NFSROOT/fai/fai_config $NFSROOT/usr/share/fai
|
| 76 |
cp -p $LIBFAI/sbin/dhclient-script $LIBFAI/etc/dhclient.conf $NFSROOT/etc
|
| 77 |
cp -p $LIBFAI/sbin/* $NFSROOT/sbin
|
| 78 |
cp -p /usr/share/fai/* $NFSROOT/usr/share/fai
|
| 79 |
cp -p $LIBFAI/etc/apt.conf $NFSROOT/etc/apt
|
| 80 |
cp -p /usr/lib/perl5/Debian/Fai.pm $NFSROOT/usr/lib/perl5/Debian/
|
| 81 |
cp -p /etc/fai.conf $NFSROOT/etc
|
| 82 |
echo "# rcS_fai.conf -- created by make-fai-nfsroot" >> $conffile
|
| 83 |
[ "LOGUSER" ] && echo "export LOGUSER=$LOGUSER" >> $conffile
|
| 84 |
}
|
| 85 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 86 |
create_nfsroot() {
|
| 87 |
|
| 88 |
cd $NFSROOT
|
| 89 |
get_basetgz
|
| 90 |
echo -n "Unpacking " ; ls /tmp/base?_?.tgz
|
| 91 |
tar zxpf /tmp/base?_?.tgz
|
| 92 |
mknod dev/boot255 c 0 255
|
| 93 |
|
| 94 |
# hoaks some packages
|
| 95 |
touch etc/fstab etc/raidtab # dump and raidtool2 needs these files
|
| 96 |
mkdir -p lib/modules/`uname -r` # dirty trick to hoax lvm
|
| 97 |
touch lib/modules/`uname -r`/modules.dep # dirty trick to hoax lvm
|
| 98 |
mkdir -p $NFSROOT/etc/ssh ; touch $NFSROOT/etc/ssh/NOSERVER
|
| 99 |
|
| 100 |
upgrade_nfsroot
|
| 101 |
copy_fai_files
|
| 102 |
|
| 103 |
# set timezone
|
| 104 |
rm -f $NFSROOT/etc/localtime
|
| 105 |
cp -dp /etc/localtime $NFSROOT/etc
|
| 106 |
cp -dp /etc/timezone $NFSROOT/etc
|
| 107 |
|
| 108 |
# make little changes to nfsroot, because most file systems are read only
|
| 109 |
rm -rf etc/mtab etc/apt/sources.list var/run
|
| 110 |
mv $NFSROOT/etc/init.d/rcS $NFSROOT/etc/init.d/rcS.orig
|
| 111 |
ln -s /proc/mounts $NFSROOT/etc/mtab
|
| 112 |
ln -s /tmp/var/run $NFSROOT/var/run
|
| 113 |
ln -s /tmp/etc/resolv.conf $NFSROOT/etc/resolv.conf
|
| 114 |
ln -s /sbin/rcS_fai $NFSROOT/etc/init.d/rcS
|
| 115 |
|
| 116 |
# kernel with modules do not log loading of modules
|
| 117 |
rmdir $NFSROOT/var/log/ksymoops/
|
| 118 |
ln -s /dev/null $NFSROOT/var/log/ksymoops
|
| 119 |
|
| 120 |
setup_ssh
|
| 121 |
|
| 122 |
cat >$NFSROOT/etc/rcS.d/S01fai_abort <<EOF
|
| 123 |
#!/bin/sh
|
| 124 |
echo FAI: installation aborted.
|
| 125 |
echo reboot with: faireboot
|
| 126 |
echo or after a logout
|
| 127 |
sh
|
| 128 |
cd /
|
| 129 |
umount -ar
|
| 130 |
reboot -dfi
|
| 131 |
EOF
|
| 132 |
chmod a+rx $NFSROOT/etc/rcS.d/S01fai_abort
|
| 133 |
}
|
| 134 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 135 |
upgrade_nfsroot() {
|
| 136 |
|
| 137 |
echo "Upgrading $NFSROOT"
|
| 138 |
{
|
| 139 |
apt-get -c $aptconf update
|
| 140 |
apt-get -c $aptconf check
|
| 141 |
chroot $NFSROOT mount -n -t proc proc /proc
|
| 142 |
rm -rf $NFSROOT/etc/pcmcia $NFSROOT/etc/apm
|
| 143 |
apt-get -c $aptconf -y remove pcmcia-cs </dev/null
|
| 144 |
|
| 145 |
# because start-stop-dameon must be faked do it here
|
| 146 |
apt-get -c $aptconf -y install dpkg </dev/null
|
| 147 |
cp -p $LIBFAI/sbin/start-stop-daemon $NFSROOT/sbin
|
| 148 |
|
| 149 |
apt-get -c $aptconf -y upgrade </dev/null
|
| 150 |
} > $devnull
|
| 151 |
echo "Adding additional packages to $NFSROOT:"
|
| 152 |
echo "$packages"
|
| 153 |
{
|
| 154 |
apt-get -c $aptconf -y --fix-missing install $packages </dev/null
|
| 155 |
chroot $NFSROOT umount -n /proc
|
| 156 |
} > $devnull
|
| 157 |
}
|
| 158 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 159 |
get_basetgz() {
|
| 160 |
|
| 161 |
[ -f /tmp/base?_?.tgz ] && return
|
| 162 |
case $BASETGZ in
|
| 163 |
ftp:*|http:*)
|
| 164 |
echo "Getting $BASETGZ via wget. This may take some time."
|
| 165 |
wget -q -P/tmp $BASETGZ
|
| 166 |
;;
|
| 167 |
*) cd /tmp ; ln -s $BASETGZ
|
| 168 |
;;
|
| 169 |
esac
|
| 170 |
}
|
| 171 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 172 |
install_kernel_nfsroot() {
|
| 173 |
rm -rf /boot/*-$KERNELVERSION $NFSROOT/lib/modules/$KERNELVERSION
|
| 174 |
dpkg -x $KERNELPACKAGE $NFSROOT
|
| 175 |
chroot $NFSROOT depmod -a -F /boot/System.map-$KERNELVERSION
|
| 176 |
}
|
| 177 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 178 |
|
| 179 |
if [ -d $NFSROOT/fai ]; then
|
| 180 |
echo $NFSROOT already exists. Removing $NFSROOT
|
| 181 |
umount $NFSROOT/dev/pts 2>/dev/null
|
| 182 |
rm -rf $NFSROOT/*
|
| 183 |
fi
|
| 184 |
create_nfsroot
|
| 185 |
install_kernel_nfsroot
|
| 186 |
mk3comimage $NFSROOT/boot/vmlinuz-$KERNELVERSION /boot/fai/installimage $NFSROOT/dev/nfs
|
| 187 |
|
| 188 |
exit 0
|