Subversion Repositories livecd

Rev

Rev 43 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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