Subversion Repositories livecd

Rev

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

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