Subversion Repositories livecd

Rev

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

Rev 210 Rev 216
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
7
# Urs Beyerle
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
### Set system clock again (code copied from rc.sysinit)
68
### Set system clock again (code copied from rc.sysinit)
69
### -----------------------------------------------------------
69
### -----------------------------------------------------------
70
ARC=0
70
ARC=0
71
SRM=0
71
SRM=0
72
UTC=0
72
UTC=0
73
 
73
 
74
if [ -f /etc/sysconfig/clock ]; then
74
if [ -f /etc/sysconfig/clock ]; then
75
   . /etc/sysconfig/clock
75
   . /etc/sysconfig/clock
76
 
76
 
77
   # convert old style clock config to new values
77
   # convert old style clock config to new values
78
   if [ "${CLOCKMODE}" = "GMT" ]; then
78
   if [ "${CLOCKMODE}" = "GMT" ]; then
79
      UTC=true
79
      UTC=true
80
   elif [ "${CLOCKMODE}" = "ARC" ]; then
80
   elif [ "${CLOCKMODE}" = "ARC" ]; then
81
      ARC=true
81
      ARC=true
82
   fi
82
   fi
83
fi
83
fi
84
 
84
 
85
CLOCKDEF=""
85
CLOCKDEF=""
86
CLOCKFLAGS="$CLOCKFLAGS --hctosys"
86
CLOCKFLAGS="$CLOCKFLAGS --hctosys"
87
 
87
 
88
case "$UTC" in
88
case "$UTC" in
89
    yes|true)   CLOCKFLAGS="$CLOCKFLAGS --utc"
89
    yes|true)   CLOCKFLAGS="$CLOCKFLAGS --utc"
90
                CLOCKDEF="$CLOCKDEF (utc)" ;;
90
                CLOCKDEF="$CLOCKDEF (utc)" ;;
91
    no|false)   CLOCKFLAGS="$CLOCKFLAGS --localtime"
91
    no|false)   CLOCKFLAGS="$CLOCKFLAGS --localtime"
92
                CLOCKDEF="$CLOCKDEF (localtime)" ;;
92
                CLOCKDEF="$CLOCKDEF (localtime)" ;;
93
esac
93
esac
94
case "$ARC" in
94
case "$ARC" in
95
    yes|true)   CLOCKFLAGS="$CLOCKFLAGS --arc"
95
    yes|true)   CLOCKFLAGS="$CLOCKFLAGS --arc"
96
                CLOCKDEF="$CLOCKDEF (arc)" ;;
96
                CLOCKDEF="$CLOCKDEF (arc)" ;;
97
esac
97
esac
98
case "$SRM" in
98
case "$SRM" in
99
    yes|true)   CLOCKFLAGS="$CLOCKFLAGS --srm"
99
    yes|true)   CLOCKFLAGS="$CLOCKFLAGS --srm"
100
                CLOCKDEF="$CLOCKDEF (srm)" ;;
100
                CLOCKDEF="$CLOCKDEF (srm)" ;;
101
esac
101
esac
102
 
102
 
103
[ -x /sbin/hwclock ] && /sbin/hwclock $CLOCKFLAGS
103
[ -x /sbin/hwclock ] && /sbin/hwclock $CLOCKFLAGS
104
action $"Setting clock $CLOCKDEF: `date`" /bin/true
104
action $"Setting clock $CLOCKDEF: `date`" /bin/true
105
 
105
 
106
 
106
 
107
### -----------------------------------------------------------
107
### -----------------------------------------------------------
108
### Configure services
108
### Configure services
109
### -----------------------------------------------------------
109
### -----------------------------------------------------------
110
 
110
 
111
### save status of services that may be disabled, 
111
### save status of services that may be disabled, 
112
#   if LiveCD mounted over NFS
112
#   if LiveCD mounted over NFS
113
if [ $NFSROOT ]; then
113
if [ $NFSROOT ]; then
114
    NFS_SERVICES="rpcidmapd NetworkManager NetworkManagerDispatcher \
114
    NFS_SERVICES="rpcidmapd NetworkManager NetworkManagerDispatcher \
115
                  netfs nfslock portmap network"
115
                  netfs nfslock portmap network"
116
    for serv in $NFS_SERVICES; do
116
    for serv in $NFS_SERVICES; do
117
	chkconfig --list $serv 2>/dev/null | grep -q ":on" && echo $serv >> /$MOUNTDIR/service.on
117
	chkconfig --list $serv 2>/dev/null | grep -q ":on" && echo $serv >> /$MOUNTDIR/service.on
118
    done
118
    done
119
fi
119
fi
120
 
120
 
121
### disable rpcidmapd, if LiveCD mounted over NFS
121
### disable rpcidmapd, if LiveCD mounted over NFS
122
if [ $NFSROOT ]; then
122
if [ $NFSROOT ]; then
123
    chkconfig rpcidmapd off >/dev/null 2>&1
123
    chkconfig rpcidmapd off >/dev/null 2>&1
124
fi
124
fi
125
 
125
 
126
### disable NetworkManager, if LiveCD mounted over NFS
126
### disable NetworkManager, if LiveCD mounted over NFS
127
if [ $NFSROOT ]; then
127
if [ $NFSROOT ]; then
128
    chkconfig NetworkManager off           >/dev/null 2>&1
128
    chkconfig NetworkManager off           >/dev/null 2>&1
129
    chkconfig NetworkManagerDispatcher off >/dev/null 2>&1 
129
    chkconfig NetworkManagerDispatcher off >/dev/null 2>&1 
130
fi
130
fi
131
 
131
 
132
### disable shutdown of network and nfs, 
132
### disable shutdown of network and nfs, 
133
# if we have the LiveCD mounted over NFS
133
# if we have the LiveCD mounted over NFS
134
if [ $NFSROOT ]; then
134
if [ $NFSROOT ]; then
135
 
135
 
136
    rm -f /etc/rc.d/rc6.d/K*netfs
136
    rm -f /etc/rc.d/rc6.d/K*netfs
137
    rm -f /etc/rc.d/rc6.d/K*nfslock
137
    rm -f /etc/rc.d/rc6.d/K*nfslock
138
    rm -f /etc/rc.d/rc6.d/K*portmap
138
    rm -f /etc/rc.d/rc6.d/K*portmap
139
    rm -f /etc/rc.d/rc6.d/K*network
139
    rm -f /etc/rc.d/rc6.d/K*network
140
 
140
 
141
    rm -f /etc/rc.d/rc0.d/K*netfs
141
    rm -f /etc/rc.d/rc0.d/K*netfs
142
    rm -f /etc/rc.d/rc0.d/K*nfslock
142
    rm -f /etc/rc.d/rc0.d/K*nfslock
143
    rm -f /etc/rc.d/rc0.d/K*portmap
143
    rm -f /etc/rc.d/rc0.d/K*portmap
144
    rm -f /etc/rc.d/rc0.d/K*network
144
    rm -f /etc/rc.d/rc0.d/K*network
145
fi
145
fi
146
 
146
 
147
### enable AFS during start up, if given by boot parameter
147
### enable AFS during start up, if given by boot parameter
148
if [ $AFS ]; then
148
if [ $AFS ]; then
149
    chkconfig afs on
149
    chkconfig afs on
150
fi
150
fi
151
 
151
 
152
### disable auto-kudzu ?
152
### disable auto-kudzu ?
153
if [ $NOKUDZU ]; then
153
if [ $NOKUDZU ]; then
154
    chkconfig kudzu-auto off
154
    chkconfig kudzu-auto off
155
fi
155
fi
156
 
156
 
157
### disable some services for fast booting
157
### disable some services for fast booting
158
if [ $FASTBOOT ]; then    
158
if [ $FASTBOOT ]; then    
159
    echo "Fast booting enabled"
159
    echo "Fast booting enabled"
160
    chkconfig vpnclient_init off  2>/dev/null
160
    chkconfig vpnclient_init off  2>/dev/null
161
    chkconfig haldaemon off       2>/dev/null
161
    chkconfig haldaemon off       2>/dev/null
162
    chkconfig pcmcia off          2>/dev/null
162
    chkconfig pcmcia off          2>/dev/null
163
    chkconfig ntpd off            2>/dev/null
163
    chkconfig ntpd off            2>/dev/null
164
    chkconfig atd off             2>/dev/null
164
    chkconfig atd off             2>/dev/null
165
    chkconfig cpuspeed off        2>/dev/null
165
    chkconfig cpuspeed off        2>/dev/null
166
    chkconfig gpm off             2>/dev/null
166
    chkconfig gpm off             2>/dev/null
167
    chkconfig messagebus off      2>/dev/null
167
    chkconfig messagebus off      2>/dev/null
168
    chkconfig avahi-daemon off    2>/dev/null
168
    chkconfig avahi-daemon off    2>/dev/null
169
    chkconfig kudzu-auto off      2>/dev/null
169
    chkconfig kudzu-auto off      2>/dev/null
170
fi
170
fi
171
 
171
 
172
### enable ntpd ?
172
### enable ntpd ?
173
if [ $NTPD ]; then
173
if [ $NTPD ]; then
174
    chkconfig ntpd on
174
    chkconfig ntpd on
175
fi
175
fi
176
 
176
 
177
### enable SSH server during start up, if given by boot parameter
177
### enable SSH server during start up, if given by boot parameter
178
if [ $SSH ]; then
178
if [ $SSH ]; then
179
    chkconfig sshd on
179
    chkconfig sshd on
180
fi
180
fi
181
 
181
 
182
### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
182
### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
183
if [ ! $NONET ]; then
183
if [ ! $NONET ]; then
184
    lspci | grep -q Intel.*3945ABG
184
    lspci | grep -q Intel.*3945ABG
185
    if [ "$?" = "0" ]; then
185
    if [ "$?" = "0" ]; then
186
	chkconfig ipw3945d on 2>/dev/null
186
	chkconfig ipw3945d on 2>/dev/null
187
    fi
187
    fi
188
fi
188
fi
189
 
189
 
190
### enable 915resolution on Intel Mobile Display controller
190
### enable 915resolution on Intel Mobile Display controller, if screen= is given
191
#   and set resolution in /etc/sysconfig/915resolution defined by screen=
191
#   and set correct resolution in /etc/sysconfig/915resolution
192
lspci | grep -q Display.*Intel.*Mobile
192
lspci | grep -q Display.*Intel.*Mobile
193
if [ "$?" = "0" ]; then 
193
if [ "$?" = "0" ] && [ $SCREEN ]; then 
194
    chkconfig 915resolution on 2>/dev/null
194
    chkconfig 915resolution on 2>/dev/null
195
    if [ -e /etc/sysconfig/915resolution ]; then
195
    if [ -e /etc/sysconfig/915resolution ]; then
196
	X=$( echo $SCREEN | cut -d"x" -f1 )
196
	X=$( echo $SCREEN | cut -d"x" -f1 )
197
	Y=$( echo $SCREEN | cut -d"x" -f2 )
197
	Y=$( echo $SCREEN | cut -d"x" -f2 )
198
	if [ $X ]; then
198
	if [ $X ]; then
199
	    sed -i "s|^X=.*|X=$X|" /etc/sysconfig/915resolution
199
	    sed -i "s|^X=.*|X=$X|" /etc/sysconfig/915resolution
200
	fi
200
	fi
201
	if [ $Y ]; then
201
	if [ $Y ]; then
202
	    sed -i "s|^Y=.*|Y=$Y|" /etc/sysconfig/915resolution
202
	    sed -i "s|^Y=.*|Y=$Y|" /etc/sysconfig/915resolution
203
	fi
203
	fi
204
    fi
204
    fi
205
fi
205
fi
206
 
206
 
207
### services on
207
### services on
208
if [ -n $SERVICEON ]; then
208
if [ -n $SERVICEON ]; then
209
    for service in `echo "$SERVICEON" | tr ':' ' '`; do
209
    for service in `echo "$SERVICEON" | tr ':' ' '`; do
210
	if [ -f /etc/init.d/$service ]; then
210
	if [ -f /etc/init.d/$service ]; then
211
	    chkconfig $service on
211
	    chkconfig $service on
212
	fi
212
	fi
213
    done
213
    done
214
fi
214
fi
215
 
215
 
216
### services off
216
### services off
217
if [ -n $SERVICEOFF ]; then
217
if [ -n $SERVICEOFF ]; then
218
    for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
218
    for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
219
	if [ -f /etc/init.d/$service ]; then
219
	if [ -f /etc/init.d/$service ]; then
220
	    chkconfig $service off
220
	    chkconfig $service off
221
	fi
221
	fi
222
    done
222
    done
223
fi
223
fi
224
 
224
 
225
 
225
 
226
### -----------------------------------------------------------
226
### -----------------------------------------------------------
227
### Main
227
### Main
228
### -----------------------------------------------------------
228
### -----------------------------------------------------------
229
 
229
 
230
### get resolv.conf, if we have the LiveCD mounted over NFS
230
### get resolv.conf, if we have the LiveCD mounted over NFS
231
if [ $NFSROOT ]; then
231
if [ $NFSROOT ]; then
232
    cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
232
    cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
233
fi
233
fi
234
 
234
 
235
### restore blacklist (modified in runveryfirst)
235
### restore blacklist (modified in runveryfirst)
236
if [ $NFSROOT ]; then
236
if [ $NFSROOT ]; then
237
    [ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
237
    [ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
238
    [ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
238
    [ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
239
    mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
239
    mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
240
fi
240
fi
241
 
241
 
242
### create AFS mount point
242
### create AFS mount point
243
mkdir -p /afs
243
mkdir -p /afs
244
 
244
 
245
### set afs cell, if given by boot parameter
245
### set afs cell, if given by boot parameter
246
if [ $CELL ]; then
246
if [ $CELL ]; then
247
    echo $CELL > /usr/vice/etc/ThisCell
247
    echo $CELL > /usr/vice/etc/ThisCell
248
fi
248
fi
249
 
249
 
250
### fix perm of /tmp
250
### fix perm of /tmp
251
chmod 1777 /tmp
251
chmod 1777 /tmp
252
 
252
 
253
### create home
253
### create home
254
mkdir -p /home
254
mkdir -p /home
255
 
255
 
256
### create /media, /misc, /net
256
### create /media, /misc, /net
257
mkdir -p /media /misc /net
257
mkdir -p /media /misc /net
258
 
258
 
259
### create /scratch
259
### create /scratch
260
mkdir -p /scratch
260
mkdir -p /scratch
261
chmod 1777 /scratch
261
chmod 1777 /scratch
262
 
262
 
263
### create /data
263
### create /data
264
if [ $PSI ]; then
264
if [ $PSI ]; then
265
    mkdir -p /data
265
    mkdir -p /data
266
    chmod 1777 /data
266
    chmod 1777 /data
267
fi
267
fi
268
 
268
 
269
### add PSI master
269
### add PSI master
270
if [ $PSI ]; then
270
if [ $PSI ]; then
271
    mkdir -p /mnt/master
271
    mkdir -p /mnt/master
272
    echo "pxeserv01:/master       /mnt/master             nfs     noauto,nolock,ro 0 0" >> /etc/fstab
272
    echo "pxeserv01:/master       /mnt/master             nfs     noauto,nolock,ro 0 0" >> /etc/fstab
273
fi
273
fi
274
 
274