Subversion Repositories livecd

Rev

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

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