Subversion Repositories livecd

Rev

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

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