Subversion Repositories livecd

Rev

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

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