Subversion Repositories livecd

Rev

Details | 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
# no X11
58
NOX=$( cmdline_parameter nox )
59
 
60
# failsafe X server
61
SIMPLEX=$( cmdline_parameter simplex )
62
 
63
# NVIDIA driver
64
NVIDIA=$( cmdline_parameter nvidia )
65
if [ "$XDRIVER" = "nvidia" ]; then
66
    NVIDIA=nvidia
67
fi
68
 
69
# force NO NVIDIA driver - will overwite NVIDIA option
70
NONVIDIA=$( cmdline_parameter nonvidia )
71
 
72
# VESA driver
73
VESA=$( cmdline_parameter vesa )
74
 
75
# force to use a video driver ?
76
XDRIVER=$( cmdline_value xdriver )
77
 
78
# Xserver configurations
79
HSYNC=$( cmdline_value hsync )
80
VSYNC=$( cmdline_value vsync )
81
SCREEN=$( cmdline_value screen )
82
 
83
# no SWAP
84
NOSWAP=$( cmdline_parameter noswap )
85
 
86
# should we auto mount all found devices?
87
AUTOMOUNT=$( cmdline_parameter automount )
88
if [ $AUTOMOUNT ]; then
89
    MOUNTOPT="auto,users"
90
else
91
    MOUNTOPT="noauto,users,ro"
92
fi
93
 
94
# folder where we find data which was previously stored
95
# (normally on a usbstick, but can be partition)
96
if [ $PSI ]; then
97
    SAVEFOLDER=PSI_LIVECD
98
else
99
    SAVEFOLDER=SL_LIVECD
100
fi
101
 
102
# local home partition?
103
# (e.g. /dev/hda1, /dev/hda1:/my_home)
104
HOMELOCAL=$( cmdline_value home )
105
 
106
# fast booting ?
107
FASTBOOT=$( cmdline_parameter fastboot )
108
 
109
# start afs?
110
AFS=$( cmdline_parameter afs )
111
 
112
# or force no afs
113
[ $( cmdline_parameter noafs ) ] && AFS=""
114
 
115
# turn of sound (volume=0)
116
NOSOUND=$( cmdline_parameter nosound )
117
 
118
# local user name?
119
LOCALUSER=$( cmdline_value user )
120
 
121
# hostname?
122
HOSTNAME=$( cmdline_value hostname )
123
 
124
# do we have defined a configuration directory?
125
CONFIG=$( cmdline_value config )
126
 
127
# do not udpate fstab?
128
NOFSTAB=$( cmdline_parameter nofstab )
129
 
130
# kde/gnome as desktop
131
GNOME=$( cmdline_parameter gnome )
132
KDE=$( cmdline_parameter kde )
133
 
134
 
135
### -----------------------------------------------------------
136
### Improved hardware detection
137
### -----------------------------------------------------------
138
 
139
### Improved graphic card detection?
140
 
141
if [ ! $SIMPLEX ]; then
142
 
143
    ### Intel Mobile 945GM
144
    lspci | grep -q VGA.*Intel.*Mobile.*945GM
145
    if [ "$?" = "0" ]; then
146
	I945GM=i945gm
147
	## not yet supported by i810 driver
148
        ## [ $XDRIVER ] || XDRIVER=i810
149
	I915RESOLUTION=on
150
    fi
151
    ### Intel Mobile 915GM
152
    lspci | grep -q VGA.*Intel.*Mobile.*915GM
153
    if [ "$?" = "0" ]; then
154
	I915GM=i915gm
155
	[ $XDRIVER ] || XDRIVER=i810
156
	I855RESOLUTION=on
157
    fi
158
 
159
    ### Intel Mobile 855GM
160
    lspci | grep -q VGA.*Intel.*855GM
161
    if [ "$?" = "0" ]; then
162
	I855GM=i855gm
163
	I855RESOLUTION=on
164
    fi
165
fi
166
 
167
 
168
### -----------------------------------------------------------
169
### Main
170
### -----------------------------------------------------------
171
 
172
### try load fuse kernel module
173
modprobe fuse 2>/dev/null
174
 
175
### activate SWAP
176
# delete all swap lines in fstab
177
 sed -i -e "/ swap /d" /etc/fstab
178
# search for swap partition
179
fdisk -l > /var/log/fdisk
180
swap_part=$( fdisk -l 2>/dev/null | grep -i "Linux swap" \
181
            | grep "^/dev/" | cut -f 1 -d " " | head -1 )
182
# add to /etc/fstab and activate SWAP
183
if [ $swap_part ] && [ ! $NOSWAP ]; then
184
    echo "$swap_part               swap                    swap    defaults 0 0" >>/etc/fstab
185
    # activate SWAP
186
    swapoff -a
187
    swapon -a -e
188
fi
189
 
190
### MAC Address of eth0
191
MAC_ETH0=$( ifconfig | grep eth0 | awk '{print $5}' )
192
 
193
### Get CONFIG_FOLDER for this machine from NFS Server (if existing) 
194
#   and copy it to /$MOUNTDIR
195
if [ $NFSSERVER ] && [ $CONFIG ]; then
196
    mkdir -p /mnt/config
197
    echo "Search for configuration files on the server ..."
198
    /etc/init.d/portmap start >/dev/null
199
    mount -t nfs $NFSSERVER:$CONFIG /mnt/config 2>/dev/null
200
    if [ "$?" != "0" ]; then
201
	echo "Could not mount $NFSSERVER:$CONFIG."
202
    else
203
	if [ -d /mnt/config/$MAC_ETH0 ]; then
204
	    CONFIG_FOLDER=/$MOUNTDIR/config
205
	    mkdir -p $CONFIG_FOLDER
206
	    cp -a /mnt/config/$MAC_ETH0/* /$CONFIG_FOLDER/ 2>/dev/null
207
	    if [ "$?" != "0" ]; then
208
		echo "Could not get $NFSSERVER:$CONFIG/$MAC_ETH0"
209
		CONFIG_FOLDER=""
210
	    else
211
		echo "Found configuration files on the server." 
212
	    fi	    
213
	fi
214
	umount /mnt/config
215
    fi
216
    /etc/init.d/portmap stop >/dev/null
217
fi
218
 
219
### search for partitions and update fstab 
220
### and look for $SAVEFOLDER (previously stored data)
221
if [ ! $FASTBOOT ] && [ ! $NOFSTAB ]; then
222
    echo "Update /etc/fstab ..."
223
    # disable kernel messages during mount/unmount
224
    echo 0 > /proc/sys/kernel/printk
225
    DEVICES=$( list_partition_devices )
226
    for DEVICE in $DEVICES; do
227
        # try to mount the device and unmount it. 
228
        # If OK, we can add it to fstab
229
	DEV=$( echo $DEVICE | cut -d"/" -f 3 )
230
	if [ $DEV ]; then
231
	    mkdir -p /mnt/$DEV
232
	    mount $DEVICE /mnt/$DEV >/dev/null 2>&1
233
	    # search for $SAVEFOLDER
234
	    if [ -d /mnt/$DEV/$SAVEFOLDER ]; then
235
		FOUND_RESTORE_DEV=/dev/$DEV
236
		echo "Found folder '$SAVEFOLDER' on $FOUND_RESTORE_DEV"
237
	    fi
238
	    # unmount again
239
	    umount /mnt/$DEV >/dev/null 2>&1
240
	    # if sucsessful add to fstab, if not already done
241
	    if [ "$?" = "0" ]; then
242
		grep -q "^$DEVICE " /etc/fstab
243
		if [ "$?" != "0" ]; then
244
		    echo -e "$DEVICE \t /mnt/$DEV \t auto \t $MOUNTOPT,suid,dev,exec 0 0" >> /etc/fstab
245
		fi
246
	    else
247
		rmdir /mnt/$DEV 2>/dev/null
248
	    fi
249
	fi
250
    done
251
    # enable kernel messages again
252
    echo 6 > /proc/sys/kernel/printk
253
fi
254
 
255
### if $SAVEFOLDER found, set $CONFIG_FOLDER and mount $FOUND_RESTORE_MNT 
256
if [ $FOUND_RESTORE_DEV ]; then
257
    FOUND_RESTORE_MNT=$( grep "^$FOUND_RESTORE_DEV " /etc/fstab | awk '{ print $2 }' )
258
    CONFIG_FOLDER=$FOUND_RESTORE_MNT/$SAVEFOLDER
259
    echo "Will restore data from $CONFIG_FOLDER"
260
    mount $FOUND_RESTORE_MNT
261
fi
262
 
263
### source the file "config", if found in $CONFIG_FOLDER
264
if [ -f $CONFIG_FOLDER/config ]; then
265
    . $CONFIG_FOLDER/config
266
fi
267
 
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
270
    # we do not need a password for local user and root
271
    NOLOCAL=nolocal
272
    NOROOT=noroot
273
fi
274
 
275
### set local user name and default hostname
276
if [ $PSI ]; then
277
    [ $LOCALUSER ] || LOCALUSER=l_psi
278
    DEFAULT_HOSTNAME=psi
279
else
280
    [ $LOCALUSER ] || LOCALUSER=sluser
281
    DEFAULT_HOSTNAME=slinux
282
fi
283
 
284
### start 855resolution?
285
[ $I855RESOLUTION ] && /etc/init.d/855resolution start 2>/dev/null
286
 
287
### start 915resolution?
288
[ $I915RESOLUTION ] && /etc/init.d/915resolution start 2>/dev/null
289
 
290
### configure Xserver
291
 
292
### check for xorg.conf in CONFIG_FOLDER
293
if [ -r $CONFIG_FOLDER/xorg.conf ]; then
294
    cp -af $CONFIG_FOLDER/xorg.conf /etc/X11/xorg.conf
295
    if [ "$?" = "0" ]; then
296
	echo "Saved xorg.conf file found."
297
	XDRIVER=""
298
	HAVE_XORG_CONF="yes"
299
    fi
300
fi
301
 
302
### use vesa driver?
303
if [ $VESA ]; then
304
    echo "Force to use VESA driver!"
305
    video_driver="--set-driver=vesa"
306
else
307
    video_driver=""
308
fi
309
 
310
### force an other video driver?
311
if [ $XDRIVER ]; then
312
    echo "Force to use $XDRIVER driver!"
313
    video_driver="--set-driver=$XDRIVER"
314
fi
315
 
316
### run system-config-display
317
if [ -x /usr/bin/system-config-display ]; then
318
    echo "Configure Xserver:"
319
    if [ ! $HAVE_XORG_CONF ]; then
320
	if [ ! $SIMPLEX ]; then
321
            # default values
322
	    [ ! $HSYNC ] && HSYNC="30.0-80.0"
323
	    [ ! $VSYNC ] && VSYNC="50.0-90.0"
324
	    [ ! $SCREEN ] && SCREEN="1280x1024"
325
 
326
	    system-config-display \
327
		--reconfig \
328
		--set-resolution=$SCREEN \
329
		--set-hsync=$HSYNC \
330
		--set-vsync=$VSYNC \
9 beyerle@PS 331
		$video_driver
1 beyerle@PS 332
	else
333
	    echo "Use simple Xserver configuration."
9 beyerle@PS 334
	    system-config-display --noui --reconfig
1 beyerle@PS 335
	fi
336
    fi
337
fi
338
 
339
### enable NVIDIA driver (needs nvidia, nvidia-libs rpms)
340
if [ $NVIDIA ] && [ ! $NONVIDIA ]; then
341
    # serach for Nvidia Video Card
342
    /sbin/lspci | grep VGA | grep -i -q nvidia
343
    if [ "$?" = "0" ]; then
344
	# lib or lib64 ?
345
	LIB=lib
346
	[ $( arch ) = "x86_64" ] && LIB=lib64
347
	# find out installed Nvidia driver version
348
	libglx=$( ls /usr/X11R6/$LIB/modules/extensions/libglx.so.1.* | head -n 1 )
349
	nvidia_version=${libglx##*.so.1.}
350
	# enable Nvidia driver (normally done by nvidia-enable - does not work on LiveCD)
351
	echo -n "NVIDIA graphic card found. Enable the nvidia driver ${nvidia_version} ... " 
352
	NVLOG=/var/log/nvidia.log
353
	# assuming that the kernel modules are already build 
354
	# link to Nvidia libs
355
	ln -sf ../../usr/X11R6/$LIB/libGL.so.1.${nvidia_version} /usr/$LIB/libGL.so
356
	ln -sf libGL.so.1.${nvidia_version} /usr/X11R6/$LIB/libGL.so
357
	rm -f /usr/X11R6/$LIB/modules/extensions/libGLcore.a 
358
	rm -f /usr/X11R6/$LIB/modules/extensions/libglx.a
359
	ln -sf libglx.so.1.${nvidia_version} /usr/X11R6/$LIB/modules/extensions/libglx.so
360
	# reconfigure X
361
	/usr/sbin/nvidia-xconfig >> $NVLOG 2>&1
362
	if [ $PSI ]; then
363
	    echo 'NVIDIA=on' >> /etc/sysconfig/cfengine
364
	fi
365
	echo "ok."
366
    fi
367
fi
368
 
369
### set special video driver options for Intel Mobile
370
 
371
#   (external VGA output: Clone)
372
if [ $I915GM ] || [ $I855GM ]; then
373
    sed -e "/Section[ \t]*\"Device\"/,/EndSection/{
374
     /^[ \t]*Option[ \t]*\"MonitorLayout\"/d
375
     /^[ \t]*Option[ \t]*\"Clone/d
376
     /EndSection/i\\
377
        Option      \"MonitorLayout\" \"CRT,LFP\"\\
378
        Option      \"Clone\" \"1\"\\
379
        Option      \"CloneRefresh\" \"60\"
380
     }" -i /etc/X11/xorg.conf
381
fi
382
 
383
# Set BoardName for Intel 915GM
384
if [ $I915GM ]; then
385
    sed -i 's/BoardName.*VESA driver.*/BoardName   "Intel 915"/' /etc/X11/xorg.conf
386
fi
387
 
388
 
389
### parameter KB = KEYBOARD
390
KEYBOARD=$KB
391
 
392
### ask user for keyboard layout if no keyboard given
393
if [ -x /usr/bin/system-config-keyboard ]; then
394
    if [ ! $KEYBOARD ]; then
395
	MORE_LAYOUTS="more..."
396
	keytables="U.S...........(us) \
397
	           Swiss-German..(sg-latin1) \
398
                   Swiss-French..(fr_CH-latin1) \
399
                   German........(de-latin1) \
400
                   Japanese......(jp106) \
401
                   $MORE_LAYOUTS"
402
	PS3="-> "
403
	echo
404
	echo "Please choose keyboard layout (type 1-6):"
405
	select KEYBOARD in $keytables;
406
	  do
407
	     case $KEYBOARD in
408
	        *)
409
	        # extract keyboard layout string from $KEYBOARD
410
	        KEYBOARD=${KEYBOARD##*(}
411
                KEYBOARD=${KEYBOARD%%)}
412
                break
413
                ;;
414
	     esac
415
	  done
416
    fi
417
fi
418
 
419
### set keyboard
420
if [ -x /usr/bin/system-config-keyboard ]; then
421
    if [ "$KEYBOARD" = "$MORE_LAYOUTS" ]; then
422
	system-config-keyboard --text
423
    else
424
	echo -n "Set keyboard to '$KEYBOARD', please wait ... "
425
	system-config-keyboard --noui $KEYBOARD >/dev/null 2>&1
426
	echo "done."
427
    fi
428
    echo
429
fi
430
 
431
### update AFS users and SEPP links (only for PSI)
432
if [ $PSI ] && [ $AFS ]; then
433
    echo "Update AFS users and SEPP links..."
434
    [ -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_sepp.pl ] && /afs/psi.ch/sys/common/update_sepp.pl >/dev/null 2>&1 &
9 beyerle@PS 436
    sleep 1
1 beyerle@PS 437
    echo
438
fi
439
 
440
### create local user, if "nolocal" is not set 
441
if [ ! $NOLOCAL ]; then
442
 
443
    user=$LOCALUSER
444
    # execute useradd twice, to make it work (don't know why)
445
    if [ $PSI ] && [ ! $NOADMIN ]; then
446
	userdel -r $user 2>/dev/null
447
	useradd -G $LocalAdminGroup $user 2>/dev/null
448
	userdel -r $user 2>/dev/null
449
	useradd -G $LocalAdminGroup $user
450
    else
451
	userdel -r $user 2>/dev/null
452
	useradd $user 2>/dev/null
453
	userdel -r $user 2>/dev/null
454
	useradd $user
455
    fi
456
 
457
    # only for PSI: change users's group to GID=UID+50000
458
    if [ $PSI ]; then
459
	uid=$( id -u $user )
460
	old_gid=$( id -g $user )
461
	new_gid=$(( $old_gid + 50000 ))
462
        # fix /etc/group
463
	sed -i "s/${user}:x:${old_gid}:/${user}:x:${new_gid}:/" /etc/group
464
        # fix /etc/passwd
465
	sed -i "s/${user}:x:${uid}:${old_gid}:/${user}:x:${uid}:${new_gid}:/" /etc/passwd
466
        # fix perm of /home/${user)
467
	chgrp -R $user /home/${user}
468
    fi
469
fi
470
 
471
### copy special files for PSI user l_psi
472
if [ $PSI ] && [ ! $NOLOCAL ]; then
473
    find /usr/share/${LOCALUSER}/ -maxdepth 1 -mindepth 1 2>/dev/null | \
474
    while read dir; do 
475
	cp -a $dir /home/${LOCALUSER}/
476
    done
477
    # set owner
478
    chown -R ${LOCALUSER}.${LOCALUSER} /home/${LOCALUSER}
479
fi
480
 
481
### set password for root and local user
482
if [ ! $NOPASSWD ]; then
483
    if [ ! $NOROOT ] || [ ! $NOLOCAL ]; then
484
	echo -n "Set password for "
485
	if [ ! $NOROOT ]; then
486
	    echo -n "'root' "
487
	fi
488
	if [ ! $NOROOT ] && [ ! $NOLOCAL ]; then
489
	    echo -n "and "
490
	fi
491
	if [ ! $NOLOCAL ]; then
492
	    echo -n "local user '$user' "
493
	fi
494
	echo
495
 
496
	if [ ! $NOLOCAL ]; then
497
	    echo "Login as local user '$user' with this password."
498
	    echo
499
	fi
500
 
501
        # set password, if not yet given by $PASSWD
502
	until [ $PASSWD ]; do
503
	    echo -n "Password: "
504
	    read -s PASSWD
505
	    echo
506
	done
507
	if [ ! $NOROOT ]; then
508
	    echo $PASSWD | passwd --stdin root >/dev/null
509
	fi
510
	if [ ! $NOLOCAL ]; then
511
	    echo $PASSWD | passwd --stdin $user >/dev/null
512
	fi
513
	echo
514
    fi
515
 
516
else
517
    # set root and $LOCALUSER to empty password
518
    sed -i "s|^root:.*|root::12345:0:99999:1:::|" /etc/shadow
519
    sed -i "s|^$LOCALUSER:.*|$LOCALUSER::12345:0:99999:1:::|" /etc/shadow
520
fi
521
 
522
### try to get hostname from DNS, if not yet defined
523
if [ ! $HOSTNAME ]; then
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|/.*||' )
526
    if [ "$IP" = "" ]; then
527
	IP=$( /sbin/ip add show dev eth1 2>/dev/null | grep "inet " | cut -d" " -f6 | sed 's|/.*||' )
528
    fi
529
    if [ "$IP" != "" ]; then
530
	host -W 1 $IP >/dev/null 2>&1
531
	if [ "$?" = "0" ]; then
532
	    HOSTNAME=$( host -W 1 $IP | cut -d" " -f 5 | cut -d"." -f 1 )
533
	    if [ "$HOSTNAME" = "3(NXDOMAIN)" ]; then
534
		HOSTNAME=$DEFAULT_HOSTNAME
535
	    fi	
536
	    if [ "$HOSTNAME" = "no" ]; then
537
		HOSTNAME=$DEFAULT_HOSTNAME
538
	    fi	
539
	fi
540
    fi
541
fi
542
 
543
### define default hostname, if $HOSTNAME still not yet set
544
if [ ! $HOSTNAME ]; then
545
    HOSTNAME=$DEFAULT_HOSTNAME
546
fi
547
 
9 beyerle@PS 548
### set hostname for eth0 or eth1
1 beyerle@PS 549
export HOSTNAME=$HOSTNAME
550
hostname $HOSTNAME
551
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
552
if [ $PSI ]; then
553
    sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
554
    sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/cfengine
555
fi
9 beyerle@PS 556
echo "DHCP_HOSTNAME=${HOSTNAME}" >> /etc/sysconfig/networking/devices/ifcfg-eth0
557
echo "DHCP_HOSTNAME=${HOSTNAME}" >> /etc/sysconfig/networking/devices/ifcfg-eth1
1 beyerle@PS 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
### unmute all mixers and set volumes
642
if [ -x /usr/bin/set-volume ]; then 
643
    if [ $NOSOUND ]; then
644
	/usr/bin/set-volume 0 > /var/log/set-volume.log 2>&1 &
645
    else
646
	/usr/bin/set-volume 60 > /var/log/set-volume.log 2>&1 &
647
    fi
648
fi
649
 
650
### set kde or gnome as desktop
651
if [ $KDE ]; then
652
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
653
    echo "DESKTOP=KDE" >> /etc/sysconfig/desktop
654
fi
655
if [ $GNOME ]; then
656
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
657
    echo "DESKTOP=GNOME" >> /etc/sysconfig/desktop
658
fi
659
 
660
### change to runlevel 3, if NOX (bad hack)
661
if [ $NOX ]; then
662
    init 3
663
fi
664