/[fai]/trunk/bin/fai
ViewVC logotype

Contents of /trunk/bin/fai

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3705 - (show annotations) (download)
Mon Jul 31 20:52:00 2006 UTC (6 years, 9 months ago) by lange
File size: 7045 byte(s)
replace $fstab with fstab
1 #!/bin/bash
2 # $Id$
3 #*********************************************************************
4 #
5 # fai -- main installation script executed after booting
6 #
7 # This script is part of FAI (Fully Automatic Installation)
8 # (c) 1999-2006 by Thomas Lange, lange@informatik.uni-koeln.de
9 # Universitaet zu Koeln
10 #
11 #*********************************************************************
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
21 #
22 # A copy of the GNU General Public License is available as
23 # `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
24 # or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
25 # can also obtain it by writing to the Free Software Foundation, Inc.,
26 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #*********************************************************************
28
29 #set -xv # for full debugging
30
31 export PATH=/usr/local/sbin:/usr/local/bin:/usr/lib/fai:/bin:/sbin:/usr/bin:/usr/sbin:
32 # some variables
33 export FAI_VERSION=FAIVERSIONSTRING
34 rundir=/var/run/fai
35 stamp=$rundir/FAI_INSTALLATION_IN_PROGRESS
36 romountopt="-o async,noatime,nolock,ro,actimeo=1800"
37
38 # the type of operating system (linux, sunos)
39 oclass=$(uname -s | tr a-z A-Z)
40 # $classes is now set so we can call hooks before fai-class defines the classes
41 classes="DEFAULT $oclass $HOSTNAME LAST"
42 faimond=0
43 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
44 fai_init() {
45
46 local sub ostype
47 set -a # now export all variables
48
49 umask 022
50 # read fai.conf
51 # linux dir
52 [ -f /etc/fai/fai.conf ] && . /etc/fai/fai.conf
53 # solaris dir
54 [ -f /tmp/install_config/fai/fai.conf ] && . /tmp/install_config/fai/fai.conf
55
56 if [ -f /boot/RUNNING_FROM_FAICD ]; then # we are booting from fai cd
57 umount /initrd
58 romountopt=
59 FAI_DEBMIRROR="--bind /media/mirror"
60 MNTPOINT=/media/mirror
61 FAI_LOCATION=
62 fi
63
64 # some variables from are not needed any more
65 unset FAI_CONFIGDIR
66
67 ostype=$(uname -s | tr A-Z a-z)
68 # read subroutine definitions
69 sub=/usr/lib/fai/subroutines
70 [ -f $sub ] && . $sub
71 [ -f $sub-$ostype ] && . $sub-$ostype
72
73 [ -f "$stamp" ] && {
74 echo "$0 already running, aborting"
75 exit 1
76 }
77
78 DEBIAN_FRONTEND=noninteractive
79 # local disks are mounted to $FAI_ROOT
80 if [ -z "$FAI_ROOT" ] ; then
81 [ $DO_INIT_TASKS -eq 1 ] && FAI_ROOT=/tmp/target || FAI_ROOT=/
82 fi
83 # executed command in the environment of the new system
84 ROOTCMD="chroot $FAI_ROOT"
85 # no chroot needed
86 [ "$FAI_ROOT" = '/' ] && ROOTCMD=
87
88 # several log files
89 diskvar=$LOGDIR/disk_var.sh
90
91 # variables for cfengine
92 target=$FAI_ROOT
93
94 if [ $DO_INIT_TASKS -eq 1 ]; then
95 trap 'echo "Now rebooting";faireboot' INT QUIT ;
96 else
97 trap "echo 'Aborted';rm -f $stamp" INT QUIT ;
98 fi
99
100 # if HOST was specified on the commandline, set hostname to it
101 [ $DO_INIT_TASKS -eq 1 ] && eval_cmdline
102 if [ -n "$HOST" ]; then
103 HOSTNAME=$HOST
104 hostname $HOST
105 echo "Hostname set to $HOST" | tee -a $LOGDIR/fai.log
106 sleep 3
107 fi
108 export HOSTNAME
109
110 if [ X$oclass = XLINUX ]; then
111 if [ $DO_INIT_TASKS -eq 1 ]; then
112 grep -q '[[:space:]]sysfs' /proc/filesystems && mount -t sysfs sysfs /sys
113 ifup lo
114 [ -x /etc/init.d/udev ] && /etc/init.d/udev start
115 [ -x /sbin/portmap ] && /sbin/portmap
116 mount -t devpts devpts /dev/pts
117 # add other options for nfs mount of /dev/root to root-path in dhcpd.conf
118 mount -o remount,noatime,ro /dev/root /
119 cat /proc/kmsg >/dev/tty4 &
120 fi
121 fi
122
123 prcopyleft
124 unset oclass
125
126 save_dmesg
127 }
128 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
129 usage() {
130 cat <<-EOF
131 fai $FAI_VERSION. Copyright (C) 1999-2005 Thomas Lange
132 Usage: $0 [options] [action]
133
134 Options:
135 -v|--verbose display more information during the update
136 -h|--help display this help message
137 -N|--new renew list of classes
138 EOF
139 exit 0
140 }
141 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
142 fstart() {
143
144 # these tasks can define variables, that are needed later
145 task confdir
146 task setup
147 task defclass
148 set_disk_info
149 task defvar
150 [ $DO_INIT_TASKS -eq 1 ] && load_keymap_consolechars
151 }
152 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
153 # Main routine
154
155 export renewclass=0
156 # Parse commandline options
157 TEMP=$(getopt -o Nhv --long new,help,verbose -n "$0" -- "$@")
158 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
159 # Note the quotes around `$TEMP': they are essential!
160 eval set -- "$TEMP"
161
162 while true ; do
163 case "$1" in
164 -h|--help)
165 shift
166 usage
167 ;;
168 -v|--verbose)
169 shift
170 verbose=1
171 ;;
172 -N|--new)
173 shift
174 renewclass=1
175 ;;
176 --)
177 shift
178 break
179 ;;
180 *)
181 echo "$0: command line parsing error ! $@"
182 exit 1
183 ;;
184 esac
185 done
186
187 if [ `id -u` -ne 0 ]; then
188 echo "Run this program as root."
189 exit 1
190 fi
191
192 # exit if we do not run from nfsroot and no parameter is given
193 if [ ! -f /.THIS_IS_THE_FAI_NFSROOT -a "X$1" = "X" ]; then
194 echo "Please give more parameters if not run from the nfsroot."
195 exit 2
196 fi
197
198 # HG: are we called as an init substitute ?
199 export DO_INIT_TASKS=0
200 [ "$0" = "/etc/init.d/rcS" ] && DO_INIT_TASKS=1
201 [ $DO_INIT_TASKS -eq 1 ] && renewclass=1 # always renew class list when installing
202
203 # Solaris has already a writable /tmp directory
204 [ "$oclass" = LINUX -a $DO_INIT_TASKS -eq 1 ] && create_ramdisk
205
206 export LOGDIR=/var/log/fai/current
207 mkdir -p $LOGDIR
208
209 # for compability, can be removed later
210 if [ $DO_INIT_TASKS -eq 1 ]; then
211 mkdir /tmp/fai
212 mount --bind /var/log/fai/current /tmp/fai
213 fi
214
215 fai_init
216
217 mkfifo $LOGDIR/logfifo
218 tee -a $LOGDIR/fai.log < $LOGDIR/logfifo &
219 # in bash &> redirect stdout and stderr to file
220 fstart &> $LOGDIR/logfifo
221 rm $LOGDIR/logfifo
222 sleep 1 # wait for tee to complete. One second should be ok
223
224 # old code
225 # {
226 # # a bash group command with { does not work on sparc
227 # task confdir
228 # task setup
229 # task defclass
230 # task defvar
231 # load_keymap_consolechars
232 # set_disk_info
233 # } > >( tee -a $LOGDIR/fai.log ) 2>&1
234
235 # override FAI_ACTION if a command line argument is given
236 [ "$1" ] && FAI_ACTION=$1
237 [ "$2" ] && targetdir=$2 # only used for dirinst
238
239 task action 2>&1 | tee -a $LOGDIR/fai.log
240
241 # not happy with this at all!
242 [ "$FAI_CVSROOT" ] && rm -rf $FAI
243
244 [ -L "$rundir/current_log" ] && rm -f "$rundir/current_log"
245 [ -L "$rundir/current_config" ] && rm -f "$rundir/current_config"
246
247 echo "End of $0"

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.5