Subversion Repositories livecd

Rev

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

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