Subversion Repositories livecd

Rev

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

Rev 1 Rev 7
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
# Fix things during bootup - run last 
3
# Fix things during bootup - run last 
4
#
4
#
5
# Urs Beyerle, PSI
5
# Urs Beyerle, PSI
6
#
6
#
7
 
7
 
8
### -----------------------------------------------------------
8
### -----------------------------------------------------------
9
### definitions
9
### definitions
10
### -----------------------------------------------------------
10
### -----------------------------------------------------------
11
 
11
 
12
# dir of mounted live system: /$MOUNTDIR/live
12
# dir of mounted live system: /$MOUNTDIR/live
13
MOUNTDIR=livecd
13
MOUNTDIR=livecd
14
 
14
 
15
# source functions
15
# source functions
16
. /$MOUNTDIR/live/liblinuxlive
16
. /$MOUNTDIR/live/liblinuxlive
17
. /etc/init.d/functions
17
. /etc/init.d/functions
18
 
18
 
19
 
19
 
20
### -----------------------------------------------------------
20
### -----------------------------------------------------------
21
### Get boot parameters
21
### Get boot parameters
22
### -----------------------------------------------------------
22
### -----------------------------------------------------------
23
 
23
 
24
# root on NFS?
24
# root on NFS?
25
NFSROOT=$( cmdline_value nfsroot )
25
NFSROOT=$( cmdline_value nfsroot )
26
 
26
 
27
# NFS Server
27
# NFS Server
28
NFSSERVER=$( echo $NFSROOT | cut -d":" -f1 )
28
NFSSERVER=$( echo $NFSROOT | cut -d":" -f1 )
29
 
29
 
30
# no local user?
30
# no local user?
31
NOLOCAL=$( cmdline_parameter nolocal )
31
NOLOCAL=$( cmdline_parameter nolocal )
32
 
32
 
33
# no root user?
33
# no root user?
34
NOROOT=$( cmdline_parameter noroot )
34
NOROOT=$( cmdline_parameter noroot )
35
 
35
 
36
# no localadmin?
36
# no localadmin?
37
NOADMIN=$( cmdline_parameter noadmin )
37
NOADMIN=$( cmdline_parameter noadmin )
38
LocalAdminGroup=localadmin
38
LocalAdminGroup=localadmin
39
 
39
 
40
# set password
40
# set password
41
PASSWD=$( cmdline_value passwd )
41
PASSWD=$( cmdline_value passwd )
42
[ ! $PASSWD ] && PASSWD=$( cmdline_value pw )
42
[ ! $PASSWD ] && PASSWD=$( cmdline_value pw )
43
 
43
 
44
# no password = empty password ?
44
# no password = empty password ?
45
NOPASSWD=$( cmdline_parameter nopasswd )
45
NOPASSWD=$( cmdline_parameter nopasswd )
46
 
46
 
47
# keyboard layout (kb= or keyboard=)
47
# keyboard layout (kb= or keyboard=)
48
KEYBOARD=$( cmdline_value keyboard )
48
KEYBOARD=$( cmdline_value keyboard )
49
KB=$( cmdline_value kb )
49
KB=$( cmdline_value kb )
50
 
50
 
51
# PSI setup?
51
# PSI setup?
52
PSI=$( cmdline_parameter psi )
52
PSI=$( cmdline_parameter psi )
53
 
53
 
54
# cups server
54
# cups server
55
CUPS=$( cmdline_value cups )
55
CUPS=$( cmdline_value cups )
56
 
56
 
57
# no X11
57
# no X11
58
NOX=$( cmdline_parameter nox )
58
NOX=$( cmdline_parameter nox )
59
 
59
 
60
# failsafe X server
60
# failsafe X server
61
SIMPLEX=$( cmdline_parameter simplex )
61
SIMPLEX=$( cmdline_parameter simplex )
62
 
62
 
63
# NVIDIA driver
63
# NVIDIA driver
64
NVIDIA=$( cmdline_parameter nvidia )
64
NVIDIA=$( cmdline_parameter nvidia )
65
if [ "$XDRIVER" = "nvidia" ]; then
65
if [ "$XDRIVER" = "nvidia" ]; then
66
    NVIDIA=nvidia
66
    NVIDIA=nvidia
67
fi
67
fi
68
 
68
 
69
# force NO NVIDIA driver - will overwite NVIDIA option
69
# force NO NVIDIA driver - will overwite NVIDIA option
70
NONVIDIA=$( cmdline_parameter nonvidia )
70
NONVIDIA=$( cmdline_parameter nonvidia )
71
 
71
 
72
# VESA driver
72
# VESA driver
73
VESA=$( cmdline_parameter vesa )
73
VESA=$( cmdline_parameter vesa )
74
 
74
 
75
# force to use a video driver ?
75
# force to use a video driver ?
76
XDRIVER=$( cmdline_value xdriver )
76
XDRIVER=$( cmdline_value xdriver )
77
 
77
 
78
# Xserver configurations
78
# Xserver configurations
79
HSYNC=$( cmdline_value hsync )
79
HSYNC=$( cmdline_value hsync )
80
VSYNC=$( cmdline_value vsync )
80
VSYNC=$( cmdline_value vsync )
81
SCREEN=$( cmdline_value screen )
81
SCREEN=$( cmdline_value screen )
82
 
82
 
83
# no SWAP
83
# no SWAP
84
NOSWAP=$( cmdline_parameter noswap )
84
NOSWAP=$( cmdline_parameter noswap )
85
 
85
 
86
# should we auto mount all found devices?
86
# should we auto mount all found devices?
87
AUTOMOUNT=$( cmdline_parameter automount )
87
AUTOMOUNT=$( cmdline_parameter automount )
88
if [ $AUTOMOUNT ]; then
88
if [ $AUTOMOUNT ]; then
89
    MOUNTOPT="auto,users"
89
    MOUNTOPT="auto,users"
90
else
90
else
91
    MOUNTOPT="noauto,users,ro"
91
    MOUNTOPT="noauto,users,ro"
92
fi
92
fi
93
 
93
 
94
# folder where we find data which was previously stored
94
# folder where we find data which was previously stored
95
# (normally on a usbstick, but can be partition)
95
# (normally on a usbstick, but can be partition)
96
if [ $PSI ]; then
96
if [ $PSI ]; then
97
    SAVEFOLDER=PSI_LIVECD
97
    SAVEFOLDER=PSI_LIVECD
98
else
98
else
99
    SAVEFOLDER=SL_LIVECD
99
    SAVEFOLDER=SL_LIVECD
100
fi
100
fi
101
 
101
 
102
# local home partition?
102
# local home partition?
103
# (e.g. /dev/hda1, /dev/hda1:/my_home)
103
# (e.g. /dev/hda1, /dev/hda1:/my_home)
104
HOMELOCAL=$( cmdline_value home )
104
HOMELOCAL=$( cmdline_value home )
105
 
105
 
106
# fast booting ?
106
# fast booting ?
107
FASTBOOT=$( cmdline_parameter fastboot )
107
FASTBOOT=$( cmdline_parameter fastboot )
108
 
108
 
109
# start afs?
109
# start afs?
110
AFS=$( cmdline_parameter afs )
110
AFS=$( cmdline_parameter afs )
111
 
111
 
112
# or force no afs
112
# or force no afs
113
[ $( cmdline_parameter noafs ) ] && AFS=""
113
[ $( cmdline_parameter noafs ) ] && AFS=""
114
 
114
 
115
# turn of sound (volume=0)
115
# turn of sound (volume=0)
116
NOSOUND=$( cmdline_parameter nosound )
116
NOSOUND=$( cmdline_parameter nosound )
117
 
117
 
118
# local user name?
118
# local user name?
119
LOCALUSER=$( cmdline_value user )
119
LOCALUSER=$( cmdline_value user )
120
 
120
 
121
# hostname?
121
# hostname?
122
HOSTNAME=$( cmdline_value hostname )
122
HOSTNAME=$( cmdline_value hostname )
123
 
123
 
124
# do we have defined a configuration directory?
124
# do we have defined a configuration directory?
125
CONFIG=$( cmdline_value config )
125
CONFIG=$( cmdline_value config )
126
 
126
 
127
# do not udpate fstab?
127
# do not udpate fstab?
128
NOFSTAB=$( cmdline_parameter nofstab )
128
NOFSTAB=$( cmdline_parameter nofstab )
129
 
129
 
130
# kde/gnome as desktop
130
# kde/gnome as desktop
131
GNOME=$( cmdline_parameter gnome )
131
GNOME=$( cmdline_parameter gnome )
132
KDE=$( cmdline_parameter kde )
132
KDE=$( cmdline_parameter kde )
133
 
133
 
134
 
134
 
135
### -----------------------------------------------------------
135
### -----------------------------------------------------------
136
### Improved hardware detection
136
### Improved hardware detection
137
### -----------------------------------------------------------
137
### -----------------------------------------------------------
138
 
138
 
139
### Improved graphic card detection?
139
### Improved graphic card detection?
140
 
140
 
141
if [ ! $SIMPLEX ]; then
141
if [ ! $SIMPLEX ]; then
142
 
142
 
143
    ### Intel Mobile 945GM
143
    ### Intel Mobile 945GM
144
    lspci | grep -q VGA.*Intel.*Mobile.*945GM
144
    lspci | grep -q VGA.*Intel.*Mobile.*945GM
145
    if [ "$?" = "0" ]; then
145
    if [ "$?" = "0" ]; then
146
	I945GM=i945gm
146
	I945GM=i945gm
147
	## not yet supported by i810 driver
147
	## not yet supported by i810 driver
148
        ## [ $XDRIVER ] || XDRIVER=i810
148
        ## [ $XDRIVER ] || XDRIVER=i810
149
	I915RESOLUTION=on
149
	I915RESOLUTION=on
150
    fi
150
    fi
151
    ### Intel Mobile 915GM
151
    ### Intel Mobile 915GM
152
    lspci | grep -q VGA.*Intel.*Mobile.*915GM
152
    lspci | grep -q VGA.*Intel.*Mobile.*915GM
153
    if [ "$?" = "0" ]; then
153
    if [ "$?" = "0" ]; then
154
	I915GM=i915gm
154
	I915GM=i915gm
155
	[ $XDRIVER ] || XDRIVER=i810
155
	[ $XDRIVER ] || XDRIVER=i810
156
	I855RESOLUTION=on
156
	I855RESOLUTION=on
157
    fi
157
    fi
158
 
158
 
159
    ### Intel Mobile 855GM
159
    ### Intel Mobile 855GM
160
    lspci | grep -q VGA.*Intel.*855GM
160
    lspci | grep -q VGA.*Intel.*855GM
161
    if [ "$?" = "0" ]; then
161
    if [ "$?" = "0" ]; then
162
	I855GM=i855gm
162
	I855GM=i855gm
163
	I855RESOLUTION=on
163
	I855RESOLUTION=on
164
    fi
164
    fi
165
fi
165
fi
166
 
166
 
167
 
167
 
168
### -----------------------------------------------------------
168
### -----------------------------------------------------------
169
### Main
169
### Main
170
### -----------------------------------------------------------
170
### -----------------------------------------------------------
171
 
171
 
172
### try load fuse kernel module
172
### try load fuse kernel module
173
modprobe fuse 2>/dev/null
173
modprobe fuse 2>/dev/null
174
 
174
 
175
### activate SWAP
175
### activate SWAP
176
# delete all swap lines in fstab
176
# delete all swap lines in fstab
177
 sed -i -e "/ swap /d" /etc/fstab
177
 sed -i -e "/ swap /d" /etc/fstab
178
# search for swap partition
178
# search for swap partition
179
fdisk -l > /var/log/fdisk
179
fdisk -l > /var/log/fdisk
180
swap_part=$( fdisk -l 2>/dev/null | grep -i "Linux swap" \
180
swap_part=$( fdisk -l 2>/dev/null | grep -i "Linux swap" \
181
            | grep "^/dev/" | cut -f 1 -d " " | head -1 )
181
            | grep "^/dev/" | cut -f 1 -d " " | head -1 )
182
# add to /etc/fstab and activate SWAP
182
# add to /etc/fstab and activate SWAP
183
if [ $swap_part ] && [ ! $NOSWAP ]; then
183
if [ $swap_part ] && [ ! $NOSWAP ]; then
184
    echo "$swap_part               swap                    swap    defaults 0 0" >>/etc/fstab
184
    echo "$swap_part               swap                    swap    defaults 0 0" >>/etc/fstab
185
    # activate SWAP
185
    # activate SWAP
186
    swapoff -a
186
    swapoff -a
187
    swapon -a -e
187
    swapon -a -e
188
fi
188
fi
189
 
189
 
190
### MAC Address of eth0
190
### MAC Address of eth0
191
MAC_ETH0=$( ifconfig | grep eth0 | awk '{print $5}' )
191
MAC_ETH0=$( ifconfig | grep eth0 | awk '{print $5}' )
192
 
192
 
193
### Get CONFIG_FOLDER for this machine from NFS Server (if existing) 
193
### Get CONFIG_FOLDER for this machine from NFS Server (if existing) 
194
#   and copy it to /$MOUNTDIR
194
#   and copy it to /$MOUNTDIR
195
if [ $NFSSERVER ] && [ $CONFIG ]; then
195
if [ $NFSSERVER ] && [ $CONFIG ]; then
196
    mkdir -p /mnt/config
196
    mkdir -p /mnt/config
197
    echo "Search for configuration files on the server ..."
197
    echo "Search for configuration files on the server ..."
198
    /etc/init.d/portmap start >/dev/null
198
    /etc/init.d/portmap start >/dev/null
199
    mount -t nfs $NFSSERVER:$CONFIG /mnt/config 2>/dev/null
199
    mount -t nfs $NFSSERVER:$CONFIG /mnt/config 2>/dev/null
200
    if [ "$?" != "0" ]; then
200
    if [ "$?" != "0" ]; then
201
	echo "Could not mount $NFSSERVER:$CONFIG."
201
	echo "Could not mount $NFSSERVER:$CONFIG."
202
    else
202
    else
203
	if [ -d /mnt/config/$MAC_ETH0 ]; then
203
	if [ -d /mnt/config/$MAC_ETH0 ]; then
204
	    CONFIG_FOLDER=/$MOUNTDIR/config
204
	    CONFIG_FOLDER=/$MOUNTDIR/config
205
	    mkdir -p $CONFIG_FOLDER
205
	    mkdir -p $CONFIG_FOLDER
206
	    cp -a /mnt/config/$MAC_ETH0/* /$CONFIG_FOLDER/ 2>/dev/null
206
	    cp -a /mnt/config/$MAC_ETH0/* /$CONFIG_FOLDER/ 2>/dev/null
207
	    if [ "$?" != "0" ]; then
207
	    if [ "$?" != "0" ]; then
208
		echo "Could not get $NFSSERVER:$CONFIG/$MAC_ETH0"
208
		echo "Could not get $NFSSERVER:$CONFIG/$MAC_ETH0"
209
		CONFIG_FOLDER=""
209
		CONFIG_FOLDER=""
210
	    else
210
	    else
211
		echo "Found configuration files on the server." 
211
		echo "Found configuration files on the server." 
212
	    fi	    
212
	    fi	    
213
	fi
213
	fi
214
	umount /mnt/config
214
	umount /mnt/config
215
    fi
215
    fi
216
    /etc/init.d/portmap stop >/dev/null
216
    /etc/init.d/portmap stop >/dev/null
217
fi
217
fi
218
 
218
 
219
### search for partitions and update fstab 
219
### search for partitions and update fstab 
220
### and look for $SAVEFOLDER (previously stored data)
220
### and look for $SAVEFOLDER (previously stored data)
221
if [ ! $FASTBOOT ] && [ ! $NOFSTAB ]; then
221
if [ ! $FASTBOOT ] && [ ! $NOFSTAB ]; then
222
    echo "Update /etc/fstab ..."
222
    echo "Update /etc/fstab ..."
223
    # disable kernel messages during mount/unmount
223
    # disable kernel messages during mount/unmount
224
    echo 0 > /proc/sys/kernel/printk
224
    echo 0 > /proc/sys/kernel/printk
225
    DEVICES=$( list_partition_devices )
225
    DEVICES=$( list_partition_devices )
226
    for DEVICE in $DEVICES; do
226
    for DEVICE in $DEVICES; do
227
        # try to mount the device and unmount it. 
227
        # try to mount the device and unmount it. 
228
        # If OK, we can add it to fstab
228
        # If OK, we can add it to fstab
229
	DEV=$( echo $DEVICE | cut -d"/" -f 3 )
229
	DEV=$( echo $DEVICE | cut -d"/" -f 3 )
230
	if [ $DEV ]; then
230
	if [ $DEV ]; then
231
	    mkdir -p /mnt/$DEV
231
	    mkdir -p /mnt/$DEV
232
	    mount $DEVICE /mnt/$DEV >/dev/null 2>&1
232
	    mount $DEVICE /mnt/$DEV >/dev/null 2>&1
233
	    # search for $SAVEFOLDER
233
	    # search for $SAVEFOLDER
234
	    if [ -d /mnt/$DEV/$SAVEFOLDER ]; then
234
	    if [ -d /mnt/$DEV/$SAVEFOLDER ]; then
235
		FOUND_RESTORE_DEV=/dev/$DEV
235
		FOUND_RESTORE_DEV=/dev/$DEV
236
		echo "Found folder '$SAVEFOLDER' on $FOUND_RESTORE_DEV"
236
		echo "Found folder '$SAVEFOLDER' on $FOUND_RESTORE_DEV"
237
	    fi
237
	    fi
238
	    # unmount again
238
	    # unmount again
239
	    umount /mnt/$DEV >/dev/null 2>&1
239
	    umount /mnt/$DEV >/dev/null 2>&1
240
	    # if sucsessful add to fstab, if not already done
240
	    # if sucsessful add to fstab, if not already done
241
	    if [ "$?" = "0" ]; then
241
	    if [ "$?" = "0" ]; then
242
		grep -q "^$DEVICE " /etc/fstab
242
		grep -q "^$DEVICE " /etc/fstab
243
		if [ "$?" != "0" ]; then
243
		if [ "$?" != "0" ]; then
244
		    echo -e "$DEVICE \t /mnt/$DEV \t auto \t $MOUNTOPT,suid,dev,exec 0 0" >> /etc/fstab
244
		    echo -e "$DEVICE \t /mnt/$DEV \t auto \t $MOUNTOPT,suid,dev,exec 0 0" >> /etc/fstab
245
		fi
245
		fi
246
	    else
246
	    else
247
		rmdir /mnt/$DEV 2>/dev/null
247
		rmdir /mnt/$DEV 2>/dev/null
248
	    fi
248
	    fi
249
	fi
249
	fi
250
    done
250
    done
251
    # enable kernel messages again
251
    # enable kernel messages again
252
    echo 6 > /proc/sys/kernel/printk
252
    echo 6 > /proc/sys/kernel/printk
253
fi
253
fi
254
 
254
 
255
### if $SAVEFOLDER found, set $CONFIG_FOLDER and mount $FOUND_RESTORE_MNT 
255
### if $SAVEFOLDER found, set $CONFIG_FOLDER and mount $FOUND_RESTORE_MNT 
256
if [ $FOUND_RESTORE_DEV ]; then
256
if [ $FOUND_RESTORE_DEV ]; then
257
    FOUND_RESTORE_MNT=$( grep "^$FOUND_RESTORE_DEV " /etc/fstab | awk '{ print $2 }' )
257
    FOUND_RESTORE_MNT=$( grep "^$FOUND_RESTORE_DEV " /etc/fstab | awk '{ print $2 }' )
258
    CONFIG_FOLDER=$FOUND_RESTORE_MNT/$SAVEFOLDER
258
    CONFIG_FOLDER=$FOUND_RESTORE_MNT/$SAVEFOLDER
259
    echo "Will restore data from $CONFIG_FOLDER"
259
    echo "Will restore data from $CONFIG_FOLDER"
260
    mount $FOUND_RESTORE_MNT
260
    mount $FOUND_RESTORE_MNT
261
fi
261
fi
262
 
262
 
263
### source the file "config", if found in $CONFIG_FOLDER
263
### source the file "config", if found in $CONFIG_FOLDER
264
if [ -f $CONFIG_FOLDER/config ]; then
264
if [ -f $CONFIG_FOLDER/config ]; then
265
    . $CONFIG_FOLDER/config
265
    . $CONFIG_FOLDER/config
266
fi
266
fi
267
 
267
 
268
### do we have a shadow/passwd file in $FOUND_FOULDER 
268
### do we have a shadow/passwd file in $FOUND_FOULDER 
269
if [ -r $CONFIG_FOLDER/passwd.tar.gz ] && [ -r $CONFIG_FOLDER/shadow.tar.gz ]; then
269
if [ -r $CONFIG_FOLDER/passwd.tar.gz ] && [ -r $CONFIG_FOLDER/shadow.tar.gz ]; then
270
    # we do not need a password for local user and root
270
    # we do not need a password for local user and root
271
    NOLOCAL=nolocal
271
    NOLOCAL=nolocal
272
    NOROOT=noroot
272
    NOROOT=noroot
273
fi
273
fi
274
 
274
 
275
### set local user name and default hostname
275
### set local user name and default hostname
276
if [ $PSI ]; then
276
if [ $PSI ]; then
277
    [ $LOCALUSER ] || LOCALUSER=l_psi
277
    [ $LOCALUSER ] || LOCALUSER=l_psi
278
    DEFAULT_HOSTNAME=psi
278
    DEFAULT_HOSTNAME=psi
279
else
279
else
280
    [ $LOCALUSER ] || LOCALUSER=sluser
280
    [ $LOCALUSER ] || LOCALUSER=sluser
281
    DEFAULT_HOSTNAME=slinux
281
    DEFAULT_HOSTNAME=slinux
282
fi
282
fi
283
 
283
 
284
### start 855resolution?
284
### start 855resolution?
285
[ $I855RESOLUTION ] && /etc/init.d/855resolution start 2>/dev/null
285
[ $I855RESOLUTION ] && /etc/init.d/855resolution start 2>/dev/null
286
 
286
 
287
### start 915resolution?
287
### start 915resolution?
288
[ $I915RESOLUTION ] && /etc/init.d/915resolution start 2>/dev/null
288
[ $I915RESOLUTION ] && /etc/init.d/915resolution start 2>/dev/null
289
 
289
 
290
### configure Xserver
290
### configure Xserver
291
 
291
 
292
### check for xorg.conf in CONFIG_FOLDER
292
### check for xorg.conf in CONFIG_FOLDER
293
if [ -r $CONFIG_FOLDER/xorg.conf ]; then
293
if [ -r $CONFIG_FOLDER/xorg.conf ]; then
294
    cp -af $CONFIG_FOLDER/xorg.conf /etc/X11/xorg.conf
294
    cp -af $CONFIG_FOLDER/xorg.conf /etc/X11/xorg.conf
295
    if [ "$?" = "0" ]; then
295
    if [ "$?" = "0" ]; then
296
	echo "Saved xorg.conf file found."
296
	echo "Saved xorg.conf file found."
297
	XDRIVER=""
297
	XDRIVER=""
298
	HAVE_XORG_CONF="yes"
298
	HAVE_XORG_CONF="yes"
299
    fi
299
    fi
300
fi
300
fi
301
 
301
 
302
### use vesa driver?
302
### use vesa driver?
303
if [ $VESA ]; then
303
if [ $VESA ]; then
304
    echo "Force to use VESA driver!"
304
    echo "Force to use VESA driver!"
305
    video_driver="--set-driver=vesa"
305
    video_driver="--set-driver=vesa"
306
else
306
else
307
    video_driver=""
307
    video_driver=""
308
fi
308
fi
309
 
309
 
310
### force an other video driver?
310
### force an other video driver?
311
if [ $XDRIVER ]; then
311
if [ $XDRIVER ]; then
312
    echo "Force to use $XDRIVER driver!"
312
    echo "Force to use $XDRIVER driver!"
313
    video_driver="--set-driver=$XDRIVER"
313
    video_driver="--set-driver=$XDRIVER"
314
fi
314
fi
315
 
315
 
316
### run system-config-display
316
### run system-config-display
317
if [ -x /usr/bin/system-config-display ]; then
317
if [ -x /usr/bin/system-config-display ]; then
318
    echo "Configure Xserver:"
318
    echo "Configure Xserver:"
319
    if [ ! $HAVE_XORG_CONF ]; then
319
    if [ ! $HAVE_XORG_CONF ]; then
320
	if [ ! $SIMPLEX ]; then
320
	if [ ! $SIMPLEX ]; then
321
            # default values
321
            # default values
322
	    [ ! $HSYNC ] && HSYNC="30.0-80.0"
322
	    [ ! $HSYNC ] && HSYNC="30.0-80.0"
323
	    [ ! $VSYNC ] && VSYNC="50.0-90.0"
323
	    [ ! $VSYNC ] && VSYNC="50.0-90.0"
324
	    [ ! $SCREEN ] && SCREEN="1280x1024"
324
	    [ ! $SCREEN ] && SCREEN="1280x1024"
325
    
325
    
326
	    system-config-display \
326
	    system-config-display \
327
		--reconfig \
327
		--reconfig \
328
                -v \
328
                -v \
329
		--set-resolution=$SCREEN \
329
		--set-resolution=$SCREEN \
330
		--set-hsync=$HSYNC \
330
		--set-hsync=$HSYNC \
331
		--set-vsync=$VSYNC \
331
		--set-vsync=$VSYNC \
332
		$video_driver | grep Trying
332
		$video_driver | grep Trying
333
	else
333
	else
334
	    echo "Use simple Xserver configuration."
334
	    echo "Use simple Xserver configuration."
335
	    system-config-display --noui --reconfig -v | grep Trying
335
	    system-config-display --noui --reconfig -v | grep Trying
336
	fi
336
	fi
337
    fi
337
    fi
338
fi
338
fi
339
 
339
 
340
### enable NVIDIA driver (needs nvidia, nvidia-libs rpms)
340
### enable NVIDIA driver (needs nvidia, nvidia-libs rpms)
341
if [ $NVIDIA ] && [ ! $NONVIDIA ]; then
341
if [ $NVIDIA ] && [ ! $NONVIDIA ]; then
342
    # serach for Nvidia Video Card
342
    # serach for Nvidia Video Card
343
    /sbin/lspci | grep VGA | grep -i -q nvidia
343
    /sbin/lspci | grep VGA | grep -i -q nvidia
344
    if [ "$?" = "0" ]; then
344
    if [ "$?" = "0" ]; then
345
	# lib or lib64 ?
345
	# lib or lib64 ?
346
	LIB=lib
346
	LIB=lib
347
	[ $( arch ) = "x86_64" ] && LIB=lib64
347
	[ $( arch ) = "x86_64" ] && LIB=lib64
348
	# find out installed Nvidia driver version
348
	# find out installed Nvidia driver version
349
	libglx=$( ls /usr/X11R6/$LIB/modules/extensions/libglx.so.1.* | head -n 1 )
349
	libglx=$( ls /usr/X11R6/$LIB/modules/extensions/libglx.so.1.* | head -n 1 )
350
	nvidia_version=${libglx##*.so.1.}
350
	nvidia_version=${libglx##*.so.1.}
351
	# enable Nvidia driver (normally done by nvidia-enable - does not work on LiveCD)
351
	# enable Nvidia driver (normally done by nvidia-enable - does not work on LiveCD)
352
	echo -n "NVIDIA graphic card found. Enable the nvidia driver ${nvidia_version} ... " 
352
	echo -n "NVIDIA graphic card found. Enable the nvidia driver ${nvidia_version} ... " 
353
	NVLOG=/var/log/nvidia.log
353
	NVLOG=/var/log/nvidia.log
354
	# assuming that the kernel modules are already build 
354
	# assuming that the kernel modules are already build 
355
	# link to Nvidia libs
355
	# link to Nvidia libs
356
	ln -sf ../../usr/X11R6/$LIB/libGL.so.1.${nvidia_version} /usr/$LIB/libGL.so
356
	ln -sf ../../usr/X11R6/$LIB/libGL.so.1.${nvidia_version} /usr/$LIB/libGL.so
357
	ln -sf libGL.so.1.${nvidia_version} /usr/X11R6/$LIB/libGL.so
357
	ln -sf libGL.so.1.${nvidia_version} /usr/X11R6/$LIB/libGL.so
358
	rm -f /usr/X11R6/$LIB/modules/extensions/libGLcore.a 
358
	rm -f /usr/X11R6/$LIB/modules/extensions/libGLcore.a 
359
	rm -f /usr/X11R6/$LIB/modules/extensions/libglx.a
359
	rm -f /usr/X11R6/$LIB/modules/extensions/libglx.a
360
	ln -sf libglx.so.1.${nvidia_version} /usr/X11R6/$LIB/modules/extensions/libglx.so
360
	ln -sf libglx.so.1.${nvidia_version} /usr/X11R6/$LIB/modules/extensions/libglx.so
361
	# reconfigure X
361
	# reconfigure X
362
	/usr/sbin/nvidia-xconfig >> $NVLOG 2>&1
362
	/usr/sbin/nvidia-xconfig >> $NVLOG 2>&1
363
	if [ $PSI ]; then
363
	if [ $PSI ]; then
364
	    echo 'NVIDIA=on' >> /etc/sysconfig/cfengine
364
	    echo 'NVIDIA=on' >> /etc/sysconfig/cfengine
365
	fi
365
	fi
366
	echo "ok."
366
	echo "ok."
367
    fi
367
    fi
368
fi
368
fi
369
 
369
 
370
### set special video driver options for Intel Mobile
370
### set special video driver options for Intel Mobile
371
 
371
 
372
#   (external VGA output: Clone)
372
#   (external VGA output: Clone)
373
if [ $I915GM ] || [ $I855GM ]; then
373
if [ $I915GM ] || [ $I855GM ]; then
374
    sed -e "/Section[ \t]*\"Device\"/,/EndSection/{
374
    sed -e "/Section[ \t]*\"Device\"/,/EndSection/{
375
     /^[ \t]*Option[ \t]*\"MonitorLayout\"/d
375
     /^[ \t]*Option[ \t]*\"MonitorLayout\"/d
376
     /^[ \t]*Option[ \t]*\"Clone/d
376
     /^[ \t]*Option[ \t]*\"Clone/d
377
     /EndSection/i\\
377
     /EndSection/i\\
378
        Option      \"MonitorLayout\" \"CRT,LFP\"\\
378
        Option      \"MonitorLayout\" \"CRT,LFP\"\\
379
        Option      \"Clone\" \"1\"\\
379
        Option      \"Clone\" \"1\"\\
380
        Option      \"CloneRefresh\" \"60\"
380
        Option      \"CloneRefresh\" \"60\"
381
     }" -i /etc/X11/xorg.conf
381
     }" -i /etc/X11/xorg.conf
382
fi
382
fi
383
 
383
 
384
# Set BoardName for Intel 915GM
384
# Set BoardName for Intel 915GM
385
if [ $I915GM ]; then
385
if [ $I915GM ]; then
386
    sed -i 's/BoardName.*VESA driver.*/BoardName   "Intel 915"/' /etc/X11/xorg.conf
386
    sed -i 's/BoardName.*VESA driver.*/BoardName   "Intel 915"/' /etc/X11/xorg.conf
387
fi
387
fi
388
 
388
 
389
 
389
 
390
### parameter KB = KEYBOARD
390
### parameter KB = KEYBOARD
391
KEYBOARD=$KB
391
KEYBOARD=$KB
392
 
392
 
393
### ask user for keyboard layout if no keyboard given
393
### ask user for keyboard layout if no keyboard given
394
if [ -x /usr/bin/system-config-keyboard ]; then
394
if [ -x /usr/bin/system-config-keyboard ]; then
395
    if [ ! $KEYBOARD ]; then
395
    if [ ! $KEYBOARD ]; then
396
	MORE_LAYOUTS="more..."
396
	MORE_LAYOUTS="more..."
397
	keytables="U.S...........(us) \
397
	keytables="U.S...........(us) \
398
	           Swiss-German..(sg-latin1) \
398
	           Swiss-German..(sg-latin1) \
399
                   Swiss-French..(fr_CH-latin1) \
399
                   Swiss-French..(fr_CH-latin1) \
400
                   German........(de-latin1) \
400
                   German........(de-latin1) \
401
                   Japanese......(jp106) \
401
                   Japanese......(jp106) \
402
                   $MORE_LAYOUTS"
402
                   $MORE_LAYOUTS"
403
	PS3="-> "
403
	PS3="-> "
404
	echo
404
	echo
405
	echo "Please choose keyboard layout (type 1-6):"
405
	echo "Please choose keyboard layout (type 1-6):"
406
	select KEYBOARD in $keytables;
406
	select KEYBOARD in $keytables;
407
	  do
407
	  do
408
	     case $KEYBOARD in
408
	     case $KEYBOARD in
409
	        *)
409
	        *)
410
	        # extract keyboard layout string from $KEYBOARD
410
	        # extract keyboard layout string from $KEYBOARD
411
	        KEYBOARD=${KEYBOARD##*(}
411
	        KEYBOARD=${KEYBOARD##*(}
412
                KEYBOARD=${KEYBOARD%%)}
412
                KEYBOARD=${KEYBOARD%%)}
413
                break
413
                break
414
                ;;
414
                ;;
415
	     esac
415
	     esac
416
	  done
416
	  done
417
    fi
417
    fi
418
fi
418
fi
419
 
419
 
420
### set keyboard
420
### set keyboard
421
if [ -x /usr/bin/system-config-keyboard ]; then
421
if [ -x /usr/bin/system-config-keyboard ]; then
422
    if [ "$KEYBOARD" = "$MORE_LAYOUTS" ]; then
422
    if [ "$KEYBOARD" = "$MORE_LAYOUTS" ]; then
423
	system-config-keyboard --text
423
	system-config-keyboard --text
424
    else
424
    else
425
	echo -n "Set keyboard to '$KEYBOARD', please wait ... "
425
	echo -n "Set keyboard to '$KEYBOARD', please wait ... "
426
	system-config-keyboard --noui $KEYBOARD >/dev/null 2>&1
426
	system-config-keyboard --noui $KEYBOARD >/dev/null 2>&1
427
	echo "done."
427
	echo "done."
428
    fi
428
    fi
429
    echo
429
    echo
430
fi
430
fi
431
 
431
 
432
### update AFS users and SEPP links (only for PSI)
432
### update AFS users and SEPP links (only for PSI)
433
if [ $PSI ] && [ $AFS ]; then
433
if [ $PSI ] && [ $AFS ]; then
434
    echo "Update AFS users and SEPP links..."
434
    echo "Update AFS users and SEPP links..."
435
    [ -x /afs/psi.ch/sys/common/update_user.pl ] && /afs/psi.ch/sys/common/update_user.pl >/dev/null 2>&1 &
435
    [ -x /afs/psi.ch/sys/common/update_user.pl ] && /afs/psi.ch/sys/common/update_user.pl >/dev/null 2>&1 &
436
    [ -x /afs/psi.ch/sys/common/update_sepp.pl ] && /afs/psi.ch/sys/common/update_sepp.pl >/dev/null 2>&1 &
436
    [ -x /afs/psi.ch/sys/common/update_sepp.pl ] && /afs/psi.ch/sys/common/update_sepp.pl >/dev/null 2>&1 &
437
    echo
437
    echo
438
fi
438
fi
439
 
439
 
440
### create local user, if "nolocal" is not set 
440
### create local user, if "nolocal" is not set 
441
if [ ! $NOLOCAL ]; then
441
if [ ! $NOLOCAL ]; then
442
 
442
 
443
    user=$LOCALUSER
443
    user=$LOCALUSER
444
    # execute useradd twice, to make it work (don't know why)
444
    # execute useradd twice, to make it work (don't know why)
445
    if [ $PSI ] && [ ! $NOADMIN ]; then
445
    if [ $PSI ] && [ ! $NOADMIN ]; then
446
	userdel -r $user 2>/dev/null
446
	userdel -r $user 2>/dev/null
447
	useradd -G $LocalAdminGroup $user 2>/dev/null
447
	useradd -G $LocalAdminGroup $user 2>/dev/null
448
	userdel -r $user 2>/dev/null
448
	userdel -r $user 2>/dev/null
449
	useradd -G $LocalAdminGroup $user
449
	useradd -G $LocalAdminGroup $user
450
    else
450
    else
451
	userdel -r $user 2>/dev/null
451
	userdel -r $user 2>/dev/null
452
	useradd $user 2>/dev/null
452
	useradd $user 2>/dev/null
453
	userdel -r $user 2>/dev/null
453
	userdel -r $user 2>/dev/null
454
	useradd $user
454
	useradd $user
455
    fi
455
    fi
456
 
456
 
457
    # only for PSI: change users's group to GID=UID+50000
457
    # only for PSI: change users's group to GID=UID+50000
458
    if [ $PSI ]; then
458
    if [ $PSI ]; then
459
	uid=$( id -u $user )
459
	uid=$( id -u $user )
460
	old_gid=$( id -g $user )
460
	old_gid=$( id -g $user )
461
	new_gid=$(( $old_gid + 50000 ))
461
	new_gid=$(( $old_gid + 50000 ))
462
        # fix /etc/group
462
        # fix /etc/group
463
	sed -i "s/${user}:x:${old_gid}:/${user}:x:${new_gid}:/" /etc/group
463
	sed -i "s/${user}:x:${old_gid}:/${user}:x:${new_gid}:/" /etc/group
464
        # fix /etc/passwd
464
        # fix /etc/passwd
465
	sed -i "s/${user}:x:${uid}:${old_gid}:/${user}:x:${uid}:${new_gid}:/" /etc/passwd
465
	sed -i "s/${user}:x:${uid}:${old_gid}:/${user}:x:${uid}:${new_gid}:/" /etc/passwd
466
        # fix perm of /home/${user)
466
        # fix perm of /home/${user)
467
	chgrp -R $user /home/${user}
467
	chgrp -R $user /home/${user}
468
    fi
468
    fi
469
fi
469
fi
470
 
470
 
471
### copy special files for PSI user l_psi
471
### copy special files for PSI user l_psi
472
if [ $PSI ] && [ ! $NOLOCAL ]; then
472
if [ $PSI ] && [ ! $NOLOCAL ]; then
473
    find /usr/share/${LOCALUSER}/ -maxdepth 1 -mindepth 1 2>/dev/null | \
473
    find /usr/share/${LOCALUSER}/ -maxdepth 1 -mindepth 1 2>/dev/null | \
474
    while read dir; do 
474
    while read dir; do 
475
	cp -a $dir /home/${LOCALUSER}/
475
	cp -a $dir /home/${LOCALUSER}/
476
    done
476
    done
477
    # set owner
477
    # set owner
478
    chown -R ${LOCALUSER}.${LOCALUSER} /home/${LOCALUSER}
478
    chown -R ${LOCALUSER}.${LOCALUSER} /home/${LOCALUSER}
479
fi
479
fi
480
 
480
 
481
### set password for root and local user
481
### set password for root and local user
482
if [ ! $NOPASSWD ]; then
482
if [ ! $NOPASSWD ]; then
483
    if [ ! $NOROOT ] || [ ! $NOLOCAL ]; then
483
    if [ ! $NOROOT ] || [ ! $NOLOCAL ]; then
484
	echo -n "Set password for "
484
	echo -n "Set password for "
485
	if [ ! $NOROOT ]; then
485
	if [ ! $NOROOT ]; then
486
	    echo -n "'root' "
486
	    echo -n "'root' "
487
	fi
487
	fi
488
	if [ ! $NOROOT ] && [ ! $NOLOCAL ]; then
488
	if [ ! $NOROOT ] && [ ! $NOLOCAL ]; then
489
	    echo -n "and "
489
	    echo -n "and "
490
	fi
490
	fi
491
	if [ ! $NOLOCAL ]; then
491
	if [ ! $NOLOCAL ]; then
492
	    echo -n "local user '$user' "
492
	    echo -n "local user '$user' "
493
	fi
493
	fi
494
	echo
494
	echo
495
 
495
 
496
	if [ ! $NOLOCAL ]; then
496
	if [ ! $NOLOCAL ]; then
497
	    echo "Login as local user '$user' with this password."
497
	    echo "Login as local user '$user' with this password."
498
	    echo
498
	    echo
499
	fi
499
	fi
500
 
500
 
501
        # set password, if not yet given by $PASSWD
501
        # set password, if not yet given by $PASSWD
502
	until [ $PASSWD ]; do
502
	until [ $PASSWD ]; do
503
	    echo -n "Password: "
503
	    echo -n "Password: "
504
	    read -s PASSWD
504
	    read -s PASSWD
505
	    echo
505
	    echo
506
	done
506
	done
507
	if [ ! $NOROOT ]; then
507
	if [ ! $NOROOT ]; then
508
	    echo $PASSWD | passwd --stdin root >/dev/null
508
	    echo $PASSWD | passwd --stdin root >/dev/null
509
	fi
509
	fi
510
	if [ ! $NOLOCAL ]; then
510
	if [ ! $NOLOCAL ]; then
511
	    echo $PASSWD | passwd --stdin $user >/dev/null
511
	    echo $PASSWD | passwd --stdin $user >/dev/null
512
	fi
512
	fi
513
	echo
513
	echo
514
    fi
514
    fi
515
 
515
 
516
else
516
else
517
    # set root and $LOCALUSER to empty password
517
    # set root and $LOCALUSER to empty password
518
    sed -i "s|^root:.*|root::12345:0:99999:1:::|" /etc/shadow
518
    sed -i "s|^root:.*|root::12345:0:99999:1:::|" /etc/shadow
519
    sed -i "s|^$LOCALUSER:.*|$LOCALUSER::12345:0:99999:1:::|" /etc/shadow
519
    sed -i "s|^$LOCALUSER:.*|$LOCALUSER::12345:0:99999:1:::|" /etc/shadow
520
fi
520
fi
521
 
521
 
522
### try to get hostname from DNS, if not yet defined
522
### try to get hostname from DNS, if not yet defined
523
if [ ! $HOSTNAME ]; then
523
if [ ! $HOSTNAME ]; then
524
    echo "Try to get hostname from DNS ..."
524
    echo "Try to get hostname from DNS ..."
525
    IP=$( /sbin/ip add show dev eth0 2>/dev/null | grep "inet " | cut -d" " -f6 | sed 's|/.*||' )
525
    IP=$( /sbin/ip add show dev eth0 2>/dev/null | grep "inet " | cut -d" " -f6 | sed 's|/.*||' )
526
    if [ "$IP" = "" ]; then
526
    if [ "$IP" = "" ]; then
527
	IP=$( /sbin/ip add show dev eth1 2>/dev/null | grep "inet " | cut -d" " -f6 | sed 's|/.*||' )
527
	IP=$( /sbin/ip add show dev eth1 2>/dev/null | grep "inet " | cut -d" " -f6 | sed 's|/.*||' )
528
    fi
528
    fi
529
    if [ "$IP" != "" ]; then
529
    if [ "$IP" != "" ]; then
530
	host -W 1 $IP >/dev/null 2>&1
530
	host -W 1 $IP >/dev/null 2>&1
531
	if [ "$?" = "0" ]; then
531
	if [ "$?" = "0" ]; then
532
	    HOSTNAME=$( host -W 1 $IP | cut -d" " -f 5 | cut -d"." -f 1 )
532
	    HOSTNAME=$( host -W 1 $IP | cut -d" " -f 5 | cut -d"." -f 1 )
533
	    if [ "$HOSTNAME" = "3(NXDOMAIN)" ]; then
533
	    if [ "$HOSTNAME" = "3(NXDOMAIN)" ]; then
534
		HOSTNAME=$DEFAULT_HOSTNAME
534
		HOSTNAME=$DEFAULT_HOSTNAME
535
	    fi	
535
	    fi	
536
	    if [ "$HOSTNAME" = "no" ]; then
536
	    if [ "$HOSTNAME" = "no" ]; then
537
		HOSTNAME=$DEFAULT_HOSTNAME
537
		HOSTNAME=$DEFAULT_HOSTNAME
538
	    fi	
538
	    fi	
539
	fi
539
	fi
540
    fi
540
    fi
541
fi
541
fi
542
 
542
 
543
### define default hostname, if $HOSTNAME still not yet set
543
### define default hostname, if $HOSTNAME still not yet set
544
if [ ! $HOSTNAME ]; then
544
if [ ! $HOSTNAME ]; then
545
    HOSTNAME=$DEFAULT_HOSTNAME
545
    HOSTNAME=$DEFAULT_HOSTNAME
546
fi
546
fi
547
 
547
 
548
### set hostname
548
### set hostname
549
export HOSTNAME=$HOSTNAME
549
export HOSTNAME=$HOSTNAME
550
hostname $HOSTNAME
550
hostname $HOSTNAME
551
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
551
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
552
if [ $PSI ]; then
552
if [ $PSI ]; then
553
    sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
553
    sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
554
    sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/cfengine
554
    sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/cfengine
555
fi
555
fi
556
for iface in eth0 eth1 eth2 eth3; do
556
for iface in eth0 eth1 eth2 eth3; do
557
    if [ -e /etc/sysconfig/network-scripts/ifcfg-${iface} ]; then
557
    if [ -e /etc/sysconfig/network-scripts/ifcfg-${iface} ]; then
558
	echo "DHCP_HOSTNAME=${HOSTNAME}" >> /etc/sysconfig/network-scripts/ifcfg-${iface}
558
	echo "DHCP_HOSTNAME=${HOSTNAME}" >> /etc/sysconfig/network-scripts/ifcfg-${iface}
559
    fi
559
    fi
560
done
560
done
561
 
561
 
562
echo "Hostname set to: $HOSTNAME"
562
echo "Hostname set to: $HOSTNAME"
563
echo
563
echo
564
 
564
 
565
### set cups server
565
### set cups server
566
if [ $CUPS ]; then
566
if [ $CUPS ]; then
567
    sed -i "s|.*ServerName .*|ServerName  $CUPS|" /etc/cups/client.conf
567
    sed -i "s|.*ServerName .*|ServerName  $CUPS|" /etc/cups/client.conf
568
fi
568
fi
569
 
569
 
570
### some magic: just access this file in order that it can be sourced later
570
### some magic: just access this file in order that it can be sourced later
571
ls -lag /etc/X11/xinit/xinitrc-common >/dev/null 2>&1
571
ls -lag /etc/X11/xinit/xinitrc-common >/dev/null 2>&1
572
sleep 1
572
sleep 1
573
 
573
 
574
### set keyboard for rdesktop
574
### set keyboard for rdesktop
575
if [ -e /etc/X11/xorg.conf ]; then
575
if [ -e /etc/X11/xorg.conf ]; then
576
    grep -q de_CH /etc/X11/xorg.conf && RDESKTOP_OPT="-k de-ch"
576
    grep -q de_CH /etc/X11/xorg.conf && RDESKTOP_OPT="-k de-ch"
577
    grep -q fr_CH /etc/X11/xorg.conf && RDESKTOP_OPT="-k fr-ch"
577
    grep -q fr_CH /etc/X11/xorg.conf && RDESKTOP_OPT="-k fr-ch"
578
    grep -q jp106 /etc/X11/xorg.conf && RDESKTOP_OPT="-k ja"
578
    grep -q jp106 /etc/X11/xorg.conf && RDESKTOP_OPT="-k ja"
579
fi
579
fi
580
 
580
 
581
if [ "$RDESKTOP_OPT" ]; then
581
if [ "$RDESKTOP_OPT" ]; then
582
    echo "alias rdesktop='rdesktop $RDESKTOP_OPT'" > /etc/profile.d/rdesktop.sh
582
    echo "alias rdesktop='rdesktop $RDESKTOP_OPT'" > /etc/profile.d/rdesktop.sh
583
    echo "export RDESKTOP_OPT='$RDESKTOP_OPT'" >> /etc/profile.d/rdesktop.sh
583
    echo "export RDESKTOP_OPT='$RDESKTOP_OPT'" >> /etc/profile.d/rdesktop.sh
584
    chmod 755 /etc/profile.d/rdesktop.sh
584
    chmod 755 /etc/profile.d/rdesktop.sh
585
fi
585
fi
586
 
586
 
587
### run setup script, if found in $CONFIG_FOLDER on $FOUND_RESTORE_MNT
587
### run setup script, if found in $CONFIG_FOLDER on $FOUND_RESTORE_MNT
588
if [ -r $CONFIG_FOLDER/setup ]; then
588
if [ -r $CONFIG_FOLDER/setup ]; then
589
    CONFIG_FOLDER=$CONFIG_FOLDER bash $CONFIG_FOLDER/setup
589
    CONFIG_FOLDER=$CONFIG_FOLDER bash $CONFIG_FOLDER/setup
590
fi
590
fi
591
 
591
 
592
### umount $FOUND_RESTORE_MNT
592
### umount $FOUND_RESTORE_MNT
593
if [ $FOUND_RESTORE_MNT ]; then
593
if [ $FOUND_RESTORE_MNT ]; then
594
    echo "Unmount $FOUND_RESTORE_MNT"
594
    echo "Unmount $FOUND_RESTORE_MNT"
595
    umount $FOUND_RESTORE_MNT 2>/dev/null
595
    umount $FOUND_RESTORE_MNT 2>/dev/null
596
    sleep 3
596
    sleep 3
597
fi
597
fi
598
 
598
 
599
### local home partition?
599
### local home partition?
600
if [ $HOMELOCAL ]; then
600
if [ $HOMELOCAL ]; then
601
    mv /home /home.old
601
    mv /home /home.old
602
    mkdir -p /mnt/home_par
602
    mkdir -p /mnt/home_par
603
    # which partition? which folder?
603
    # which partition? which folder?
604
    HOMEPAR=$( echo $HOMELOCAL | cut -d":" -f1 )
604
    HOMEPAR=$( echo $HOMELOCAL | cut -d":" -f1 )
605
    HOMEDIR=$( echo $HOMELOCAL | grep ":" | cut -d":" -f2 )
605
    HOMEDIR=$( echo $HOMELOCAL | grep ":" | cut -d":" -f2 )
606
    umount $HOMEPAR 2>/dev/null
606
    umount $HOMEPAR 2>/dev/null
607
    # mount it with option noatime, healthy for USB flash drives
607
    # mount it with option noatime, healthy for USB flash drives
608
    mount -o noatime -rw $HOMEPAR /mnt/home_par 2>/dev/null
608
    mount -o noatime -rw $HOMEPAR /mnt/home_par 2>/dev/null
609
    if [ "$?" != "0" ]; then
609
    if [ "$?" != "0" ]; then
610
	echo "ERROR: Could not mount read/write $HOMEPAR"
610
	echo "ERROR: Could not mount read/write $HOMEPAR"
611
	umount $HOMEPAR >/dev/null 2&>1
611
	umount $HOMEPAR >/dev/null 2&>1
612
	mv /home.old /home
612
	mv /home.old /home
613
    else
613
    else
614
	echo "$HOMEPAR mounted on /mnt/home_par"
614
	echo "$HOMEPAR mounted on /mnt/home_par"
615
	# link to new home
615
	# link to new home
616
	ln -s /mnt/home_par/$HOMEDIR /home
616
	ln -s /mnt/home_par/$HOMEDIR /home
617
	if [ ! -d /mnt/home_par/$HOMEDIR ]; then
617
	if [ ! -d /mnt/home_par/$HOMEDIR ]; then
618
	    echo "$HOMELOCAL not found on $HOMEPAR"
618
	    echo "$HOMELOCAL not found on $HOMEPAR"
619
	    echo mkdir -p /mnt/home_par/$HOMEDIR
619
	    echo mkdir -p /mnt/home_par/$HOMEDIR
620
	    if [ "$?" != "0" ]; then
620
	    if [ "$?" != "0" ]; then
621
		echo "ERROR: Could not create $HOMELOCAL on $HOMEPAR"
621
		echo "ERROR: Could not create $HOMELOCAL on $HOMEPAR"
622
		umount $HOMEPAR >/dev/null 2&>1
622
		umount $HOMEPAR >/dev/null 2&>1
623
		rm -f /home
623
		rm -f /home
624
		mv /home.old /home
624
		mv /home.old /home
625
	    else
625
	    else
626
		echo "Folder $HOMEDIR created on $HOMEPAR"
626
		echo "Folder $HOMEDIR created on $HOMEPAR"
627
	    fi
627
	    fi
628
	fi
628
	fi
629
	if [ -d /mnt/home_par/$HOMEDIR ]; then
629
	if [ -d /mnt/home_par/$HOMEDIR ]; then
630
	    echo "/home is linked to /mnt/home_par${HOMEDIR}"
630
	    echo "/home is linked to /mnt/home_par${HOMEDIR}"
631
	    # copy files from /home.old to /home, which are not yet there
631
	    # copy files from /home.old to /home, which are not yet there
632
	    /bin/cp -a -i --reply=no /home.old/* /home/ 
632
	    /bin/cp -a -i --reply=no /home.old/* /home/ 
633
	    rm -rf /home.old
633
	    rm -rf /home.old
634
	fi
634
	fi
635
    fi
635
    fi
636
    sleep 2
636
    sleep 2
637
fi
637
fi
638
 
638
 
639
### mount all if AUTOMOUNT set
639
### mount all if AUTOMOUNT set
640
if [ $AUTOMOUNT ]; then
640
if [ $AUTOMOUNT ]; then
641
    mount -a
641
    mount -a
642
fi
642
fi
643
 
643
 
644
### unload/load sound module for snd-card-X (timing problem?)
644
### unload/load sound module for snd-card-X (timing problem?)
645
rpm -q alsa-lib | grep el5 >/dev/null
645
rpm -q alsa-lib | grep el5 >/dev/null
646
if [ "$?" = "0" ]; then
646
if [ "$?" = "0" ]; then
647
    sound_modules=$( grep snd-card- /etc/modprobe.conf | awk ' $1 ~ /alias/ { print $3 }' | tr - _ )
647
    sound_modules=$( grep snd-card- /etc/modprobe.conf | awk ' $1 ~ /alias/ { print $3 }' | tr - _ )
648
    for module in $sound_modules; do
648
    for module in $sound_modules; do
649
	lsmod | awk '{ print $1 }' | grep $module >/dev/null 2>&1
649
	lsmod | awk '{ print $1 }' | grep $module >/dev/null 2>&1
650
	if [ "$?" = "0" ]; then
650
	if [ "$?" = "0" ]; then
651
	    rmmod $module    >/dev/null 2>&1
651
	    rmmod $module    >/dev/null 2>&1
652
	    sleep 2
652
	    sleep 2
653
	    modprobe $module >/dev/null 2>&1
653
	    modprobe $module >/dev/null 2>&1
654
	fi
654
	fi
655
    done
655
    done
656
fi
656
fi
657
 
657
 
658
### unmute all mixers and set volumes
658
### unmute all mixers and set volumes
659
if [ -x /usr/bin/set-volume ]; then 
659
if [ -x /usr/bin/set-volume ]; then 
660
    if [ $NOSOUND ]; then
660
    if [ $NOSOUND ]; then
661
	/usr/bin/set-volume 0 > /var/log/set-volume.log 2>&1 &
661
	/usr/bin/set-volume 0 > /var/log/set-volume.log 2>&1 &
662
    else
662
    else
663
	/usr/bin/set-volume 60 > /var/log/set-volume.log 2>&1 &
663
	/usr/bin/set-volume 60 > /var/log/set-volume.log 2>&1 &
664
    fi
664
    fi
665
fi
665
fi
666
 
666
 
667
### set kde or gnome as desktop
667
### set kde or gnome as desktop
668
if [ $KDE ]; then
668
if [ $KDE ]; then
669
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
669
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
670
    echo "DESKTOP=KDE" >> /etc/sysconfig/desktop
670
    echo "DESKTOP=KDE" >> /etc/sysconfig/desktop
671
fi
671
fi
672
if [ $GNOME ]; then
672
if [ $GNOME ]; then
673
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
673
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
674
    echo "DESKTOP=GNOME" >> /etc/sysconfig/desktop
674
    echo "DESKTOP=GNOME" >> /etc/sysconfig/desktop
675
fi
675
fi
676
 
676
 
677
### change to runlevel 3, if NOX (bad hack)
677
### change to runlevel 3, if NOX (bad hack)
678
if [ $NOX ]; then
678
if [ $NOX ]; then
679
    init 3
679
    init 3
680
fi
680
fi
681
 
681