Subversion Repositories livecd

Rev

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

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