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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 368 - (show annotations) (download)
Mon Mar 5 21:55:09 2001 UTC (12 years, 2 months ago) by lange
File size: 7129 byte(s)
copyright 2001
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-2001 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 set -e
41 . /etc/fai.conf
42
43 conffile=$NFSROOT/etc/rcS_fai.conf
44
45 # Additional packages that are install to nfsroot
46 packages="$NFSROOT_PACKAGES perl-5.005 dhcp-client file rdate cfengine bootpc wget rsh-client less dump ext2resize raidtools2 lvm strace expect5.31 hdparm parted"
47
48 export DEBIAN_FRONTEND=Noninteractive
49
50 if [ "$verbose" ]; then
51 devnull=/dev/tty
52 else
53 devnull=/dev/null
54 fi
55
56 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
57 die() {
58
59 echo $*
60 exit 99
61 }
62 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63 setup_ssh() {
64
65 # enable root login
66 perl -pi -e 's/PermitRootLogin no/PermitRootLogin yes/' $NFSROOT/etc/ssh/sshd_config
67 if [ -f "$SSH_IDENTITY" ]; then
68 mkdir -p -m 700 $NFSROOT/root/.ssh
69 cp -p $SSH_IDENTITY $NFSROOT/root/.ssh/authorized_keys
70 echo You can log into install clients without password using $SSH_IDENTITY
71 fi
72 }
73 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
74 copy_fai_files() {
75
76 perl -pi -e "s/^root::/root:${FAI_ROOTPW}:/" etc/passwd
77 mkdir -p $NFSROOT/fai/fai_config $NFSROOT/usr/share/fai
78 cp -p $LIBFAI/sbin/dhclient-script $LIBFAI/etc/dhclient.conf $NFSROOT/etc
79 cp -p $LIBFAI/sbin/* $NFSROOT/sbin
80 cp -p /usr/share/fai/* $NFSROOT/usr/share/fai
81 cp -p $LIBFAI/etc/apt.conf $NFSROOT/etc/apt
82 cp -p /usr/lib/perl5/Debian/Fai.pm $NFSROOT/usr/lib/perl5/Debian/
83 cp -p /etc/fai.conf $NFSROOT/etc
84 cp -p /tmp/base?_?.tgz $NFSROOT/var/tmp
85 cat > $conffile <<-EOF
86 # rcS_fai.conf -- created by make-fai-nfsroot
87 LOGUSER=$LOGUSER
88 KERNELVERSION=$KERNELVERSION
89 FAI_PACKAGEDIR=$FAI_PACKAGEDIR
90 MNTPOINT=$MNTPOINT
91 UTC=$UTC
92 EOF
93 }
94 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
95 create_nfsroot() {
96
97 mkdir -p $NFSROOT
98 cd $NFSROOT || die "Error: Can't cd to $NFSROOT"
99 get_basetgz
100 echo -n "Unpacking " ; ls /tmp/base?_?.tgz
101 tar -C $NFSROOT -zxpf /tmp/base?_?.tgz
102 mknod $NFSROOT/dev/boot255 c 0 255
103
104 if [ "$FAI_PACKAGEDIR" ]; then
105 mkdir -p $NFSROOT/$MNTPOINT
106 mount -o ro,rsize=8192 $FAI_PACKAGEDIR $NFSROOT/$MNTPOINT || die "Can't mount $FAI_PACKAGEDIR"
107 fi
108
109 # hoaks some packages
110 touch etc/fstab etc/raidtab # dump and raidtool2 needs these files
111 mkdir -p lib/modules/$KERNELVERSION # dirty trick to hoax lvm
112 touch lib/modules/$KERNELVERSION/modules.dep # dirty trick to hoax lvm
113 mkdir -p $NFSROOT/etc/ssh
114 touch $NFSROOT/etc/ssh/NOSERVER
115
116 echo "$FAI_SOURCES_LIST" > $NFSROOT/etc/apt/sources.list
117 upgrade_nfsroot
118 copy_fai_files
119
120 # set timezone
121 rm -f $NFSROOT/etc/localtime
122 cp -d /etc/localtime /etc/timezone $NFSROOT/etc
123
124 # make little changes to nfsroot, because file systems are
125 # read only for the install clients
126 rm -rf etc/mtab var/run
127 mv $NFSROOT/etc/init.d/rcS $NFSROOT/etc/init.d/rcS.orig
128 ln -s /proc/mounts $NFSROOT/etc/mtab
129 ln -s /tmp/var/run $NFSROOT/var/run
130 ln -sf /tmp/etc/resolv.conf $NFSROOT/etc/resolv.conf
131 ln -s /sbin/rcS_fai $NFSROOT/etc/init.d/rcS
132
133 # turn off logging of loading kernel modules
134 rmdir $NFSROOT/var/log/ksymoops/
135 ln -s /dev/null $NFSROOT/var/log/ksymoops
136
137 # definition for loopback device
138 echo "iface lo inet loopback" >$NFSROOT/etc/network/interfaces
139
140 echo "*.* /tmp/syslog.log" >$NFSROOT/etc/syslog.conf
141
142 # if package ssh is installed
143 [ -f /var/lib/dpkg/info/ssh.list ] && setup_ssh
144 umount $NFSROOT/dev/pts 2>/dev/null || true
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 apt-get clean
180 chroot $NFSROOT umount -n /proc
181 } > $devnull
182 }
183 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
184 get_basetgz() {
185
186 [ -f /tmp/base?_?.tgz ] && return
187 [ "$FAI_BASETGZ" ] || die "no /tmp/base?_?.tgz found and FAI_BASETGZ not defined."
188 case $FAI_BASETGZ in
189 ftp:*|http:*)
190 echo "Getting $FAI_BASETGZ via wget. This may take some time."
191 TMPBDIR=`mktemp /tmp/FAI-wget-XXXXXX` || exit 1
192 rm $TMPBDIR; mkdir $TMPBDIR || exit
193 wget -P$TMPBDIR $FAI_BASETGZ
194 mv $TMPBDIR/base?_?.tgz /tmp
195 rm -rf $TMPBDIR
196 ;;
197 /*/base?_?.tgz)
198 rm -f /tmp/base?_?.tgz
199 ln -s $FAI_BASETGZ /tmp
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 || true
212 rm -rf $NFSROOT
213 fi
214
215 create_nfsroot
216
217 # TODO: only umount if created (debian mirror via NFS)
218 test -d $NFSROOT/$MNTPOINT && umount $NFSROOT/$MNTPOINT || true
219
220 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