Subversion Repositories livecd

Rev

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

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