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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 284 - (hide annotations) (download)
Tue Dec 12 11:02:50 2000 UTC (12 years, 5 months ago) by lange
File size: 6968 byte(s)
added parted
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 284 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"
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 278 mkdir -p $NFSROOT/$MNTPOINT
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 lange 119
103 lange 203 if [ "$FAI_PACKAGEDIR" ]; then
104     mount -o ro,rsize=8192 $FAI_PACKAGEDIR $NFSROOT/$MNTPOINT || die "Can't mount $FAI_PACKAGEDIR"
105     fi
106    
107 lange 119 # hoaks some packages
108 lange 14 touch etc/fstab etc/raidtab # dump and raidtool2 needs these files
109 lange 217 mkdir -p lib/modules/$KERNELVERSION # dirty trick to hoax lvm
110     touch lib/modules/$KERNELVERSION/modules.dep # dirty trick to hoax lvm
111     mkdir -p $NFSROOT/etc/ssh
112     touch $NFSROOT/etc/ssh/NOSERVER
113 lange 119
114 lange 187 echo "$FAI_SOURCES_LIST" > $NFSROOT/etc/apt/sources.list
115 lange 27 upgrade_nfsroot
116 lange 119 copy_fai_files
117    
118     # set timezone
119     rm -f $NFSROOT/etc/localtime
120 lange 217 cp -d /etc/localtime /etc/timezone $NFSROOT/etc
121 lange 119
122 lange 217 # make little changes to nfsroot, because file systems are
123     # read only for the install clients
124 lange 187 rm -rf etc/mtab var/run
125 lange 119 mv $NFSROOT/etc/init.d/rcS $NFSROOT/etc/init.d/rcS.orig
126     ln -s /proc/mounts $NFSROOT/etc/mtab
127     ln -s /tmp/var/run $NFSROOT/var/run
128 lange 242 ln -sf /tmp/etc/resolv.conf $NFSROOT/etc/resolv.conf
129 lange 119 ln -s /sbin/rcS_fai $NFSROOT/etc/init.d/rcS
130 lange 2
131 lange 217 # turn off logging of loading kernel modules
132 lange 119 rmdir $NFSROOT/var/log/ksymoops/
133     ln -s /dev/null $NFSROOT/var/log/ksymoops
134    
135 lange 217 # definition for loopback device
136 lange 224 cat >$NFSROOT/etc/network/interfaces <<-EOF
137 lange 183 iface lo inet static
138     address 127.0.0.1
139     netmask 255.0.0.0
140 lange 143 EOF
141 lange 217 # if package ssh is installed
142     [ -f /var/lib/dpkg/info/ssh.list ] && setup_ssh
143 lange 130 umount $NFSROOT/dev/pts 2>/dev/null
144 lange 119
145 lange 217 cat >$NFSROOT/etc/rc2.d/S01fai_abort <<-EOF
146 lange 183 #!/bin/sh
147     echo FAI: installation aborted.
148     echo reboot with: faireboot
149     echo or after a logout
150     sh
151     cd /
152     umount -ar
153     reboot -dfi
154 lange 2 EOF
155 lange 217 chmod a+rx $NFSROOT/etc/rc2.d/S01fai_abort
156 lange 2 }
157     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
158 lange 27 upgrade_nfsroot() {
159 lange 2
160 lange 119 echo "Upgrading $NFSROOT"
161     {
162 lange 242 cp /etc/resolv.conf $NFSROOT/etc
163 lange 203 chroot $NFSROOT apt-get update
164     chroot $NFSROOT apt-get check
165 lange 119 chroot $NFSROOT mount -n -t proc proc /proc
166     rm -rf $NFSROOT/etc/pcmcia $NFSROOT/etc/apm
167 lange 203 chroot $NFSROOT apt-get -y remove pcmcia-cs </dev/null
168 lange 57
169 lange 217 # fake start-stop-dameon
170     chroot $NFSROOT dpkg-divert --quiet --package fai --add --rename /sbin/start-stop-daemon
171     cp $LIBFAI/sbin/start-stop-daemon $NFSROOT/sbin
172     chroot $NFSROOT apt-get -y upgrade
173 lange 119 } > $devnull
174     echo "Adding additional packages to $NFSROOT:"
175 lange 69 echo "$packages"
176 lange 119 {
177 lange 203 chroot $NFSROOT apt-get -y --fix-missing install $packages </dev/null
178 lange 119 chroot $NFSROOT umount -n /proc
179     } > $devnull
180 lange 2 }
181     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
182 lange 69 get_basetgz() {
183 lange 2
184 lange 119 [ -f /tmp/base?_?.tgz ] && return
185 lange 274 [ "$FAI_BASETGZ" ] || die "no /tmp/base?_?.tgz found and FAI_BASETGZ not defined."
186     case $FAI_BASETGZ in
187 lange 119 ftp:*|http:*)
188 lange 274 echo "Getting $FAI_BASETGZ via wget. This may take some time."
189 lange 203 TMPBDIR=`mktemp /tmp/FAI-wget-XXXXXX` || exit 1
190     rm $TMPBDIR; mkdir $TMPBDIR || exit
191 lange 274 wget -P$TMPBDIR $FAI_BASETGZ
192 lange 203 mv $TMPBDIR/base?_?.tgz /tmp
193     rm -rf $TMPBDIR
194 lange 119 ;;
195 lange 217 /*/base?_?.tgz)
196 lange 278 rm -f /tmp/base?_?.tgz
197     ln -s $FAI_BASETGZ /tmp
198 lange 119 ;;
199 lange 217 *)
200 lange 274 die "FAI_BASETGZ $FAI_BASETGZ looks strong."
201 lange 217 ;;
202 lange 119 esac
203 lange 69 }
204     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
205 lange 169 # main routine
206    
207 lange 119 if [ -d $NFSROOT/fai ]; then
208     echo $NFSROOT already exists. Removing $NFSROOT
209 lange 203 umount $NFSROOT/dev/pts 1>/dev/null 2>&1
210 lange 129 rm -rf $NFSROOT
211 lange 2 fi
212    
213 lange 203 create_nfsroot
214     test -d $NFSROOT/$MNTPOINT && umount $NFSROOT/$MNTPOINT
215    
216 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