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

Contents of /trunk/bin/fai

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3418 - (hide annotations) (download)
Tue Apr 18 13:37:56 2006 UTC (7 years, 1 month ago) by lange
File size: 7076 byte(s)
use /var/log/fai/current-log as default LOGDIR,
/tmp/fai is currently a mount --bind to it
1 lange 2661 #!/bin/bash
2     # $Id$
3     #*********************************************************************
4     #
5 lange 2732 # fai -- main installation script executed after booting
6 lange 2661 #
7     # This script is part of FAI (Fully Automatic Installation)
8 lange 3304 # (c) 1999-2006 by Thomas Lange, lange@informatik.uni-koeln.de
9 lange 2661 # 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 lange 2674 rundir=/var/run/fai
35     stamp=$rundir/FAI_INSTALLATION_IN_PROGRESS
36 lange 2661 romountopt="-o async,noatime,nolock,ro,actimeo=1800"
37     fstab=fstab # Solaris uses vfstab
38    
39     # the type of operating system (linux, sunos)
40 lange 3096 oclass=$(uname -s | tr a-z A-Z)
41 lange 2661 # $classes is now set so we can call hooks before fai-class defines the classes
42     classes="DEFAULT $oclass $HOSTNAME LAST"
43     faimond=0
44     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
45     fai_init() {
46    
47 lange 3409 local sub ostype
48 lange 2661 set -a # now export all variables
49    
50     umask 022
51     # read fai.conf
52     # linux dir
53     [ -f /etc/fai/fai.conf ] && . /etc/fai/fai.conf
54     # solaris dir
55     [ -f /tmp/install_config/fai/fai.conf ] && . /tmp/install_config/fai/fai.conf
56    
57     if [ -f /boot/RUNNING_FROM_FAICD ]; then # we are booting from fai cd
58     umount /initrd
59     romountopt=
60     FAI_DEBMIRROR="--bind /media/mirror"
61     MNTPOINT=/media/mirror
62     FAI_LOCATION=
63     fi
64    
65     # some variables from are not needed any more
66 lange 3381 unset FAI_CONFIGDIR installserver
67 lange 2661
68 lange 3378 ostype=$(uname -s | tr A-Z a-z)
69 lange 2661 # read subroutine definitions
70 lange 2936 sub=/usr/lib/fai/subroutines
71 lange 2661 [ -f $sub ] && . $sub
72 lange 3379 [ -f $sub-$ostype ] && . $sub-$ostype
73 lange 2661
74     [ -f "$stamp" ] && {
75     echo "$0 already running, aborting"
76     exit 1
77     }
78    
79     DEBIAN_FRONTEND=noninteractive
80     # local disks are mounted to $FAI_ROOT
81     if [ -z "$FAI_ROOT" ] ; then
82 lange 2761 [ $DO_INIT_TASKS -eq 1 ] && FAI_ROOT=/tmp/target || FAI_ROOT=/
83 lange 2661 fi
84     # executed command in the environment of the new system
85     ROOTCMD="chroot $FAI_ROOT"
86     # no chroot needed
87     [ "$FAI_ROOT" = '/' ] && ROOTCMD=
88    
89     # several log files
90     diskvar=$LOGDIR/disk_var.sh
91 lange 2732 rcslog=$LOGDIR/fai.log
92 lange 2661
93     # variables for cfengine
94     files=$FAI/files
95     target=$FAI_ROOT
96    
97 lange 2761 if [ $DO_INIT_TASKS -eq 1 ]; then
98 lange 2661 trap 'echo "Now rebooting";faireboot' INT QUIT ;
99     else
100     trap "echo 'Aborted';rm -f $stamp" INT QUIT ;
101     fi
102    
103     # if HOST was specified on the commandline, set hostname to it
104 lange 3381 [ $DO_INIT_TASKS -eq 1 ] && eval_cmdline
105 lange 2661 if [ -n "$HOST" ]; then
106     HOSTNAME=$HOST
107     hostname $HOST
108     echo "Hostname set to $HOST" | tee -a $rcslog
109     sleep 3
110     fi
111 lange 2805 export HOSTNAME
112 lange 2661
113 lange 3378 if [ X$oclass = XLINUX ]; then
114 lange 2761 if [ $DO_INIT_TASKS -eq 1 ]; then
115 lange 2661 grep -q '[[:space:]]sysfs' /proc/filesystems && mount -t sysfs sysfs /sys
116     ifup lo
117 lange 3129 [ -x /etc/init.d/udev ] && /etc/init.d/udev start
118 lange 2661 [ -x /sbin/portmap ] && /sbin/portmap
119     mount -t devpts devpts /dev/pts
120     # add other options for nfs mount of /dev/root to root-path in dhcpd.conf
121 lange 3143 mount -o remount,noatime,ro /dev/root /
122 lange 2661 cat /proc/kmsg >/dev/tty4 &
123     fi
124     fi
125 lange 3409
126     prcopyleft
127 lange 3376 unset oclass
128 lange 2661
129     save_dmesg
130     }
131     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
132     usage() {
133 lange 2732 cat <<-EOF
134     fai $FAI_VERSION. Copyright (C) 1999-2005 Thomas Lange
135     Usage: $0 [options] [action]
136 lange 2661
137 lange 2732 Options:
138     -v|--verbose display more information during the update
139     -h|--help display this help message
140 lange 2761 -N|--new renew list of classes
141 lange 2661 EOF
142     exit 0
143     }
144     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
145     fstart() {
146    
147     # these tasks can define variables, that are needed later
148     task confdir
149     task setup
150     task defclass
151 lange 2674 set_disk_info
152 lange 2661 task defvar
153 lange 2761 [ $DO_INIT_TASKS -eq 1 ] && load_keymap_consolechars
154 lange 2661 }
155     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
156     # Main routine
157    
158 lange 2770 export renewclass=0
159 lange 2661 # Parse commandline options
160 lange 2761 TEMP=$(getopt -o Nhv --long new,help,verbose -n "$0" -- "$@")
161 lange 2661 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
162     # Note the quotes around `$TEMP': they are essential!
163     eval set -- "$TEMP"
164    
165     while true ; do
166     case "$1" in
167     -h|--help)
168     shift
169     usage
170     ;;
171     -v|--verbose)
172     shift
173     verbose=1
174     ;;
175 lange 2761 -N|--new)
176     shift
177 lange 2770 renewclass=1
178 lange 2761 ;;
179 lange 2661 --)
180     shift
181     break
182     ;;
183     *)
184     echo "$0: command line parsing error ! $@"
185     exit 1
186     ;;
187     esac
188     done
189    
190 lange 3151 if [ `id -u` -ne 0 ]; then
191     echo "Run this program as root."
192     exit 1
193     fi
194    
195 lange 3291 # exit if we do not run from nfsroot and no parameter is given
196 lange 3304 if [ ! -f /.THIS_IS_THE_FAI_NFSROOT -a "X$1" = "X" ]; then
197 lange 3291 echo "Please give more parameters if not run from the nfsroot."
198     exit 2
199     fi
200    
201 lange 3410 # HG: are we called as an init substitute ?
202     export DO_INIT_TASKS=0
203     [ "$0" = "/etc/init.d/rcS" ] && DO_INIT_TASKS=1
204     [ $DO_INIT_TASKS -eq 1 ] && renewclass=1 # always renew class list when installing
205    
206     # Solaris has already a writable /tmp directory
207     [ "$oclass" = LINUX -a $DO_INIT_TASKS -eq 1 ] && create_ramdisk
208    
209 lange 3418 export LOGDIR=/var/log/fai/current-log
210     mkdir -p $LOGDIR
211     # for compability, can be removed later
212     mkdir /tmp/fai
213     mount --bind /var/log/fai/current-log /tmp/fai
214 lange 3410
215 lange 2661 fai_init
216    
217     lpipe=$LOGDIR/logfifo
218     mkfifo $lpipe
219     tee -a $rcslog < $lpipe &
220     # in bash &> redirect stdout and stderr to file
221     fstart &> $lpipe
222     rm $lpipe
223     unset lpipe
224     sleep 1 # wait for tee to complete. One second should be ok
225    
226     # old code
227     # {
228     # # a bash group command with { does not work on sparc
229     # task confdir
230     # task setup
231     # task defclass
232     # task defvar
233     # load_keymap_consolechars
234     # set_disk_info
235     # } > >( tee -a $rcslog ) 2>&1
236    
237     # override FAI_ACTION if a command line argument is given
238     [ "$1" ] && FAI_ACTION=$1
239 lange 3378 [ "$2" ] && targetdir=$2 # only used for dirinst
240 lange 2661
241     task action 2>&1 | tee -a $rcslog
242    
243 lange 3378 # not happy with this at all!
244 lange 2674 [ "$FAI_CVSROOT" ] && rm -rf $FAI
245    
246     [ -L "$rundir/current_log" ] && rm -f "$rundir/current_log"
247     [ -L "$rundir/current_config" ] && rm -f "$rundir/current_config"
248    
249 lange 2661 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