Subversion Repositories livecd

Rev

Rev 7 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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