Subversion Repositories livecd

Rev

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

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