Subversion Repositories livecd

Rev

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

Rev 131 Rev 137
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
# Fix things during bootup - run first 
3
# Fix things during bootup - run first 
4
# For example: Enable services, etc ...
4
# For example: Enable services, etc ...
5
# Executed at the very end of /etc/rc.d/rc.sysinit
5
# Executed at the very end of /etc/rc.d/rc.sysinit
6
#
6
#
7
# Urs Beyerle, PSI
7
# Urs Beyerle, PSI
8
#
8
#
9
 
9
 
10
### -----------------------------------------------------------
10
### -----------------------------------------------------------
11
### Definitions
11
### Definitions
12
### -----------------------------------------------------------
12
### -----------------------------------------------------------
13
 
13
 
14
# dir of mounted /$MOUNTDIR/live
14
# dir of mounted /$MOUNTDIR/live
15
MOUNTDIR=livecd
15
MOUNTDIR=livecd
16
 
16
 
17
# source functions
17
# source functions
18
. /$MOUNTDIR/live/liblinuxlive
18
. /$MOUNTDIR/live/liblinuxlive
19
. /etc/init.d/functions
19
. /etc/init.d/functions
20
 
20
 
21
 
21
 
22
### -----------------------------------------------------------
22
### -----------------------------------------------------------
23
### Get boot parameters
23
### Get boot parameters
24
### -----------------------------------------------------------
24
### -----------------------------------------------------------
25
 
25
 
26
# start afs?
26
# start afs?
27
AFS=$( cmdline_parameter afs )
27
AFS=$( cmdline_parameter afs )
28
CELL=$( cmdline_value cell )
28
CELL=$( cmdline_value cell )
29
 
29
 
30
# or force no afs
30
# or force no afs
31
[ $( cmdline_parameter noafs ) ] && AFS=""
31
[ $( cmdline_parameter noafs ) ] && AFS=""
32
 
32
 
33
# start ssh server?
33
# start ssh server?
34
SSH=$( cmdline_parameter ssh )
34
SSH=$( cmdline_parameter ssh )
35
 
35
 
36
# root on NFS?
36
# root on NFS?
37
NFSROOT=$( cmdline_value nfsroot )
37
NFSROOT=$( cmdline_value nfsroot )
38
 
38
 
39
# PSI setup?
39
# PSI setup?
40
PSI=$( cmdline_parameter psi )
40
PSI=$( cmdline_parameter psi )
41
 
41
 
42
# do not start network
42
# do not start network
43
NONET=$( cmdline_parameter nonet )
43
NONET=$( cmdline_parameter nonet )
44
 
44
 
45
# Are PXE/TFTP and NFS Server the same host ? not uesed any more
45
# Are PXE/TFTP and NFS Server the same host ? not uesed any more
46
ONEMASTER=$( cmdline_parameter onemaster )
46
ONEMASTER=$( cmdline_parameter onemaster )
47
 
47
 
48
# fast booting ?
48
# fast booting ?
49
FASTBOOT=$( cmdline_parameter fastboot )
49
FASTBOOT=$( cmdline_parameter fastboot )
50
 
50
 
51
# no (auto) kudzu ?
51
# no (auto) kudzu ?
52
NOKUDZU=$( cmdline_parameter nokudzu )
52
NOKUDZU=$( cmdline_parameter nokudzu )
53
 
53
 
54
# if run=rdesktop, we do fast boot
54
# if run=rdesktop, we do fast boot
55
if [ "$( cmdline_value run )" = "rdesktop" ]; then
55
if [ "$( cmdline_value run )" = "rdesktop" ]; then
56
    FASTBOOT="fastboot"
56
    FASTBOOT="fastboot"
57
fi
57
fi
58
 
58
 
59
# start ntpd ?
59
# start ntpd ?
60
NTPD=$( cmdline_parameter ntpd )
60
NTPD=$( cmdline_parameter ntpd )
61
 
61
 
62
# services on/off
62
# services on/off
63
SERVICEON=$( cmdline_value serviceon )
63
SERVICEON=$( cmdline_value serviceon )
64
SERVICEOFF=$( cmdline_value serviceoff )
64
SERVICEOFF=$( cmdline_value serviceoff )
65
 
65
 
66
# Xserver configurations
66
# Xserver configurations
67
SCREEN=$( cmdline_value screen )
67
SCREEN=$( cmdline_value screen )
68
 
68
 
69
 
69
 
70
### -----------------------------------------------------------
70
### -----------------------------------------------------------
71
### Configure services
71
### Configure services
72
### -----------------------------------------------------------
72
### -----------------------------------------------------------
73
 
73
 
-
 
74
### save status of services that may be disabled, if LiveCD mounted over NFS
-
 
75
if [ $NFSROOT ]; then
-
 
76
    NFS_SERVICES="rpcidmapd NetworkManager NetworkManagerDispatcher \
-
 
77
                  netfs nfslock portmap network"
-
 
78
    for serv in $NFS_SERVICES; do
-
 
79
	chkconfig --list $serv | grep -q ":on" && echo $serv >> /$MOUNTDIR/service.on
-
 
80
    done
-
 
81
fi
-
 
82
 
74
### disable rpcidmapd, if LiveCD mounted over NFS
83
### disable rpcidmapd, if LiveCD mounted over NFS
75
if [ $NFSROOT ]; then
84
if [ $NFSROOT ]; then
-
 
85
    $MOUNTDIR
76
    chkconfig rpcidmapd off >/dev/null 2>&1
86
    chkconfig rpcidmapd off >/dev/null 2>&1
77
fi
87
fi
78
 
88
 
79
### disable NetworkManager, if LiveCD mounted over NFS
89
### disable NetworkManager, if LiveCD mounted over NFS
80
if [ $NFSROOT ]; then
90
if [ $NFSROOT ]; then
81
    chkconfig NetworkManager off           >/dev/null 2>&1
91
    chkconfig NetworkManager off           >/dev/null 2>&1
82
    chkconfig NetworkManagerDispatcher off >/dev/null 2>&1 
92
    chkconfig NetworkManagerDispatcher off >/dev/null 2>&1 
83
fi
93
fi
84
 
94
 
85
### disable shutdown of network and nfs, 
95
### disable shutdown of network and nfs, 
86
# if we have the LiveCD mounted over NFS
96
# if we have the LiveCD mounted over NFS
87
if [ $NFSROOT ]; then
97
if [ $NFSROOT ]; then
88
    if [ $ONEMASTER ]; then
98
    if [ $ONEMASTER ]; then
89
        # "network off" is only necessary, 
99
        # "network off" is only necessary, 
90
        # if PXE/TFTP and NTS server is on same machine
100
        # if PXE/TFTP and NTS server is on same machine
91
	chkconfig network off
101
	chkconfig network off
92
    fi
102
    fi
93
 
103
 
94
    rm -f /etc/rc.d/rc6.d/K*netfs
104
    rm -f /etc/rc.d/rc6.d/K*netfs
95
    rm -f /etc/rc.d/rc6.d/K*nfslock
105
    rm -f /etc/rc.d/rc6.d/K*nfslock
96
    rm -f /etc/rc.d/rc6.d/K*portmap
106
    rm -f /etc/rc.d/rc6.d/K*portmap
97
    rm -f /etc/rc.d/rc6.d/K*network
107
    rm -f /etc/rc.d/rc6.d/K*network
98
 
108
 
99
    rm -f /etc/rc.d/rc0.d/K*netfs
109
    rm -f /etc/rc.d/rc0.d/K*netfs
100
    rm -f /etc/rc.d/rc0.d/K*nfslock
110
    rm -f /etc/rc.d/rc0.d/K*nfslock
101
    rm -f /etc/rc.d/rc0.d/K*portmap
111
    rm -f /etc/rc.d/rc0.d/K*portmap
102
    rm -f /etc/rc.d/rc0.d/K*network
112
    rm -f /etc/rc.d/rc0.d/K*network
103
fi
113
fi
104
 
114
 
105
### enable AFS during start up, if given by boot parameter
115
### enable AFS during start up, if given by boot parameter
106
if [ $AFS ]; then
116
if [ $AFS ]; then
107
    chkconfig afs on
117
    chkconfig afs on
108
fi
118
fi
109
 
119
 
110
### disable auto-kudzu
120
### disable auto-kudzu
111
if [ $NOKUDZU ]; then
121
if [ $NOKUDZU ]; then
112
    chkconfig kudzu-auto off
122
    chkconfig kudzu-auto off
113
fi
123
fi
114
 
124
 
115
### disable some services for fast booting
125
### disable some services for fast booting
116
if [ $FASTBOOT ]; then    
126
if [ $FASTBOOT ]; then    
117
    echo "Fast booting enabled"
127
    echo "Fast booting enabled"
118
    chkconfig vpnclient_init off  2>/dev/null
128
    chkconfig vpnclient_init off  2>/dev/null
119
    chkconfig haldaemon off       2>/dev/null
129
    chkconfig haldaemon off       2>/dev/null
120
    chkconfig pcmcia off          2>/dev/null
130
    chkconfig pcmcia off          2>/dev/null
121
    chkconfig ntpd off            2>/dev/null
131
    chkconfig ntpd off            2>/dev/null
122
    chkconfig atd off             2>/dev/null
132
    chkconfig atd off             2>/dev/null
123
    chkconfig cpuspeed off        2>/dev/null
133
    chkconfig cpuspeed off        2>/dev/null
124
    chkconfig gpm off             2>/dev/null
134
    chkconfig gpm off             2>/dev/null
125
    chkconfig messagebus off      2>/dev/null
135
    chkconfig messagebus off      2>/dev/null
126
    chkconfig avahi-daemon off    2>/dev/null
136
    chkconfig avahi-daemon off    2>/dev/null
127
    chkconfig kudzu-auto off      2>/dev/null
137
    chkconfig kudzu-auto off      2>/dev/null
128
fi
138
fi
129
 
139
 
130
### enable ntpd?
140
### enable ntpd?
131
if [ $NTPD ]; then
141
if [ $NTPD ]; then
132
    chkconfig ntpd on
142
    chkconfig ntpd on
133
fi
143
fi
134
 
144
 
135
### enable SSH server during start up, if given by boot parameter
145
### enable SSH server during start up, if given by boot parameter
136
if [ $SSH ]; then
146
if [ $SSH ]; then
137
    chkconfig sshd on
147
    chkconfig sshd on
138
fi
148
fi
139
 
149
 
140
### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
150
### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
141
if [ ! $NONET ]; then
151
if [ ! $NONET ]; then
142
    lspci | grep -q Intel.*3945ABG
152
    lspci | grep -q Intel.*3945ABG
143
    if [ "$?" = "0" ]; then
153
    if [ "$?" = "0" ]; then
144
	chkconfig ipw3945d on 2>/dev/null
154
	chkconfig ipw3945d on 2>/dev/null
145
    fi
155
    fi
146
fi
156
fi
147
 
157
 
148
### enable 915resolution on Intel Mobile Display controller
158
### enable 915resolution on Intel Mobile Display controller
149
#   and set resolution in /etc/sysconfig/915resolution defined by screen=
159
#   and set resolution in /etc/sysconfig/915resolution defined by screen=
150
lspci | grep -q Display.*Intel.*Mobile
160
lspci | grep -q Display.*Intel.*Mobile
151
if [ "$?" = "0" ]; then 
161
if [ "$?" = "0" ]; then 
152
    chkconfig 915resolution on 2>/dev/null
162
    chkconfig 915resolution on 2>/dev/null
153
    if [ -e /etc/sysconfig/915resolution ]; then
163
    if [ -e /etc/sysconfig/915resolution ]; then
154
	X=$( echo $SCREEN | cut -d"x" -f1 )
164
	X=$( echo $SCREEN | cut -d"x" -f1 )
155
	Y=$( echo $SCREEN | cut -d"x" -f2 )
165
	Y=$( echo $SCREEN | cut -d"x" -f2 )
156
	if [ $X ]; then
166
	if [ $X ]; then
157
	    sed -i "s|^X=.*|X=$X|" /etc/sysconfig/915resolution
167
	    sed -i "s|^X=.*|X=$X|" /etc/sysconfig/915resolution
158
	fi
168
	fi
159
	if [ $Y ]; then
169
	if [ $Y ]; then
160
	    sed -i "s|^Y=.*|Y=$Y|" /etc/sysconfig/915resolution
170
	    sed -i "s|^Y=.*|Y=$Y|" /etc/sysconfig/915resolution
161
	fi
171
	fi
162
    fi
172
    fi
163
fi
173
fi
164
 
174
 
165
### services on
175
### services on
166
if [ -n $SERVICEON ]; then
176
if [ -n $SERVICEON ]; then
167
    for service in `echo "$SERVICEON" | tr ':' ' '`; do
177
    for service in `echo "$SERVICEON" | tr ':' ' '`; do
168
	if [ -f /etc/init.d/$service ]; then
178
	if [ -f /etc/init.d/$service ]; then
169
	    chkconfig $service on
179
	    chkconfig $service on
170
	fi
180
	fi
171
    done
181
    done
172
fi
182
fi
173
 
183
 
174
### services off
184
### services off
175
if [ -n $SERVICEOFF ]; then
185
if [ -n $SERVICEOFF ]; then
176
    for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
186
    for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
177
	if [ -f /etc/init.d/$service ]; then
187
	if [ -f /etc/init.d/$service ]; then
178
	    chkconfig $service off
188
	    chkconfig $service off
179
	fi
189
	fi
180
    done
190
    done
181
fi
191
fi
182
 
192
 
183
 
193
 
184
### -----------------------------------------------------------
194
### -----------------------------------------------------------
185
### Main
195
### Main
186
### -----------------------------------------------------------
196
### -----------------------------------------------------------
187
 
197
 
188
### get resolv.conf, if we have the LiveCD mounted over NFS
198
### get resolv.conf, if we have the LiveCD mounted over NFS
189
if [ $NFSROOT ]; then
199
if [ $NFSROOT ]; then
190
    cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
200
    cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
191
fi
201
fi
192
 
202
 
193
### restore blacklist (modified in runveryfirst)
203
### restore blacklist (modified in runveryfirst)
194
if [ $NFSROOT ]; then
204
if [ $NFSROOT ]; then
195
    [ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
205
    [ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
196
    [ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
206
    [ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
197
    mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
207
    mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
198
fi
208
fi
199
 
209
 
200
### create AFS mount point
210
### create AFS mount point
201
mkdir -p /afs
211
mkdir -p /afs
202
 
212
 
203
### set afs cell, if given by boot parameter
213
### set afs cell, if given by boot parameter
204
if [ $CELL ]; then
214
if [ $CELL ]; then
205
    echo $CELL > /usr/vice/etc/ThisCell
215
    echo $CELL > /usr/vice/etc/ThisCell
206
fi
216
fi
207
 
217
 
208
### fix perm of /tmp
218
### fix perm of /tmp
209
chmod 1777 /tmp
219
chmod 1777 /tmp
210
 
220
 
211
### create home
221
### create home
212
mkdir -p /home
222
mkdir -p /home
213
 
223
 
214
### create /scratch
224
### create /scratch
215
mkdir -p /scratch
225
mkdir -p /scratch
216
chmod 1777 /scratch
226
chmod 1777 /scratch
217
 
227
 
218
### create /data
228
### create /data
219
if [ $PSI ]; then
229
if [ $PSI ]; then
220
    mkdir -p /data
230
    mkdir -p /data
221
    chmod 1777 /data
231
    chmod 1777 /data
222
fi
232
fi
223
 
233
 
224
### add PSI master
234
### add PSI master
225
if [ $PSI ]; then
235
if [ $PSI ]; then
226
    mkdir -p /mnt/master
236
    mkdir -p /mnt/master
227
    echo "pxeserv01:/master       /mnt/master             nfs     noauto,nolock,ro 0 0" >> /etc/fstab
237
    echo "pxeserv01:/master       /mnt/master             nfs     noauto,nolock,ro 0 0" >> /etc/fstab
228
fi
238
fi
229
 
239