| 1 |
lange |
46 |
#! /bin/sh |
| 2 |
lange |
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 |
lange |
119 |
# Thomas Lange, Universitaet Koeln, 2000 |
| 31 |
lange |
2 |
|
| 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 |
lange |
27 |
PATH=/bin:/sbin:/usr/bin:/usr/sbin |
| 37 |
lange |
43 |
|
| 38 |
lange |
119 |
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 |
lange |
14 |
# Additional packages that are install to nfsroot |
| 50 |
lange |
119 |
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 |
lange |
2 |
|
| 52 |
lange |
14 |
export DEBIAN_FRONTEND=Noninteractive |
| 53 |
lange |
2 |
|
| 54 |
lange |
14 |
if [ "$verbose" ]; then |
| 55 |
|
|
devnull=/dev/tty |
| 56 |
|
|
else |
| 57 |
|
|
devnull=/dev/null |
| 58 |
|
|
fi |
| 59 |
lange |
2 |
|
| 60 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 61 |
lange |
69 |
setup_ssh() { |
| 62 |
|
|
|
| 63 |
lange |
119 |
# 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 |
lange |
69 |
} |
| 71 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 72 |
lange |
119 |
copy_fai_files() { |
| 73 |
lange |
2 |
|
| 74 |
lange |
119 |
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 |
lange |
129 |
mkdir -p $NFSROOT |
| 89 |
lange |
119 |
cd $NFSROOT |
| 90 |
lange |
69 |
get_basetgz |
| 91 |
lange |
119 |
echo -n "Unpacking " ; ls /tmp/base?_?.tgz |
| 92 |
|
|
tar zxpf /tmp/base?_?.tgz |
| 93 |
|
|
mknod dev/boot255 c 0 255 |
| 94 |
|
|
|
| 95 |
|
|
# hoaks some packages |
| 96 |
lange |
14 |
touch etc/fstab etc/raidtab # dump and raidtool2 needs these files |
| 97 |
|
|
mkdir -p lib/modules/`uname -r` # dirty trick to hoax lvm |
| 98 |
|
|
touch lib/modules/`uname -r`/modules.dep # dirty trick to hoax lvm |
| 99 |
lange |
119 |
mkdir -p $NFSROOT/etc/ssh ; touch $NFSROOT/etc/ssh/NOSERVER |
| 100 |
|
|
|
| 101 |
lange |
27 |
upgrade_nfsroot |
| 102 |
lange |
119 |
copy_fai_files |
| 103 |
|
|
|
| 104 |
|
|
# set timezone |
| 105 |
|
|
rm -f $NFSROOT/etc/localtime |
| 106 |
|
|
cp -dp /etc/localtime $NFSROOT/etc |
| 107 |
|
|
cp -dp /etc/timezone $NFSROOT/etc |
| 108 |
|
|
|
| 109 |
|
|
# make little changes to nfsroot, because most file systems are read only |
| 110 |
lange |
2 |
rm -rf etc/mtab etc/apt/sources.list var/run |
| 111 |
lange |
119 |
mv $NFSROOT/etc/init.d/rcS $NFSROOT/etc/init.d/rcS.orig |
| 112 |
|
|
ln -s /proc/mounts $NFSROOT/etc/mtab |
| 113 |
|
|
ln -s /tmp/var/run $NFSROOT/var/run |
| 114 |
|
|
ln -s /tmp/etc/resolv.conf $NFSROOT/etc/resolv.conf |
| 115 |
|
|
ln -s /sbin/rcS_fai $NFSROOT/etc/init.d/rcS |
| 116 |
lange |
2 |
|
| 117 |
lange |
119 |
# kernel with modules do not log loading of modules |
| 118 |
|
|
rmdir $NFSROOT/var/log/ksymoops/ |
| 119 |
|
|
ln -s /dev/null $NFSROOT/var/log/ksymoops |
| 120 |
|
|
|
| 121 |
|
|
setup_ssh |
| 122 |
|
|
|
| 123 |
|
|
cat >$NFSROOT/etc/rcS.d/S01fai_abort <<EOF |
| 124 |
lange |
2 |
#!/bin/sh |
| 125 |
|
|
echo FAI: installation aborted. |
| 126 |
lange |
14 |
echo reboot with: faireboot |
| 127 |
lange |
2 |
echo or after a logout |
| 128 |
|
|
sh |
| 129 |
|
|
cd / |
| 130 |
|
|
umount -ar |
| 131 |
|
|
reboot -dfi |
| 132 |
|
|
EOF |
| 133 |
lange |
119 |
chmod a+rx $NFSROOT/etc/rcS.d/S01fai_abort |
| 134 |
lange |
2 |
} |
| 135 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 136 |
lange |
27 |
upgrade_nfsroot() { |
| 137 |
lange |
2 |
|
| 138 |
lange |
119 |
echo "Upgrading $NFSROOT" |
| 139 |
|
|
{ |
| 140 |
|
|
apt-get -c $aptconf update |
| 141 |
|
|
apt-get -c $aptconf check |
| 142 |
|
|
chroot $NFSROOT mount -n -t proc proc /proc |
| 143 |
|
|
rm -rf $NFSROOT/etc/pcmcia $NFSROOT/etc/apm |
| 144 |
|
|
apt-get -c $aptconf -y remove pcmcia-cs </dev/null |
| 145 |
lange |
57 |
|
| 146 |
|
|
# because start-stop-dameon must be faked do it here |
| 147 |
lange |
119 |
apt-get -c $aptconf -y install dpkg </dev/null |
| 148 |
|
|
cp -p $LIBFAI/sbin/start-stop-daemon $NFSROOT/sbin |
| 149 |
lange |
57 |
|
| 150 |
lange |
119 |
apt-get -c $aptconf -y upgrade </dev/null |
| 151 |
|
|
} > $devnull |
| 152 |
|
|
echo "Adding additional packages to $NFSROOT:" |
| 153 |
lange |
69 |
echo "$packages" |
| 154 |
lange |
119 |
{ |
| 155 |
|
|
apt-get -c $aptconf -y --fix-missing install $packages </dev/null |
| 156 |
|
|
chroot $NFSROOT umount -n /proc |
| 157 |
|
|
} > $devnull |
| 158 |
lange |
2 |
} |
| 159 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 160 |
lange |
69 |
get_basetgz() { |
| 161 |
lange |
2 |
|
| 162 |
lange |
119 |
[ -f /tmp/base?_?.tgz ] && return |
| 163 |
|
|
case $BASETGZ in |
| 164 |
|
|
ftp:*|http:*) |
| 165 |
|
|
echo "Getting $BASETGZ via wget. This may take some time." |
| 166 |
|
|
wget -q -P/tmp $BASETGZ |
| 167 |
|
|
;; |
| 168 |
|
|
*) cd /tmp ; ln -s $BASETGZ |
| 169 |
|
|
;; |
| 170 |
|
|
esac |
| 171 |
lange |
69 |
} |
| 172 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 173 |
lange |
119 |
install_kernel_nfsroot() { |
| 174 |
|
|
rm -rf /boot/*-$KERNELVERSION $NFSROOT/lib/modules/$KERNELVERSION |
| 175 |
|
|
dpkg -x $KERNELPACKAGE $NFSROOT |
| 176 |
|
|
chroot $NFSROOT depmod -a -F /boot/System.map-$KERNELVERSION |
| 177 |
|
|
} |
| 178 |
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 179 |
lange |
2 |
|
| 180 |
lange |
119 |
if [ -d $NFSROOT/fai ]; then |
| 181 |
|
|
echo $NFSROOT already exists. Removing $NFSROOT |
| 182 |
|
|
umount $NFSROOT/dev/pts 2>/dev/null |
| 183 |
lange |
129 |
rm -rf $NFSROOT |
| 184 |
lange |
2 |
fi |
| 185 |
lange |
119 |
create_nfsroot |
| 186 |
|
|
install_kernel_nfsroot |
| 187 |
|
|
mk3comimage $NFSROOT/boot/vmlinuz-$KERNELVERSION /boot/fai/installimage $NFSROOT/dev/nfs |
| 188 |
lange |
2 |
|
| 189 |
lange |
14 |
exit 0 |