/[fai]/trunk/scripts/make-fai-nfsroot
ViewVC logotype

Contents of /trunk/scripts/make-fai-nfsroot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 277 - (show annotations) (download)
Thu Dec 7 13:11:16 2000 UTC (12 years, 5 months ago) by lange
File size: 6986 byte(s)
FAI_BASETGZ now abolute path
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 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
33
34 while getopts v opt ; do
35 case "$opt" in
36 v) verbose=1 ;;
37 esac
38 done
39
40 . /etc/fai.conf
41
42 conffile=$NFSROOT/etc/rcS_fai.conf
43
44 # Additional packages that are install to nfsroot
45 packages="$NFSROOT_PACKAGES perl-5.005 dhcp-client file rdate cfengine bootpc wget rsh-client less dump ext2resize raidtools2 lvm strace expect5.31 hdparm"
46
47 export DEBIAN_FRONTEND=Noninteractive
48
49 if [ "$verbose" ]; then
50 devnull=/dev/tty
51 else
52 devnull=/dev/null
53 fi
54
55 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56 die() {
57
58 echo $*
59 exit 99
60 }
61 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
62 setup_ssh() {
63
64 # enable root login
65 perl -pi -e 's/PermitRootLogin no/PermitRootLogin yes/' $NFSROOT/etc/ssh/sshd_config
66 if [ -f "$SSH_IDENTITY" ]; then
67 mkdir -p -m 700 $NFSROOT/root/.ssh
68 cp -p $SSH_IDENTITY $NFSROOT/root/.ssh/authorized_keys
69 echo You can log into install clients without password using $SSH_IDENTITY
70 fi
71 }
72 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
73 copy_fai_files() {
74
75 perl -pi -e "s/^root::/root:${FAI_ROOTPW}:/" etc/passwd
76 mkdir -p $NFSROOT/fai/fai_config $NFSROOT/usr/share/fai
77 cp -p $LIBFAI/sbin/dhclient-script $LIBFAI/etc/dhclient.conf $NFSROOT/etc
78 cp -p $LIBFAI/sbin/* $NFSROOT/sbin
79 cp -p /usr/share/fai/* $NFSROOT/usr/share/fai
80 cp -p $LIBFAI/etc/apt.conf $NFSROOT/etc/apt
81 cp -p /usr/lib/perl5/Debian/Fai.pm $NFSROOT/usr/lib/perl5/Debian/
82 cp -p /etc/fai.conf $NFSROOT/etc
83 cp -p /tmp/base?_?.tgz $NFSROOT/var/tmp
84 cat > $conffile <<-EOF
85 # rcS_fai.conf -- created by make-fai-nfsroot
86 LOGUSER=$LOGUSER
87 KERNELVERSION=$KERNELVERSION
88 FAI_PACKAGEDIR=$FAI_PACKAGEDIR
89 MNTPOINT=$MNTPOINT
90 UTC=$UTC
91 EOF
92 }
93 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
94 create_nfsroot() {
95
96 mkdir -p $NFSROOT
97 cd $NFSROOT || die "Error: Can't cd to $NFSROOT"
98 get_basetgz
99 echo -n "Unpacking " ; ls /tmp/base?_?.tgz
100 tar -C $NFSROOT -zxpf /tmp/base?_?.tgz
101 mknod $NFSROOT/dev/boot255 c 0 255
102 mkdir -p $NFSROOT/$MNTPOINT
103
104 if [ "$FAI_PACKAGEDIR" ]; then
105 mount -o ro,rsize=8192 $FAI_PACKAGEDIR $NFSROOT/$MNTPOINT || die "Can't mount $FAI_PACKAGEDIR"
106 fi
107
108 # hoaks some packages
109 touch etc/fstab etc/raidtab # dump and raidtool2 needs these files
110 mkdir -p lib/modules/$KERNELVERSION # dirty trick to hoax lvm
111 touch lib/modules/$KERNELVERSION/modules.dep # dirty trick to hoax lvm
112 mkdir -p $NFSROOT/etc/ssh
113 touch $NFSROOT/etc/ssh/NOSERVER
114
115 echo "$FAI_SOURCES_LIST" > $NFSROOT/etc/apt/sources.list
116 upgrade_nfsroot
117 copy_fai_files
118
119 # set timezone
120 rm -f $NFSROOT/etc/localtime
121 cp -d /etc/localtime /etc/timezone $NFSROOT/etc
122
123 # make little changes to nfsroot, because file systems are
124 # read only for the install clients
125 rm -rf etc/mtab var/run
126 mv $NFSROOT/etc/init.d/rcS $NFSROOT/etc/init.d/rcS.orig
127 ln -s /proc/mounts $NFSROOT/etc/mtab
128 ln -s /tmp/var/run $NFSROOT/var/run
129 ln -sf /tmp/etc/resolv.conf $NFSROOT/etc/resolv.conf
130 ln -s /sbin/rcS_fai $NFSROOT/etc/init.d/rcS
131
132 # turn off logging of loading kernel modules
133 rmdir $NFSROOT/var/log/ksymoops/
134 ln -s /dev/null $NFSROOT/var/log/ksymoops
135
136 # definition for loopback device
137 cat >$NFSROOT/etc/network/interfaces <<-EOF
138 iface lo inet static
139 address 127.0.0.1
140 netmask 255.0.0.0
141 EOF
142 # if package ssh is installed
143 [ -f /var/lib/dpkg/info/ssh.list ] && setup_ssh
144 umount $NFSROOT/dev/pts 2>/dev/null
145
146 cat >$NFSROOT/etc/rc2.d/S01fai_abort <<-EOF
147 #!/bin/sh
148 echo FAI: installation aborted.
149 echo reboot with: faireboot
150 echo or after a logout
151 sh
152 cd /
153 umount -ar
154 reboot -dfi
155 EOF
156 chmod a+rx $NFSROOT/etc/rc2.d/S01fai_abort
157 }
158 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
159 upgrade_nfsroot() {
160
161 echo "Upgrading $NFSROOT"
162 {
163 cp /etc/resolv.conf $NFSROOT/etc
164 chroot $NFSROOT apt-get update
165 chroot $NFSROOT apt-get check
166 chroot $NFSROOT mount -n -t proc proc /proc
167 rm -rf $NFSROOT/etc/pcmcia $NFSROOT/etc/apm
168 chroot $NFSROOT apt-get -y remove pcmcia-cs </dev/null
169
170 # fake start-stop-dameon
171 chroot $NFSROOT dpkg-divert --quiet --package fai --add --rename /sbin/start-stop-daemon
172 cp $LIBFAI/sbin/start-stop-daemon $NFSROOT/sbin
173 chroot $NFSROOT apt-get -y upgrade
174 } > $devnull
175 echo "Adding additional packages to $NFSROOT:"
176 echo "$packages"
177 {
178 chroot $NFSROOT apt-get -y --fix-missing install $packages </dev/null
179 chroot $NFSROOT umount -n /proc
180 } > $devnull
181 }
182 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
183 get_basetgz() {
184
185 [ -f /tmp/base?_?.tgz ] && return
186 [ "$FAI_BASETGZ" ] || die "no /tmp/base?_?.tgz found and FAI_BASETGZ not defined."
187 case $FAI_BASETGZ in
188 ftp:*|http:*)
189 echo "Getting $FAI_BASETGZ via wget. This may take some time."
190 TMPBDIR=`mktemp /tmp/FAI-wget-XXXXXX` || exit 1
191 rm $TMPBDIR; mkdir $TMPBDIR || exit
192 wget -P$TMPBDIR $FAI_BASETGZ
193 mv $TMPBDIR/base?_?.tgz /tmp
194 rm -rf $TMPBDIR
195 ;;
196 /*/base?_?.tgz)
197 cd /tmp
198 rm -f base?_?.tgz
199 ln -s $FAI_BASETGZ
200 ;;
201 *)
202 die "FAI_BASETGZ $FAI_BASETGZ looks strong."
203 ;;
204 esac
205 }
206 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
207 # main routine
208
209 if [ -d $NFSROOT/fai ]; then
210 echo $NFSROOT already exists. Removing $NFSROOT
211 umount $NFSROOT/dev/pts 1>/dev/null 2>&1
212 rm -rf $NFSROOT
213 fi
214
215 create_nfsroot
216 test -d $NFSROOT/$MNTPOINT && umount $NFSROOT/$MNTPOINT
217
218 exit 0

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.5