/[fai]/trunk/share/subroutines-linux
ViewVC logotype

Contents of /trunk/share/subroutines-linux

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1821 - (hide annotations) (download)
Tue May 27 12:03:15 2003 UTC (9 years, 11 months ago) by lange
File size: 4859 byte(s)
enhance task_chboot() to  support fai-chboot if DHCP environment was used
1 lange 1370 #! /bin/sh
2    
3 lange 1300 # $Id$
4     #
5     # subroutine definitions for linux
6     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7 lange 1641 set_disk_info() {
8 lange 1300
9     # the variable holds a space separated list of devices and their block size
10 lange 1641 device_size=$(disk-info)
11 lange 1300
12     # a list of all local disks, without size
13 lange 1641 disklist=$(list_disks $device_size)
14 lange 1300 }
15     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16     jobsrunning() {
17    
18     # test if jobs are running
19     ps r | egrep -qv "ps r|TIME COMMAND"
20     }
21     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
22     eval_cmdline() {
23    
24     # parse kernel parameters and define variables
25     local word
26    
27 lange 1733 echo -n "Kernel parameters: "; cat /proc/cmdline
28 lange 1789 for word in $(cat /proc/cmdline) ; do
29 lange 1300 case $word in
30     [a-zA-Z]*=*)
31     echo "Defining variable: $word"
32     eval $word
33     ;;
34     esac
35     done
36     }
37     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38     task_confdir() {
39    
40 lange 1641 local bootlog
41 lange 1300 eval_cmdline
42    
43 lange 1478 bootlog=$LOGDIR/boot.log
44     get-boot-info
45 lange 1625 echo "Reading $bootlog"
46     . $bootlog
47 lange 1630 unset T170 T171 T172 ROOT_PATH BOOTFILE
48 lange 1328
49     # define flags to see if syslogd should be started
50     # this routine is called again, so you can use a hook to redefine flags
51     echo 6 > /proc/sys/kernel/printk
52     define_fai_flags
53     [ "$syslogd" ] && {
54     klogd -c7 -f $LOGDIR/kernel.log
55     syslogd -m 0 -p /tmp/etc/syslogsocket
56     }
57    
58 lange 1300 echo "SERVER=$SERVER" >> $rcsfaivar
59     create_resolv_conf
60     get_fai_dir
61     }
62     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
63     task_partition() {
64    
65     echo "Partitioning local harddisks"
66     [ ! -s $diskvar ] && setup_harddisks -d -X > $LOGDIR/format.log 2>&1
67     # setup_harddisks must create $diskvar file
68     if [ ! -s $diskvar ]; then
69     cat $LOGDIR/format.log
70 lange 1321 die "setup_harddisks did not create $diskvar file."
71 lange 1300 fi
72     # now define variable for root and boot partition and boot device
73     . $diskvar
74     }
75     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76     task_extrbase() {
77    
78 lange 1585 local fs=$FAI_ROOT/etc/$fstab
79 lange 1300 # extract the tar file which was the result of debootstrap
80     echo "Unpacking Debian base archive"
81     gzip -dc /var/tmp/base.tgz | tar -C $FAI_ROOT -xpf -
82     # now we can copy fstab
83 lange 1585 [ -f $fs ] && mv $fs $fs.old
84     cp -p $LOGDIR/$fstab $fs
85 lange 1300 }
86     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
87     task_mirror() {
88    
89     # mount debian mirror directory
90     [ "$FAI_DEBMIRROR" ] || return # nothing to do
91     mkdir -p $FAI_ROOT/$MNTPOINT
92     mount $romountopt $FAI_DEBMIRROR $FAI_ROOT/$MNTPOINT ||
93     die "Can't mount $FAI_DEBMIRROR"
94     }
95     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
96     task_updatebase() {
97    
98     # maybe the base system is not up to date
99     echo "Updating base"
100 lange 1508 # try to mount the config space, since it can also contain Debian Packages
101     # in /fai/files/packages
102     mount --bind $FAI $FAI_ROOT/fai
103 lange 1300 if [ "$debug" ]; then
104     prepare_apt | tee -a $LOGDIR/updatebase.log 2>&1
105     else
106     prepare_apt > $LOGDIR/updatebase.log 2>&1
107     fi
108     }
109     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
110     task_instsoft() {
111    
112     echo "Installing software may take a while"
113     if [ "$debug" ]; then
114     install_packages | tee -a $LOGDIR/software.log
115     elif [ "$verbose" ]; then
116     yes '' | install_packages 2>&1 | tee -a $LOGDIR/software.log
117     else
118     yes '' | install_packages >> $LOGDIR/software.log 2>&1
119     fi
120     }
121     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
122     task_finish() {
123    
124     # umount swap space
125 lange 1785 ifconfig
126 lange 1515 local sd
127 lange 1300 for sd in $SWAPLIST; do
128 lange 1515 swapoff $sd && [ "$verbose" ] && echo "Disable swap device $sd"
129 lange 1300 done
130     umount -n $FAI_ROOT/proc
131     # undo fake of all programs made by fai
132 lange 1365 fai-divert -R
133 lange 1300 }
134     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
135     task_chboot() {
136    
137 lange 1821 local frsh
138     frsh="$FAI_REMOTESH -l $LOGUSER ${SERVER}"
139    
140     if [ -z "$LOGUSER" ] ; then
141     echo "LOGUSER not defined. Can't change network boot configuration"
142     exit
143     fi
144    
145     if dmesg | grep -q "Sending BOOTP requests"; then
146     # change boot device (local disk or network) when using bootp
147     [ "$LOGUSER" -a "$TFTPLINK" ] &&
148     $frsh "cd /boot/fai; rm -f $HOSTNAME; ln -s $TFTPLINK $HOSTNAME"
149     else
150     # change boot device (local disk or network) when using DHCP
151     # first test if a given filename exists on the server
152     testcmd="test -s /boot/fai/$HOSTNAME-localboot ; echo \$?"
153     ret=`$FAI_REMOTESH -l $LOGUSER ${SERVER} "$testcmd"`
154     if [ "$ret" -ne 0 ]; then
155     # copy the kernel to the server
156     $FAI_REMOTECP $target/boot/vmlinuz-* $LOGUSER@${SERVER}:/boot/fai/$HOSTNAME-localboot
157     fi
158     . $diskvar # read ROOT_PARTITION
159     $frsh fai-chboot -v $HOSTNAME-localboot $ROOT_PARTITION $HOSTNAME
160     fi
161 lange 1300 }
162     # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.5