Subversion Repositories livecd

Rev

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

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