Subversion Repositories livecd

Rev

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

Rev 137 Rev 138
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
74
### save status of services that may be disabled, 
-
 
75
#   if LiveCD mounted over NFS
75
if [ $NFSROOT ]; then
76
if [ $NFSROOT ]; then
76
    NFS_SERVICES="rpcidmapd NetworkManager NetworkManagerDispatcher \
77
    NFS_SERVICES="rpcidmapd NetworkManager NetworkManagerDispatcher \
77
                  netfs nfslock portmap network"
78
                  netfs nfslock portmap network"
78
    for serv in $NFS_SERVICES; do
79
    for serv in $NFS_SERVICES; do
79
	chkconfig --list $serv | grep -q ":on" && echo $serv >> /$MOUNTDIR/service.on
80
	chkconfig --list $serv | grep -q ":on" && echo $serv >> /$MOUNTDIR/service.on
80
    done
81
    done
81
fi
82
fi
82
 
83
 
83
### disable rpcidmapd, if LiveCD mounted over NFS
84
### disable rpcidmapd, if LiveCD mounted over NFS
84
if [ $NFSROOT ]; then
85
if [ $NFSROOT ]; then
85
    $MOUNTDIR
86
    $MOUNTDIR
86
    chkconfig rpcidmapd off >/dev/null 2>&1
87
    chkconfig rpcidmapd off >/dev/null 2>&1
87
fi
88
fi
88
 
89
 
89
### disable NetworkManager, if LiveCD mounted over NFS
90
### disable NetworkManager, if LiveCD mounted over NFS
90
if [ $NFSROOT ]; then
91
if [ $NFSROOT ]; then
91
    chkconfig NetworkManager off           >/dev/null 2>&1
92
    chkconfig NetworkManager off           >/dev/null 2>&1
92
    chkconfig NetworkManagerDispatcher off >/dev/null 2>&1 
93
    chkconfig NetworkManagerDispatcher off >/dev/null 2>&1 
93
fi
94
fi
94
 
95
 
95
### disable shutdown of network and nfs, 
96
### disable shutdown of network and nfs, 
96
# if we have the LiveCD mounted over NFS
97
# if we have the LiveCD mounted over NFS
97
if [ $NFSROOT ]; then
98
if [ $NFSROOT ]; then
98
    if [ $ONEMASTER ]; then
99
    if [ $ONEMASTER ]; then
99
        # "network off" is only necessary, 
100
        # "network off" is only necessary, 
100
        # if PXE/TFTP and NTS server is on same machine
101
        # if PXE/TFTP and NTS server is on same machine
101
	chkconfig network off
102
	chkconfig network off
102
    fi
103
    fi
103
 
104
 
104
    rm -f /etc/rc.d/rc6.d/K*netfs
105
    rm -f /etc/rc.d/rc6.d/K*netfs
105
    rm -f /etc/rc.d/rc6.d/K*nfslock
106
    rm -f /etc/rc.d/rc6.d/K*nfslock
106
    rm -f /etc/rc.d/rc6.d/K*portmap
107
    rm -f /etc/rc.d/rc6.d/K*portmap
107
    rm -f /etc/rc.d/rc6.d/K*network
108
    rm -f /etc/rc.d/rc6.d/K*network
108
 
109
 
109
    rm -f /etc/rc.d/rc0.d/K*netfs
110
    rm -f /etc/rc.d/rc0.d/K*netfs
110
    rm -f /etc/rc.d/rc0.d/K*nfslock
111
    rm -f /etc/rc.d/rc0.d/K*nfslock
111
    rm -f /etc/rc.d/rc0.d/K*portmap
112
    rm -f /etc/rc.d/rc0.d/K*portmap
112
    rm -f /etc/rc.d/rc0.d/K*network
113
    rm -f /etc/rc.d/rc0.d/K*network
113
fi
114
fi
114
 
115
 
115
### enable AFS during start up, if given by boot parameter
116
### enable AFS during start up, if given by boot parameter
116
if [ $AFS ]; then
117
if [ $AFS ]; then
117
    chkconfig afs on
118
    chkconfig afs on
118
fi
119
fi
119
 
120
 
120
### disable auto-kudzu
121
### disable auto-kudzu ?
121
if [ $NOKUDZU ]; then
122
if [ $NOKUDZU ]; then
122
    chkconfig kudzu-auto off
123
    chkconfig kudzu-auto off
123
fi
124
fi
124
 
125
 
125
### disable some services for fast booting
126
### disable some services for fast booting
126
if [ $FASTBOOT ]; then    
127
if [ $FASTBOOT ]; then    
127
    echo "Fast booting enabled"
128
    echo "Fast booting enabled"
128
    chkconfig vpnclient_init off  2>/dev/null
129
    chkconfig vpnclient_init off  2>/dev/null
129
    chkconfig haldaemon off       2>/dev/null
130
    chkconfig haldaemon off       2>/dev/null
130
    chkconfig pcmcia off          2>/dev/null
131
    chkconfig pcmcia off          2>/dev/null
131
    chkconfig ntpd off            2>/dev/null
132
    chkconfig ntpd off            2>/dev/null
132
    chkconfig atd off             2>/dev/null
133
    chkconfig atd off             2>/dev/null
133
    chkconfig cpuspeed off        2>/dev/null
134
    chkconfig cpuspeed off        2>/dev/null
134
    chkconfig gpm off             2>/dev/null
135
    chkconfig gpm off             2>/dev/null
135
    chkconfig messagebus off      2>/dev/null
136
    chkconfig messagebus off      2>/dev/null
136
    chkconfig avahi-daemon off    2>/dev/null
137
    chkconfig avahi-daemon off    2>/dev/null
137
    chkconfig kudzu-auto off      2>/dev/null
138
    chkconfig kudzu-auto off      2>/dev/null
138
fi
139
fi
139
 
140
 
140
### enable ntpd?
141
### enable ntpd ?
141
if [ $NTPD ]; then
142
if [ $NTPD ]; then
142
    chkconfig ntpd on
143
    chkconfig ntpd on
143
fi
144
fi
144
 
145
 
145
### enable SSH server during start up, if given by boot parameter
146
### enable SSH server during start up, if given by boot parameter
146
if [ $SSH ]; then
147
if [ $SSH ]; then
147
    chkconfig sshd on
148
    chkconfig sshd on
148
fi
149
fi
149
 
150
 
150
### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
151
### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
151
if [ ! $NONET ]; then
152
if [ ! $NONET ]; then
152
    lspci | grep -q Intel.*3945ABG
153
    lspci | grep -q Intel.*3945ABG
153
    if [ "$?" = "0" ]; then
154
    if [ "$?" = "0" ]; then
154
	chkconfig ipw3945d on 2>/dev/null
155
	chkconfig ipw3945d on 2>/dev/null
155
    fi
156
    fi
156
fi
157
fi
157
 
158
 
158
### enable 915resolution on Intel Mobile Display controller
159
### enable 915resolution on Intel Mobile Display controller
159
#   and set resolution in /etc/sysconfig/915resolution defined by screen=
160
#   and set resolution in /etc/sysconfig/915resolution defined by screen=
160
lspci | grep -q Display.*Intel.*Mobile
161
lspci | grep -q Display.*Intel.*Mobile
161
if [ "$?" = "0" ]; then 
162
if [ "$?" = "0" ]; then 
162
    chkconfig 915resolution on 2>/dev/null
163
    chkconfig 915resolution on 2>/dev/null
163
    if [ -e /etc/sysconfig/915resolution ]; then
164
    if [ -e /etc/sysconfig/915resolution ]; then
164
	X=$( echo $SCREEN | cut -d"x" -f1 )
165
	X=$( echo $SCREEN | cut -d"x" -f1 )
165
	Y=$( echo $SCREEN | cut -d"x" -f2 )
166
	Y=$( echo $SCREEN | cut -d"x" -f2 )
166
	if [ $X ]; then
167
	if [ $X ]; then
167
	    sed -i "s|^X=.*|X=$X|" /etc/sysconfig/915resolution
168
	    sed -i "s|^X=.*|X=$X|" /etc/sysconfig/915resolution
168
	fi
169
	fi
169
	if [ $Y ]; then
170
	if [ $Y ]; then
170
	    sed -i "s|^Y=.*|Y=$Y|" /etc/sysconfig/915resolution
171
	    sed -i "s|^Y=.*|Y=$Y|" /etc/sysconfig/915resolution
171
	fi
172
	fi
172
    fi
173
    fi
173
fi
174
fi
174
 
175
 
175
### services on
176
### services on
176
if [ -n $SERVICEON ]; then
177
if [ -n $SERVICEON ]; then
177
    for service in `echo "$SERVICEON" | tr ':' ' '`; do
178
    for service in `echo "$SERVICEON" | tr ':' ' '`; do
178
	if [ -f /etc/init.d/$service ]; then
179
	if [ -f /etc/init.d/$service ]; then
179
	    chkconfig $service on
180
	    chkconfig $service on
180
	fi
181
	fi
181
    done
182
    done
182
fi
183
fi
183
 
184
 
184
### services off
185
### services off
185
if [ -n $SERVICEOFF ]; then
186
if [ -n $SERVICEOFF ]; then
186
    for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
187
    for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
187
	if [ -f /etc/init.d/$service ]; then
188
	if [ -f /etc/init.d/$service ]; then
188
	    chkconfig $service off
189
	    chkconfig $service off
189
	fi
190
	fi
190
    done
191
    done
191
fi
192
fi
192
 
193
 
193
 
194
 
194
### -----------------------------------------------------------
195
### -----------------------------------------------------------
195
### Main
196
### Main
196
### -----------------------------------------------------------
197
### -----------------------------------------------------------
197
 
198
 
198
### get resolv.conf, if we have the LiveCD mounted over NFS
199
### get resolv.conf, if we have the LiveCD mounted over NFS
199
if [ $NFSROOT ]; then
200
if [ $NFSROOT ]; then
200
    cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
201
    cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
201
fi
202
fi
202
 
203
 
203
### restore blacklist (modified in runveryfirst)
204
### restore blacklist (modified in runveryfirst)
204
if [ $NFSROOT ]; then
205
if [ $NFSROOT ]; then
205
    [ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
206
    [ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
206
    [ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
207
    [ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
207
    mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
208
    mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
208
fi
209
fi
209
 
210
 
210
### create AFS mount point
211
### create AFS mount point
211
mkdir -p /afs
212
mkdir -p /afs
212
 
213
 
213
### set afs cell, if given by boot parameter
214
### set afs cell, if given by boot parameter
214
if [ $CELL ]; then
215
if [ $CELL ]; then
215
    echo $CELL > /usr/vice/etc/ThisCell
216
    echo $CELL > /usr/vice/etc/ThisCell
216
fi
217
fi
217
 
218
 
218
### fix perm of /tmp
219
### fix perm of /tmp
219
chmod 1777 /tmp
220
chmod 1777 /tmp
220
 
221
 
221
### create home
222
### create home
222
mkdir -p /home
223
mkdir -p /home
223
 
224
 
224
### create /scratch
225
### create /scratch
225
mkdir -p /scratch
226
mkdir -p /scratch
226
chmod 1777 /scratch
227
chmod 1777 /scratch
227
 
228
 
228
### create /data
229
### create /data
229
if [ $PSI ]; then
230
if [ $PSI ]; then
230
    mkdir -p /data
231
    mkdir -p /data
231
    chmod 1777 /data
232
    chmod 1777 /data
232
fi
233
fi
233
 
234
 
234
### add PSI master
235
### add PSI master
235
if [ $PSI ]; then
236
if [ $PSI ]; then
236
    mkdir -p /mnt/master
237
    mkdir -p /mnt/master
237
    echo "pxeserv01:/master       /mnt/master             nfs     noauto,nolock,ro 0 0" >> /etc/fstab
238
    echo "pxeserv01:/master       /mnt/master             nfs     noauto,nolock,ro 0 0" >> /etc/fstab
238
fi
239
fi
239
 
240