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

Contents of /trunk/bin/fai

Parent Directory Parent Directory | Revision Log Revision Log


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