Subversion Repositories livecd

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 beyerle@PS 1
#!/bin/bash
2
#
3
# Fix things during bootup - run first 
4
# Executed at the very end of /etc/rc.d/rc.sysinit
5
#
6
# Urs Beyerle, PSI
7
#
8
 
9
### -----------------------------------------------------------
10
### definitions
11
### -----------------------------------------------------------
12
 
13
# dir of mounted /$MOUNTDIR/live
14
MOUNTDIR=livecd
15
 
16
# source functions
17
. /$MOUNTDIR/live/liblinuxlive
18
. /etc/init.d/functions
19
 
20
 
21
### -----------------------------------------------------------
22
### Get boot parameters
23
### -----------------------------------------------------------
24
 
25
# start afs?
26
AFS=$( cmdline_parameter afs )
27
CELL=$( cmdline_value cell )
28
 
29
# or force no afs
30
[ $( cmdline_parameter noafs ) ] && AFS=""
31
 
32
# start ssh server?
33
SSH=$( cmdline_parameter ssh )
34
 
35
# root on NFS?
36
NFSROOT=$( cmdline_value nfsroot )
37
 
38
# PSI setup?
39
PSI=$( cmdline_parameter psi )
40
 
41
# do not start network
42
NONET=$( cmdline_parameter nonet )
43
 
44
# Are PXE/TFTP and NFS Server the same host ? not uesed any more
45
ONEMASTER=$( cmdline_parameter onemaster )
46
 
47
# static IP
48
IPADDR=$( cmdline_value ip )
49
 
50
# gateway
51
GATEWAY=$( cmdline_value gw )
52
 
53
# netmask
54
NETMASK=$( cmdline_value netmask )
55
 
56
# fast booting ?
57
FASTBOOT=$( cmdline_parameter fastboot )
58
 
59
# if run=rdesktop, we do fast boot
60
if [ "$( cmdline_value run )" = "rdesktop" ]; then
61
    FASTBOOT="fastboot"
62
fi
63
 
64
# start ntpd ?
65
NTPD=$( cmdline_parameter ntpd )
66
 
67
# services on/off
68
SERVICEON=$( cmdline_value serviceon )
69
SERVICEOFF=$( cmdline_value serviceoff )
70
 
71
 
72
### -----------------------------------------------------------
73
### Main
74
### -----------------------------------------------------------
75
 
76
### disable rpcidmapd, if LiveCD mounted over NFS
77
if [ $NFSROOT ]; then
78
    chkconfig rpcidmapd off
79
fi
80
 
81
### restore blacklist (modified in runveryfirst)
82
if [ $NFSROOT ]; then
9 beyerle@PS 83
    cp /etc/hotplug/blacklist /etc/hotplug/blacklist.runveryfirst
84
    cp -fa /etc/hotplug/blacklist.backup /etc/hotplug/blacklist
1 beyerle@PS 85
fi
86
 
87
### get resolv.conf
88
# if we have the LiveCD mounted over NFS
89
if [ $NFSROOT ]; then
90
    cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
91
fi
92
 
93
### disable shutdown of network and nfs, 
94
# if we have the LiveCD mounted over NFS
95
if [ $NFSROOT ]; then
96
    if [ $ONEMASTER ]; then
97
        # "network off" is only necessary, 
98
        # if PXE/TFTP and NTS server is on same machine
99
	chkconfig network off
100
    fi
101
 
102
    rm -f /etc/rc.d/rc6.d/K75netfs
103
    rm -f /etc/rc.d/rc6.d/K86nfslock
104
    rm -f /etc/rc.d/rc6.d/K87portmap
105
    rm -f /etc/rc.d/rc6.d/K90network
106
 
107
    rm -f /etc/rc.d/rc0.d/K75netfs
108
    rm -f /etc/rc.d/rc0.d/K86nfslock
109
    rm -f /etc/rc.d/rc0.d/K87portmap
110
    rm -f /etc/rc.d/rc0.d/K90network
111
fi
112
 
113
### create AFS mount point
114
mkdir -p /afs
115
 
116
### enable AFS during start up, if given by boot parameter
117
if [ $AFS ]; then
118
    chkconfig afs on
119
fi
120
 
121
### disable some services for fast booting
122
if [ $FASTBOOT ]; then    
123
    echo "Fast booting enabled"
124
    chkconfig vpnclient_init off
125
    chkconfig haldaemon off
126
    chkconfig pcmcia off
127
    chkconfig ntpd off
128
    chkconfig atd off
129
    chkconfig cpuspeed off
130
    chkconfig gpm off
131
    chkconfig messagebus off
132
    rm -rf /etc/rc.d/rc3.d/S04kudzu-auto
133
    rm -rf /etc/rc.d/rc5.d/S04kudzu-auto
134
fi
135
 
136
### enable ntpd?
137
if [ $NTPD ]; then
138
    chkconfig ntpd on
139
fi
140
 
141
### enable SSH server during start up, if given by boot parameter
142
if [ $SSH ]; then
143
    chkconfig sshd on
144
fi
145
 
146
### services on
147
if [ -n $SERVICEON ]; then
148
    for service in `echo "$SERVICEON" | tr ':' ' '`; do
149
	if [ -f /etc/init.d/$service ]; then
150
	    chkconfig $service on
151
	fi
152
    done
153
fi
154
 
155
### services off
156
if [ -n $SERVICEOFF ]; then
157
    for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
158
	if [ -f /etc/init.d/$service ]; then
159
	    chkconfig $service off
160
	fi
161
    done
162
fi
163
 
164
### fix perm of /tmp
165
chmod 1777 /tmp
166
 
167
### link /opt -> /usr/opt !
168
ln -s /usr/opt /opt
169
 
170
### create home
171
mkdir -p /home
172
 
173
### create /scratch
174
mkdir -p /scratch
175
chmod 1777 /scratch
176
 
177
### create /data
178
if [ $PSI ]; then
179
    mkdir -p /data
180
    chmod 1777 /data
181
fi
182
 
183
### add PSI master
184
if [ $PSI ]; then
185
    mkdir -p /mnt/master
186
    echo "pxeserv01:/master       /mnt/master             nfs     nfsvers=2,noauto,nolock,ro 0 0" >> /etc/fstab
187
fi
188
 
189
### set afs cell, if given by boot parameter
190
if [ $CELL ]; then
191
    echo $CELL > /usr/vice/etc/ThisCell
192
fi
193
 
9 beyerle@PS 194
### do not activate network eth0/1 during bootup, if "nonet"
1 beyerle@PS 195
if [ $NONET ]; then
9 beyerle@PS 196
    for iface in eth0 eth1; do
1 beyerle@PS 197
	for file in networking/profiles/default/ifcfg \
198
	            networking/devices/ifcfg \
199
                    network-scripts/ifcfg; do
9 beyerle@PS 200
	  sed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}
1 beyerle@PS 201
	done
202
    done
203
fi
204
 
205
### define static IP and gateway, netmask
206
if [ $IPADDR ]; then    
207
    if [ ! $GATEWAY ]; then
208
	# default gatway x.y.z.1
209
	GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )
210
	if [ ! $NETMASK ]; then
211
	    NETMASK=255.255.255.0
212
	fi
213
    fi
214
    # create config files for eth0
215
    for iface in eth0; do
216
	for file in networking/profiles/default/ifcfg \
217
	            networking/devices/ifcfg \
218
	            network-scripts/ifcfg; do
219
	  sed -i "s/BOOTPROTO=.*/BOOTPROTO=none/" /etc/sysconfig/${file}-${iface}
220
	  echo "IPADDR=$IPADDR" > /etc/sysconfig/${file}-${iface}
221
	  echo "NETMASK=$NETMASK" > /etc/sysconfig/${file}-${iface}
222
	  echo "GATEWAY=$GATEWAY" > /etc/sysconfig/${file}-${iface}
223
	done
224
    done
225
fi