Subversion Repositories livecd

Rev

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

Rev 169 Rev 172
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
    # execute useradd/groupadd twice, to make it work (don't know why)
-
 
489
    if [ $PSI ] && [ ! $NOADMIN ]; then
488
    if [ $PSI ] && [ ! $NOADMIN ]; then
490
	groupdel $user 2>/dev/null
-
 
491
	groupadd $user 2>/dev/null
489
	groupadd $user   2>/dev/null
492
	groupdel $user 2>/dev/null
-
 
493
	groupadd $user
-
 
494
	
-
 
495
	userdel -r $user                  2>/dev/null
-
 
496
	useradd -G $LocalAdminGroup $user 2>/dev/null
-
 
497
	userdel -r $user                  2>/dev/null
-
 
498
        # add user to fuse group ?
490
        # add user to fuse group ?
499
	grep -q "^fuse:" /etc/group
491
	grep -q "^fuse:" /etc/group
500
	if [ "$?" = "0" ]; then
492
	if [ "$?" = "0" ]; then
501
	    useradd -g $user -G ${LocalAdminGroup},fuse $user
493
	    useradd -g $user -G ${LocalAdminGroup},fuse $user  2>/dev/null
502
	else
494
	else
503
	    useradd -g $user -G ${LocalAdminGroup} $user
495
	    useradd -g $user -G ${LocalAdminGroup} $user       2>/dev/null
504
	fi
496
	fi
505
    else
497
    else
506
	userdel -r $user 2>/dev/null
-
 
507
	useradd $user    2>/dev/null
498
	groupadd $user  2>/dev/null
508
	userdel -r $user 2>/dev/null
-
 
509
	grep -q "^fuse:" /etc/group
-
 
510
        # add user to fuse group ?
499
        # add user to fuse group ?
-
 
500
	grep -q "^fuse:" /etc/group
511
	if [ "$?" = "0" ]; then
501
	if [ "$?" = "0" ]; then
512
	    useradd -G fuse $user
502
	    useradd -g $user -G fuse $user  2>/dev/null
513
	else
503
	else
514
	    useradd $user
504
	    useradd -g $user $user          2>/dev/null
515
	fi
505
	fi
516
    fi
506
    fi
517
 
507
 
518
fi
508
fi
519
 
509
 
520
### copy special files for PSI user l_psi
510
### copy special files for PSI user l_psi
521
if [ $PSI ] && [ ! $NOLOCAL ]; then
511
if [ $PSI ] && [ ! $NOLOCAL ]; then
522
    find /usr/share/${LOCALUSER}/ -maxdepth 1 -mindepth 1 2>/dev/null | \
512
    find /usr/share/${LOCALUSER}/ -maxdepth 1 -mindepth 1 2>/dev/null | \
523
    while read dir; do 
513
    while read dir; do 
524
	cp -a $dir /home/${LOCALUSER}/
514
	cp -a $dir /home/${LOCALUSER}/
525
    done
515
    done
526
    # set owner
516
    # set owner
527
    chown -R ${LOCALUSER}.${LOCALUSER} /home/${LOCALUSER}
517
    chown -R ${LOCALUSER}.${LOCALUSER} /home/${LOCALUSER}
528
fi
518
fi
529
 
519
 
530
### autostart kmix and krandrtray in KDE
520
### autostart kmix and krandrtray in KDE
531
if [ ! $NOLOCAL ]; then
521
if [ ! $NOLOCAL ]; then
532
    mkdir -p /home/${LOCALUSER}/.kde/Autostart
522
    mkdir -p /home/${LOCALUSER}/.kde/Autostart
533
    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
534
    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
535
    chown -R ${LOCALUSER}.${LOCALUSER} /home/${LOCALUSER}/.kde/Autostart
525
    chown -R ${LOCALUSER}.${LOCALUSER} /home/${LOCALUSER}/.kde/Autostart
536
fi
526
fi
537
 
527
 
538
 
528
 
539
### first set empty password
529
### first set empty password
540
if [ ! $NOROOT ]; then
530
if [ ! $NOROOT ]; then
541
    sed -i "s|^root:.*|root::12345:0:99999:1:::|" /etc/shadow
531
    sed -i "s|^root:.*|root::12345:0:99999:1:::|" /etc/shadow
542
fi
532
fi
543
if [ ! $NOLOCAL]; then
533
if [ ! $NOLOCAL]; then
544
    sed -i "s|^$LOCALUSER:.*|$LOCALUSER::12345:0:99999:1:::|" /etc/shadow
534
    sed -i "s|^$LOCALUSER:.*|$LOCALUSER::12345:0:99999:1:::|" /etc/shadow
545
fi
535
fi
546
 
536
 
547
### set password for root and local user
537
### set password for root and local user
548
if [ ! $NOPASSWD ]; then
538
if [ ! $NOPASSWD ]; then
549
    if [ ! $NOROOT ] || [ ! $NOLOCAL ]; then
539
    if [ ! $NOROOT ] || [ ! $NOLOCAL ]; then
550
	echo -n "Set password for "
540
	echo -n "Set password for "
551
	if [ ! $NOROOT ]; then
541
	if [ ! $NOROOT ]; then
552
	    echo -n "'root' "
542
	    echo -n "'root' "
553
	fi
543
	fi
554
	if [ ! $NOROOT ] && [ ! $NOLOCAL ]; then
544
	if [ ! $NOROOT ] && [ ! $NOLOCAL ]; then
555
	    echo -n "and "
545
	    echo -n "and "
556
	fi
546
	fi
557
	if [ ! $NOLOCAL ]; then
547
	if [ ! $NOLOCAL ]; then
558
	    echo -n "local user '$user' "
548
	    echo -n "local user '$user' "
559
	fi
549
	fi
560
	echo
550
	echo
561
	echo "or hit return for empty password."
551
	echo "or hit return for empty password."
562
 
552
 
563
	if [ ! $NOLOCAL ]; then
553
	if [ ! $NOLOCAL ]; then
564
	    echo "Login as local user '$user' with this password."
554
	    echo "Login as local user '$user' with this password."
565
	fi
555
	fi
566
	echo
556
	echo
567
 
557
 
568
        # ask for password, if not yet given by $PASSWD
558
        # ask for password, if not yet given by $PASSWD
569
	if [ ! $PASSWD ]; then 
559
	if [ ! $PASSWD ]; then 
570
	    echo -n "Password: "
560
	    echo -n "Password: "
571
	    read -s PASSWD
561
	    read -s PASSWD
572
	    echo
562
	    echo
573
	fi
563
	fi
574
 
564
 
575
	# set password - or - set empty password
565
	# set password - or - set empty password
576
	if [ ! $NOROOT ] && [ "$PASSWD" ]; then
566
	if [ ! $NOROOT ] && [ "$PASSWD" ]; then
577
	    echo $PASSWD | passwd --stdin root >/dev/null
567
	    echo $PASSWD | passwd --stdin root >/dev/null
578
	fi
568
	fi
579
	if [ ! $NOLOCAL] && [ "$PASSWD" ]; then
569
	if [ ! $NOLOCAL] && [ "$PASSWD" ]; then
580
	    echo $PASSWD | passwd --stdin $user >/dev/null
570
	    echo $PASSWD | passwd --stdin $user >/dev/null
581
	fi
571
	fi
582
	echo
572
	echo
583
    fi
573
    fi
584
fi
574
fi
585
 
575
 
586
### try to get hostname from DNS, if not yet defined
576
### try to get hostname from DNS, if not yet defined
587
if [ ! $HOSTNAME ]; then
577
if [ ! $HOSTNAME ]; then
588
    echo "Try to get hostname from DNS ..."
578
    echo "Try to get hostname from DNS ..."
589
    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|/.*||' )
590
    if [ "$IP" = "" ]; then
580
    if [ "$IP" = "" ]; then
591
	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|/.*||' )
592
    fi
582
    fi
593
    if [ "$IP" != "" ]; then
583
    if [ "$IP" != "" ]; then
594
	host -W 1 $IP >/dev/null 2>&1
584
	host -W 1 $IP >/dev/null 2>&1
595
	if [ "$?" = "0" ]; then
585
	if [ "$?" = "0" ]; then
596
	    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 )
597
	    if [ "$HOSTNAME" = "3(NXDOMAIN)" ]; then
587
	    if [ "$HOSTNAME" = "3(NXDOMAIN)" ]; then
598
		HOSTNAME=$DEFAULT_HOSTNAME
588
		HOSTNAME=$DEFAULT_HOSTNAME
599
	    fi	
589
	    fi	
600
	    if [ "$HOSTNAME" = "no" ]; then
590
	    if [ "$HOSTNAME" = "no" ]; then
601
		HOSTNAME=$DEFAULT_HOSTNAME
591
		HOSTNAME=$DEFAULT_HOSTNAME
602
	    fi	
592
	    fi	
603
	fi
593
	fi
604
    fi
594
    fi
605
fi
595
fi
606
 
596
 
607
### define default hostname, if $HOSTNAME is still not yet set
597
### define default hostname, if $HOSTNAME is still not yet set
608
if [ ! $HOSTNAME ]; then
598
if [ ! $HOSTNAME ]; then
609
    HOSTNAME=$DEFAULT_HOSTNAME
599
    HOSTNAME=$DEFAULT_HOSTNAME
610
fi
600
fi
611
 
601
 
612
### set hostname
602
### set hostname
613
export HOSTNAME=$HOSTNAME
603
export HOSTNAME=$HOSTNAME
614
hostname $HOSTNAME
604
hostname $HOSTNAME
615
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
605
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
616
if [ $PSI ]; then
606
if [ $PSI ]; then
617
    sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
607
    sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
618
    sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/psi
608
    sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/psi
619
fi
609
fi
620
for iface in eth0 eth1 eth2 eth3; do
610
for iface in eth0 eth1 eth2 eth3; do
621
    if [ -e /etc/sysconfig/network-scripts/ifcfg-${iface} ]; then
611
    if [ -e /etc/sysconfig/network-scripts/ifcfg-${iface} ]; then
622
	echo "DHCP_HOSTNAME=${HOSTNAME}" >> /etc/sysconfig/network-scripts/ifcfg-${iface}
612
	echo "DHCP_HOSTNAME=${HOSTNAME}" >> /etc/sysconfig/network-scripts/ifcfg-${iface}
623
    fi
613
    fi
624
done
614
done
625
 
615
 
626
echo "Hostname set to: $HOSTNAME"
616
echo "Hostname set to: $HOSTNAME"
627
echo
617
echo
628
 
618
 
629
### set cups server
619
### set cups server
630
if [ $CUPS ]; then
620
if [ $CUPS ]; then
631
    sed -i "s|.*ServerName .*|ServerName  $CUPS|" /etc/cups/client.conf
621
    sed -i "s|.*ServerName .*|ServerName  $CUPS|" /etc/cups/client.conf
632
    grep -q ServerName /etc/cups/client.conf || echo "ServerName  $CUPS" >> /etc/cups/client.conf 
622
    grep -q ServerName /etc/cups/client.conf || echo "ServerName  $CUPS" >> /etc/cups/client.conf 
633
fi
623
fi
634
 
624
 
635
### some magic: just access this file in order that it can be sourced later
625
### some magic: just access this file in order that it can be sourced later
636
ls -lag /etc/X11/xinit/xinitrc-common >/dev/null 2>&1
626
ls -lag /etc/X11/xinit/xinitrc-common >/dev/null 2>&1
637
 
627
 
638
### set keyboard for rdesktop
628
### set keyboard for rdesktop
639
if [ -e $XORG_CONF ]; then
629
if [ -e $XORG_CONF ]; then
640
    grep -q de_CH $XORG_CONF && RDESKTOP_OPT="-k de-ch"
630
    grep -q de_CH $XORG_CONF && RDESKTOP_OPT="-k de-ch"
641
    grep -q fr_CH $XORG_CONF && RDESKTOP_OPT="-k fr-ch"
631
    grep -q fr_CH $XORG_CONF && RDESKTOP_OPT="-k fr-ch"
642
    grep -q jp106 $XORG_CONF && RDESKTOP_OPT="-k ja"
632
    grep -q jp106 $XORG_CONF && RDESKTOP_OPT="-k ja"
643
fi
633
fi
644
 
634
 
645
if [ "$RDESKTOP_OPT" ]; then
635
if [ "$RDESKTOP_OPT" ]; then
646
    echo "alias rdesktop='rdesktop $RDESKTOP_OPT'" > /etc/profile.d/rdesktop.sh
636
    echo "alias rdesktop='rdesktop $RDESKTOP_OPT'" > /etc/profile.d/rdesktop.sh
647
    echo "export RDESKTOP_OPT='$RDESKTOP_OPT'" >> /etc/profile.d/rdesktop.sh
637
    echo "export RDESKTOP_OPT='$RDESKTOP_OPT'" >> /etc/profile.d/rdesktop.sh
648
    chmod 755 /etc/profile.d/rdesktop.sh
638
    chmod 755 /etc/profile.d/rdesktop.sh
649
fi
639
fi
650
 
640
 
651
### run setup script, if found in $CONFIG_FOLDER on $FOUND_RESTORE_MNT
641
### run setup script, if found in $CONFIG_FOLDER on $FOUND_RESTORE_MNT
652
if [ -r $CONFIG_FOLDER/setup ]; then
642
if [ -r $CONFIG_FOLDER/setup ]; then
653
    CONFIG_FOLDER=$CONFIG_FOLDER bash $CONFIG_FOLDER/setup
643
    CONFIG_FOLDER=$CONFIG_FOLDER bash $CONFIG_FOLDER/setup
654
fi
644
fi
655
 
645
 
656
### umount $FOUND_RESTORE_MNT
646
### umount $FOUND_RESTORE_MNT
657
if [ $FOUND_RESTORE_MNT ]; then
647
if [ $FOUND_RESTORE_MNT ]; then
658
    echo "Unmount $FOUND_RESTORE_MNT"
648
    echo "Unmount $FOUND_RESTORE_MNT"
659
    umount $FOUND_RESTORE_MNT 2>/dev/null
649
    umount $FOUND_RESTORE_MNT 2>/dev/null
660
    sleep 3
650
    sleep 3
661
fi
651
fi
662
 
652
 
663
### local home partition?
653
### local home partition?
664
if [ $HOMELOCAL ]; then
654
if [ $HOMELOCAL ]; then
665
    mv /home /home.old
655
    mv /home /home.old
666
    mkdir -p /mnt/home_par
656
    mkdir -p /mnt/home_par
667
    # which partition? which folder?
657
    # which partition? which folder?
668
    HOMEPAR=$( echo $HOMELOCAL | cut -d":" -f1 )
658
    HOMEPAR=$( echo $HOMELOCAL | cut -d":" -f1 )
669
    HOMEDIR=$( echo $HOMELOCAL | grep ":" | cut -d":" -f2 )
659
    HOMEDIR=$( echo $HOMELOCAL | grep ":" | cut -d":" -f2 )
670
    umount $HOMEPAR 2>/dev/null
660
    umount $HOMEPAR 2>/dev/null
671
    # mount it with option noatime, healthy for USB flash drives
661
    # mount it with option noatime, healthy for USB flash drives
672
    mount -o noatime -rw $HOMEPAR /mnt/home_par 2>/dev/null
662
    mount -o noatime -rw $HOMEPAR /mnt/home_par 2>/dev/null
673
    if [ "$?" != "0" ]; then
663
    if [ "$?" != "0" ]; then
674
	echo "ERROR: Could not mount read/write $HOMEPAR"
664
	echo "ERROR: Could not mount read/write $HOMEPAR"
675
	umount $HOMEPAR >/dev/null 2&>1
665
	umount $HOMEPAR >/dev/null 2&>1
676
	mv /home.old /home
666
	mv /home.old /home
677
    else
667
    else
678
	echo "$HOMEPAR mounted on /mnt/home_par"
668
	echo "$HOMEPAR mounted on /mnt/home_par"
679
	# link to new home
669
	# link to new home
680
	ln -s /mnt/home_par/$HOMEDIR /home
670
	ln -s /mnt/home_par/$HOMEDIR /home
681
	if [ ! -d /mnt/home_par/$HOMEDIR ]; then
671
	if [ ! -d /mnt/home_par/$HOMEDIR ]; then
682
	    echo "$HOMELOCAL not found on $HOMEPAR"
672
	    echo "$HOMELOCAL not found on $HOMEPAR"
683
	    echo mkdir -p /mnt/home_par/$HOMEDIR
673
	    echo mkdir -p /mnt/home_par/$HOMEDIR
684
	    if [ "$?" != "0" ]; then
674
	    if [ "$?" != "0" ]; then
685
		echo "ERROR: Could not create $HOMELOCAL on $HOMEPAR"
675
		echo "ERROR: Could not create $HOMELOCAL on $HOMEPAR"
686
		umount $HOMEPAR >/dev/null 2&>1
676
		umount $HOMEPAR >/dev/null 2&>1
687
		rm -f /home
677
		rm -f /home
688
		mv /home.old /home
678
		mv /home.old /home
689
	    else
679
	    else
690
		echo "Folder $HOMEDIR created on $HOMEPAR"
680
		echo "Folder $HOMEDIR created on $HOMEPAR"
691
	    fi
681
	    fi
692
	fi
682
	fi
693
	if [ -d /mnt/home_par/$HOMEDIR ]; then
683
	if [ -d /mnt/home_par/$HOMEDIR ]; then
694
	    echo "/home is linked to /mnt/home_par${HOMEDIR}"
684
	    echo "/home is linked to /mnt/home_par${HOMEDIR}"
695
	    # copy files from /home.old to /home, which are not yet there
685
	    # copy files from /home.old to /home, which are not yet there
696
	    /bin/cp -a -i --reply=no /home.old/* /home/ 
686
	    /bin/cp -a -i --reply=no /home.old/* /home/ 
697
	    rm -rf /home.old
687
	    rm -rf /home.old
698
	fi
688
	fi
699
    fi
689
    fi
700
    sleep 2
690
    sleep 2
701
fi
691
fi
702
 
692
 
703
### mount all if AUTOMOUNT set
693
### mount all if AUTOMOUNT set
704
if [ $AUTOMOUNT ]; then
694
if [ $AUTOMOUNT ]; then
705
    mount -a
695
    mount -a
706
fi
696
fi
707
 
697
 
708
### unmute all mixers and set volumes
698
### unmute all mixers and set volumes
709
if [ -x /usr/bin/set-volume ]; then 
699
if [ -x /usr/bin/set-volume ]; then 
710
    if [ $NOSOUND ]; then
700
    if [ $NOSOUND ]; then
711
	/usr/bin/set-volume 0 > /var/log/set-volume.log 2>&1 &
701
	/usr/bin/set-volume 0 > /var/log/set-volume.log 2>&1 &
712
    else
702
    else
713
	/usr/bin/set-volume 60 > /var/log/set-volume.log 2>&1 &
703
	/usr/bin/set-volume 60 > /var/log/set-volume.log 2>&1 &
714
    fi
704
    fi
715
fi
705
fi
716
 
706
 
717
### set kde or gnome as desktop
707
### set kde or gnome as desktop
718
if [ $KDE ]; then
708
if [ $KDE ]; then
719
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
709
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
720
    echo "DESKTOP=KDE" >> /etc/sysconfig/desktop
710
    echo "DESKTOP=KDE" >> /etc/sysconfig/desktop
721
fi
711
fi
722
if [ $GNOME ]; then
712
if [ $GNOME ]; then
723
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
713
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
724
    echo "DESKTOP=GNOME" >> /etc/sysconfig/desktop
714
    echo "DESKTOP=GNOME" >> /etc/sysconfig/desktop
725
fi
715
fi
726
 
716
 
727
### reload sound module (second time)
717
### reload sound module (second time)
728
reload_soundmodule
718
reload_soundmodule
729
 
719
 
730
### bring up all network interfaces (useful to enable WLAN devices)
720
### bring up all network interfaces (useful to enable WLAN devices)
731
if [ ! $NONET ]; then
721
if [ ! $NONET ]; then
732
    devices=$( ls /etc/sysconfig/network-scripts/ifcfg-* \
722
    devices=$( ls /etc/sysconfig/network-scripts/ifcfg-* \
733
               | sed "s|/etc/sysconfig/network-scripts/ifcfg-||" | grep -v lo )
723
               | sed "s|/etc/sysconfig/network-scripts/ifcfg-||" | grep -v lo )
734
    for device in $devices; do
724
    for device in $devices; do
735
	ifconfig $device up > /dev/null 2>&1 &
725
	ifconfig $device up > /dev/null 2>&1 &
736
    done
726
    done
737
fi
727
fi
738
 
728