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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 269 - (hide annotations) (download)
Thu Dec 7 12:28:01 2000 UTC (12 years, 5 months ago) by lange
File size: 6954 byte(s)
FAI_BASETGZ not nedded any more
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 lange 217 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
33 lange 2
34 lange 119 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 lange 14 # Additional packages that are install to nfsroot
45 lange 244 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 lange 2
47 lange 14 export DEBIAN_FRONTEND=Noninteractive
48 lange 2
49 lange 14 if [ "$verbose" ]; then
50     devnull=/dev/tty
51     else
52     devnull=/dev/null
53     fi
54 lange 2
55     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56 lange 203 die() {
57    
58     echo $*
59     exit 99
60     }
61     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
62 lange 69 setup_ssh() {
63    
64 lange 119 # 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 lange 130 cp -p $SSH_IDENTITY $NFSROOT/root/.ssh/authorized_keys
69 lange 217 echo You can log into install clients without password using $SSH_IDENTITY
70 lange 119 fi
71 lange 69 }
72     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
73 lange 119 copy_fai_files() {
74 lange 2
75 lange 217 perl -pi -e "s/^root::/root:${FAI_ROOTPW}:/" etc/passwd
76 lange 119 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 lange 240 cp -p /tmp/base?_?.tgz $NFSROOT/var/tmp
84 lange 187 cat > $conffile <<-EOF
85     # rcS_fai.conf -- created by make-fai-nfsroot
86     LOGUSER=$LOGUSER
87     KERNELVERSION=$KERNELVERSION
88     FAI_PACKAGEDIR=$FAI_PACKAGEDIR
89 lange 203 MNTPOINT=$MNTPOINT
90 lange 217 UTC=$UTC
91 lange 187 EOF
92 lange 119 }
93     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
94     create_nfsroot() {
95    
96 lange 129 mkdir -p $NFSROOT
97 lange 217 cd $NFSROOT || die "Error: Can't cd to $NFSROOT"
98 lange 69 get_basetgz
99 lange 119 echo -n "Unpacking " ; ls /tmp/base?_?.tgz
100 lange 217 tar -C $NFSROOT -zxpf /tmp/base?_?.tgz
101 lange 203 mknod $NFSROOT/dev/boot255 c 0 255
102     mkdir -p $NFSROOT/$MNTPOINT
103 lange 119
104 lange 203 if [ "$FAI_PACKAGEDIR" ]; then
105     mount -o ro,rsize=8192 $FAI_PACKAGEDIR $NFSROOT/$MNTPOINT || die "Can't mount $FAI_PACKAGEDIR"
106     fi
107    
108 lange 119 # hoaks some packages
109 lange 14 touch etc/fstab etc/raidtab # dump and raidtool2 needs these files
110 lange 217 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 lange 119
115 lange 187 echo "$FAI_SOURCES_LIST" > $NFSROOT/etc/apt/sources.list
116 lange 27 upgrade_nfsroot
117 lange 119 copy_fai_files
118    
119     # set timezone
120     rm -f $NFSROOT/etc/localtime
121 lange 217 cp -d /etc/localtime /etc/timezone $NFSROOT/etc
122 lange 119
123 lange 217 # make little changes to nfsroot, because file systems are
124     # read only for the install clients
125 lange 187 rm -rf etc/mtab var/run
126 lange 119 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 lange 242 ln -sf /tmp/etc/resolv.conf $NFSROOT/etc/resolv.conf
130 lange 119 ln -s /sbin/rcS_fai $NFSROOT/etc/init.d/rcS
131 lange 2
132 lange 217 # turn off logging of loading kernel modules
133 lange 119 rmdir $NFSROOT/var/log/ksymoops/
134     ln -s /dev/null $NFSROOT/var/log/ksymoops
135    
136 lange 217 # definition for loopback device
137 lange 224 cat >$NFSROOT/etc/network/interfaces <<-EOF
138 lange 183 iface lo inet static
139     address 127.0.0.1
140     netmask 255.0.0.0
141 lange 143 EOF
142 lange 217 # if package ssh is installed
143     [ -f /var/lib/dpkg/info/ssh.list ] && setup_ssh
144 lange 130 umount $NFSROOT/dev/pts 2>/dev/null
145 lange 119
146 lange 217 cat >$NFSROOT/etc/rc2.d/S01fai_abort <<-EOF
147 lange 183 #!/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 lange 2 EOF
156 lange 217 chmod a+rx $NFSROOT/etc/rc2.d/S01fai_abort
157 lange 2 }
158     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
159 lange 27 upgrade_nfsroot() {
160 lange 2
161 lange 119 echo "Upgrading $NFSROOT"
162     {
163 lange 242 cp /etc/resolv.conf $NFSROOT/etc
164 lange 203 chroot $NFSROOT apt-get update
165     chroot $NFSROOT apt-get check
166 lange 119 chroot $NFSROOT mount -n -t proc proc /proc
167     rm -rf $NFSROOT/etc/pcmcia $NFSROOT/etc/apm
168 lange 203 chroot $NFSROOT apt-get -y remove pcmcia-cs </dev/null
169 lange 57
170 lange 217 # 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 lange 119 } > $devnull
175     echo "Adding additional packages to $NFSROOT:"
176 lange 69 echo "$packages"
177 lange 119 {
178 lange 203 chroot $NFSROOT apt-get -y --fix-missing install $packages </dev/null
179 lange 119 chroot $NFSROOT umount -n /proc
180     } > $devnull
181 lange 2 }
182     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
183 lange 69 get_basetgz() {
184 lange 2
185 lange 119 [ -f /tmp/base?_?.tgz ] && return
186 lange 203 [ "$BASETGZ" ] || die "no /tmp/base?_?.tgz found and BASETGZ not defined."
187 lange 119 case $BASETGZ in
188     ftp:*|http:*)
189     echo "Getting $BASETGZ via wget. This may take some time."
190 lange 203 TMPBDIR=`mktemp /tmp/FAI-wget-XXXXXX` || exit 1
191     rm $TMPBDIR; mkdir $TMPBDIR || exit
192 lange 217 wget -P$TMPBDIR $BASETGZ
193 lange 203 mv $TMPBDIR/base?_?.tgz /tmp
194     rm -rf $TMPBDIR
195 lange 119 ;;
196 lange 217 /*/base?_?.tgz)
197 lange 203 cd /tmp
198     rm -f base?_?.tgz
199     ln -s $BASETGZ
200 lange 119 ;;
201 lange 217 *)
202     die "BASETGZ $BASETGZ seems strong."
203     ;;
204 lange 119 esac
205 lange 69 }
206     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
207 lange 169 # main routine
208    
209 lange 119 if [ -d $NFSROOT/fai ]; then
210     echo $NFSROOT already exists. Removing $NFSROOT
211 lange 203 umount $NFSROOT/dev/pts 1>/dev/null 2>&1
212 lange 129 rm -rf $NFSROOT
213 lange 2 fi
214    
215 lange 203 create_nfsroot
216     test -d $NFSROOT/$MNTPOINT && umount $NFSROOT/$MNTPOINT
217    
218 lange 14 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