Subversion Repositories livecd

Rev

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

Rev 108 Rev 125
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
###############################################################
3
###############################################################
4
#
4
#
5
# Installes the LiveCD on local hard disk
5
# Installes the LiveCD on local hard disk
6
# 
6
# 
7
# Boot LiveCD and run this script as root
7
# Boot LiveCD and run this script as root
8
#
8
#
9
# Urs Beyerle, PSI
9
# Urs Beyerle, PSI
10
#
10
#
11
###############################################################
11
###############################################################
12
 
12
 
13
 
13
 
14
###############################################################
14
###############################################################
15
# Definitions
15
# Definitions
16
###############################################################
16
###############################################################
17
 
17
 
18
# set PATH
18
# set PATH
19
PATH="/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin"
19
PATH="/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin"
20
 
20
 
21
# RPMs that are no longer needed and can break future udpates
21
# RPMs that are no longer needed and can break future udpates
22
RPMS_TO_REMOVE="kernel-module-squashfs \
22
RPMS_TO_REMOVE="kernel-module-squashfs \
23
                kernel-module-unionfs \
23
                kernel-module-unionfs \
24
                kernel-module-aufs \
24
                kernel-module-aufs \
25
                unionfs-.* \
25
                unionfs-.* \
26
                aufs-.* \
26
                aufs-.* \
27
                squashfs-.*"
27
                squashfs-.*"
28
 
28
 
29
# RPMs that can break future Scientific Linux updates
29
# RPMs that can break future Scientific Linux updates
30
# because there are not part of Scientific Linux
30
# because there are not part of Scientific Linux
31
RPMS_TO_REMOVE_SL="kernel-module-ntfs \
31
RPMS_TO_REMOVE_SL="kernel-module-ntfs \
32
                   nvidia.*psi"
32
                   nvidia.*psi"
33
                   
33
                   
34
# RPMs that can break future PSI SL updates
34
# RPMs that can break future PSI SL updates
35
# because there are not part of PSI Scientific Linux
35
# because there are not part of PSI Scientific Linux
36
RPMS_TO_REMOVE_PSI=""
36
RPMS_TO_REMOVE_PSI=""
37
                   
37
                   
38
# files which should be restored from .ori files
38
# files which should be restored from .ori files
39
FILES_RESTORE="/etc/init.d/netfs \
39
FILES_RESTORE="/etc/init.d/netfs \
40
           /etc/init.d/autofs \
40
           /etc/init.d/autofs \
41
           /etc/init.d/halt \
41
           /etc/init.d/halt \
42
           /etc/init.d/network
42
           /etc/init.d/network
43
           /etc/init.d/functions \
43
           /etc/init.d/functions \
44
           /etc/rc.d/rc.sysinit \
44
           /etc/rc.d/rc.sysinit \
45
           /etc/sysconfig/afs \
45
           /etc/sysconfig/afs \
46
           /etc/motd \
46
           /etc/motd \
47
           /etc/redhat-release \
47
           /etc/redhat-release \
48
	   /etc/rc.d/rc.local"
48
	   /etc/rc.d/rc.local"
49
 
49
 
50
# LiveCD init scripts will be removed
50
# LiveCD init scripts will be removed
51
LIVECD_INIT_SCRIPTS="runfirst \
51
LIVECD_INIT_SCRIPTS="runfirst \
52
                    runveryfirst \
52
                    runveryfirst \
53
                    runlast \
53
                    runlast \
54
                    kudzu-auto \
54
                    kudzu-auto \
55
                    login"
55
                    login"
56
 
56
 
57
# Main directories which should be not be copied
57
# Main directories which should be not be copied
58
DIR_NOT_COPY="/proc \
58
DIR_NOT_COPY="/proc \
59
              /dev \
59
              /dev \
60
              /livecd \
60
              /livecd \
61
              /boot \
61
              /boot \
62
              /afs \
62
              /afs \
63
              /sys \
63
              /sys \
64
              /mnt \
64
              /mnt \
65
              /media \
65
              /media \
66
              /initrd"
66
              /initrd"
67
 
67
 
68
# Mount point of the new SL system
68
# Mount point of the new SL system
69
NEW=/mnt/harddisk
69
NEW=/mnt/harddisk
70
 
70
 
71
# Name of the script
71
# Name of the script
72
SCRIPTNAME=$( basename $0 )
72
SCRIPTNAME=$( basename $0 )
73
 
73
 
74
 
74
 
75
 
75
 
76
 
76
 
77
###############################################################
77
###############################################################
78
# Functions
78
# Functions
79
###############################################################
79
###############################################################
80
 
80
 
81
function usage() {
81
function usage() {
82
 
82
 
83
   ## Usage
83
   ## Usage
84
   # ----------------------------------------------------------
84
   # ----------------------------------------------------------
85
 
85
 
86
   cat <<EOF
86
   cat <<EOF
87
   
87
   
88
  $SCRIPTNAME [OPTIONS] -mbr=[DEVICE] [PARTITION]
88
  $SCRIPTNAME [OPTIONS] -mbr=[DEVICE] [PARTITION]
89
 
89
 
90
    Installes LiveCD on PARTITION and the bootloader grub into 
90
    Installes LiveCD on PARTITION and the bootloader grub into 
91
    the Master Boot Record (MBR) of DEVICE. The MBR will be 
91
    the Master Boot Record (MBR) of DEVICE. The MBR will be 
92
    backed up to PARTITION.
92
    backed up to PARTITION.
93
 
93
 
94
  OPTIONS:
94
  OPTIONS:
95
 
95
 
96
    -h   --help       : Print this screen
96
    -h   --help       : Print this screen
97
    -swap=[partition] : Use [partition] as swap
97
    -swap=[partition] : Use [partition] as swap
98
    -win=[partition]  : Your active Windows partition. If not given, 
98
    -win=[partition]  : Your active Windows partition. If not given, 
99
                        $SCRIPTNAME tries to find it
99
                        $SCRIPTNAME tries to find it
100
    -nogrub           : Do not install grub. You have to install 
100
    -nogrub           : Do not install grub. You have to install 
101
                        manually a bootloader (not recommended)
101
                        manually a bootloader (not recommended)
102
    -floppy           : Needed, if grub should be installed on floppy
102
    -floppy           : Needed, if grub should be installed on floppy
103
                        In this case use -mbr=/dev/fd0 -floppy
103
                        In this case use -mbr=/dev/fd0 -floppy
104
    -norpmremove      : Do not remove RPMs that can break future 
104
    -norpmremove      : Do not remove RPMs that can break future 
105
                        updates (not recommended)
105
                        updates (not recommended)
106
    -y                : Answer all questions with yes
106
    -y                : Answer all questions with yes
107
 
107
 
108
  Example:
108
  Example:
109
 
109
 
110
  $SCRIPTNAME -swap=/dev/sda3 -mbr=/dev/sda /dev/sda2
110
  $SCRIPTNAME -swap=/dev/sda3 -mbr=/dev/sda /dev/sda2
111
 
111
 
112
    Will install LiveCD on /dev/sda2 (= second partition on 
112
    Will install LiveCD on /dev/sda2 (= second partition on 
113
    first SATA disk). All data on /dev/sda2 will be deleted.
113
    first SATA disk). All data on /dev/sda2 will be deleted.
114
    /dev/sda3 has to be a Linux Swap partion. GRUB will be 
114
    /dev/sda3 has to be a Linux Swap partion. GRUB will be 
115
    installed in the MBR of /dev/sda (= first SATA disk).
115
    installed in the MBR of /dev/sda (= first SATA disk).
116
   
116
   
117
  Remarks:
117
  Remarks:
118
 
118
 
119
    To display your hard disk partitions, user 'fdisk -l'.
119
    To display your hard disk partitions, user 'fdisk -l'.
120
    Use fdisk, qtparted or parted to create an empty Linux
120
    Use fdisk, qtparted or parted to create an empty Linux
121
    partition.
121
    partition.
122
 
122
 
123
EOF
123
EOF
124
}
124
}
125
 
125
 
126
 
126
 
127
function exit_now() {
127
function exit_now() {
128
 
128
 
129
    local exitcode=$1
129
    local exitcode=$1
130
    umount $INSTALL_PART 2>/dev/null
130
    umount $INSTALL_PART 2>/dev/null
131
    exit $exitcode
131
    exit $exitcode
132
}
132
}
133
 
133
 
134
 
134
 
135
 
135
 
136
###############################################################
136
###############################################################
137
# Main
137
# Main
138
###############################################################
138
###############################################################
139
 
139
 
140
### are we root?
140
### are we root?
141
### -----------------------------------------------------------
141
### -----------------------------------------------------------
142
if [ "$( whoami )" != "root" ]; then
142
if [ "$( whoami )" != "root" ]; then
143
    echo; echo "Please run this script as root: 'su - -c $SCRIPTNAME'"; echo
143
    echo; echo "Please run this script as root: 'su - -c $SCRIPTNAME'"; echo
144
    exit_now 1
144
    exit_now 1
145
fi
145
fi
146
 
146
 
147
 
147
 
148
### read options from command-line
148
### read options from command-line
149
### -----------------------------------------------------------
149
### -----------------------------------------------------------
150
while [ $# -gt 0 ]; do
150
while [ $# -gt 0 ]; do
151
 
151
 
152
    case "$1" in
152
    case "$1" in
153
       -h)
153
       -h)
154
            usage; exit_now;;
154
            usage; exit_now;;
155
 
155
 
156
       --help)
156
       --help)
157
            usage; exit_now;;
157
            usage; exit_now;;
158
 
158
 
159
       -swap*)
159
       -swap*)
160
           if echo $1 | grep -q '=' ; then
160
           if echo $1 | grep -q '=' ; then
161
	       SWAP_PART=$( echo $1 | sed 's/^-swap=//' )
161
	       SWAP_PART=$( echo $1 | sed 's/^-swap=//' )
162
	   else
162
	   else
163
	       shift
163
	       shift
164
               SWAP_PART=$1
164
               SWAP_PART=$1
165
	   fi
165
	   fi
166
	   ;;
166
	   ;;
167
 
167
 
168
       -mbr*)
168
       -mbr*)
169
           if echo $1 | grep -q '=' ; then
169
           if echo $1 | grep -q '=' ; then
170
	       MBR_DEV=$( echo $1 | sed 's/^-mbr=//' )
170
	       MBR_DEV=$( echo $1 | sed 's/^-mbr=//' )
171
	   else
171
	   else
172
	       shift
172
	       shift
173
               MBR_DEV=$1
173
               MBR_DEV=$1
174
	   fi
174
	   fi
175
	   ;;
175
	   ;;
176
 
176
 
177
       -win*)
177
       -win*)
178
           if echo $1 | grep -q '=' ; then
178
           if echo $1 | grep -q '=' ; then
179
	       WIN_PART=$( echo $1 | sed 's/^-win=//' )
179
	       WIN_PART=$( echo $1 | sed 's/^-win=//' )
180
	   else
180
	   else
181
	       shift
181
	       shift
182
               WIN_PART=$1
182
               WIN_PART=$1
183
	   fi
183
	   fi
184
	   ;;
184
	   ;;
185
 
185
 
186
       -nogrub)
186
       -nogrub)
187
            NOGRUB=$1;;
187
            NOGRUB=$1;;
188
 
188
 
189
       -norpmremove)
189
       -norpmremove)
190
            NORPMREMOVE=$1;;
190
            NORPMREMOVE=$1;;
191
 
191
 
192
       -floppy)
192
       -floppy)
193
            FLOPPY=$1;;
193
            FLOPPY=$1;;
194
 
194
 
195
       -y)
195
       -y)
196
            YES=$1;;
196
            YES=$1;;
197
 
197
 
198
       *)
198
       *)
199
            INSTALL_PART=$1;;
199
            INSTALL_PART=$1;;
200
    esac
200
    esac
201
 
201
 
202
    shift
202
    shift
203
 
203
 
204
done
204
done
205
echo
205
echo
206
 
206
 
207
 
207
 
208
### display fdisk -l
208
### display fdisk -l
209
### -----------------------------------------------------------
209
### -----------------------------------------------------------
210
echo "Output of 'fdisk -l' ..."
210
echo "Output of 'fdisk -l' ..."
211
fdisk -l
211
fdisk -l
212
echo
212
echo
213
 
213
 
214
 
214
 
215
### test if $INSTALL_PART is defined
215
### test if $INSTALL_PART is defined
216
### -----------------------------------------------------------
216
### -----------------------------------------------------------
217
if [ ! $INSTALL_PART ]; then
217
if [ ! $INSTALL_PART ]; then
218
    echo "No partition defined for installation."
218
    echo "No partition defined for installation."
219
    echo "Please see '$SCRIPTNAME -h'."; echo
219
    echo "Please see '$SCRIPTNAME -h'."; echo
220
    exit_now 1
220
    exit_now 1
221
fi
221
fi
222
 
222
 
223
 
223
 
224
### test if MBR_DEV is given
224
### test if MBR_DEV is given
225
### -----------------------------------------------------------
225
### -----------------------------------------------------------
226
if [ ! $NOGRUB ]; then
226
if [ ! $NOGRUB ]; then
227
    if [ ! $MBR_DEV ]; then
227
    if [ ! $MBR_DEV ]; then
228
	echo "No MBR device defined."
228
	echo "No MBR device defined."
229
	echo "Please see '$SCRIPTNAME -h'."
229
	echo "Please see '$SCRIPTNAME -h'."
230
	echo
230
	echo
231
	exit_now 1
231
	exit_now 1
232
    fi
232
    fi
233
fi
233
fi
234
 
234
 
235
 
235
 
236
### test if $INSTALL_PART exists
236
### test if $INSTALL_PART exists
237
### -----------------------------------------------------------
237
### -----------------------------------------------------------
238
fdisk -l | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
238
fdisk -l | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
239
if [ "$?" != "0" ]; then
239
if [ "$?" != "0" ]; then
240
    echo "Partition $INSTALL_PART not found! See 'fdisk -l'."
240
    echo "Partition $INSTALL_PART not found! See 'fdisk -l'."
241
    echo "Or you have to reboot first to make the partition table active." 
241
    echo "Or you have to reboot first to make the partition table active." 
242
    echo
242
    echo
243
    exit_now 1
243
    exit_now 1
244
fi
244
fi
245
 
245
 
246
 
246
 
247
### test if $INSTALL_PART is a Linux partition
247
### test if $INSTALL_PART is a Linux partition
248
### -----------------------------------------------------------
248
### -----------------------------------------------------------
249
fdisk -l | grep "Linux$" | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
249
fdisk -l | grep "Linux$" | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
250
if [ "$?" != "0" ]; then
250
if [ "$?" != "0" ]; then
251
    echo "Partition $INSTALL_PART is not a Linux partition! (see 'fdisk -l')."
251
    echo "Partition $INSTALL_PART is not a Linux partition! (see 'fdisk -l')."
252
    echo "Use fdisk and/or qtparted to create a Linux partition!"
252
    echo "Use fdisk and/or qtparted to create a Linux partition!"
253
    echo "You have to reboot first to make the partition table active."
253
    echo "You have to reboot first to make the partition table active."
254
    echo
254
    echo
255
    exit_now 1
255
    exit_now 1
256
fi
256
fi
257
 
257
 
258
 
258
 
259
### test if $SWAP_PART exists and is a Linux Swap partition
259
### test if $SWAP_PART exists and is a Linux Swap partition
260
### -----------------------------------------------------------
260
### -----------------------------------------------------------
261
if [ $SWAP_PART ]; then
261
if [ $SWAP_PART ]; then
262
    fdisk -l | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
262
    fdisk -l | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
263
    if [ "$?" != "0" ]; then
263
    if [ "$?" != "0" ]; then
264
	echo "Swap partition $SWAP_PART not found! (see 'fdisk -l')."
264
	echo "Swap partition $SWAP_PART not found! (see 'fdisk -l')."
265
	echo "Or you have to reboot first to make the partition table active."
265
	echo "Or you have to reboot first to make the partition table active."
266
	echo
266
	echo
267
	exit_now 1
267
	exit_now 1
268
    fi
268
    fi
269
    fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
269
    fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
270
    if [ "$?" != "0" ]; then
270
    if [ "$?" != "0" ]; then
271
	echo "Partition $SWAP_PART is not a Linux swap partition! (see 'fdisk -l')."
271
	echo "Partition $SWAP_PART is not a Linux swap partition! (see 'fdisk -l')."
272
	echo "Use fdisk and/or qtparted to create a Linux Swap partition !"
272
	echo "Use fdisk and/or qtparted to create a Linux Swap partition !"
273
	echo "You have to reboot first to make the partition table active."
273
	echo "You have to reboot first to make the partition table active."
274
	echo
274
	echo
275
	exit_now 1
275
	exit_now 1
276
    fi
276
    fi
277
fi
277
fi
278
 
278
 
279
 
279
 
280
### set $INSTALL_DEV (eg. /dev/sda)
280
### set $INSTALL_DEV (eg. /dev/sda)
281
### -----------------------------------------------------------
281
### -----------------------------------------------------------
282
INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
282
INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
283
INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
283
INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
284
 
284
 
285
 
285
 
286
### print warning
286
### print warning
287
### -----------------------------------------------------------
287
### -----------------------------------------------------------
288
echo                     "------------------------------------------------------------"
288
echo                     "------------------------------------------------------------"
289
echo                     "   LiveCD will be installed on partition $INSTALL_PART"
289
echo                     "   LiveCD will be installed on partition $INSTALL_PART"
290
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
290
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
291
[ ! $NOGRUB ]    && echo " GRUB will be installed in Master Boot Record of $MBR_DEV"
291
[ ! $NOGRUB ]    && echo " GRUB will be installed in Master Boot Record of $MBR_DEV"
292
echo                     "       !! All data on $INSTALL_PART will be lost !!"
292
echo                     "       !! All data on $INSTALL_PART will be lost !!"
293
echo                     "------------------------------------------------------------"
293
echo                     "------------------------------------------------------------"
294
echo
294
echo
295
 
295
 
296
 
296
 
297
### continue?
297
### continue?
298
### -----------------------------------------------------------
298
### -----------------------------------------------------------
299
if [ ! $YES ]; then
299
if [ ! $YES ]; then
300
    echo -n "Continue (y/N)? "
300
    echo -n "Continue (y/N)? "
301
    read key
301
    read key
302
    echo
302
    echo
303
    [ "$key" != "y" ] && exit_now 0
303
    [ "$key" != "y" ] && exit_now 0
304
fi
304
fi
305
 
305
 
306
 
306
 
307
### format $SWAP_PART (don't format swap, if already formated)
307
### format $SWAP_PART (don't format swap, if already formated)
308
### -----------------------------------------------------------
308
### -----------------------------------------------------------
309
if [ $SWAP_PART ]; then
309
if [ $SWAP_PART ]; then
310
    echo "Make swap on $SWAP_PART ..."
310
    echo "Make swap on $SWAP_PART ..."
311
    swapoff -a >/dev/null 2>&1
311
    swapoff -a >/dev/null 2>&1
312
    swapon $SWAP_PART 2>/dev/null
312
    swapon $SWAP_PART 2>/dev/null
313
    if [ "$?" != "0" ]; then
313
    if [ "$?" != "0" ]; then
314
	echo "Format $SWAP_PART as swap." 
314
	echo "Format $SWAP_PART as swap." 
315
	mkswap $SWAP_PART
315
	mkswap $SWAP_PART
316
    fi
316
    fi
317
    echo
317
    echo
318
fi
318
fi
319
 
319
 
320
 
320
 
321
### format $INSTALL_PART
321
### format $INSTALL_PART
322
### -----------------------------------------------------------
322
### -----------------------------------------------------------
323
echo -n "Format $INSTALL_PART, please wait ... " 
323
echo -n "Format $INSTALL_PART, please wait ... " 
324
mkfs.ext3 -q $INSTALL_PART || exit_now 1
324
mkfs.ext3 -q $INSTALL_PART || exit_now 1
325
echo "done."; echo
325
echo "done."; echo
326
 
326
 
327
 
327
 
328
### mount $INSTALL_PART
328
### mount $INSTALL_PART
329
### -----------------------------------------------------------
329
### -----------------------------------------------------------
330
echo -n "Try to mount $INSTALL_PART to $NEW ... "
330
echo -n "Try to mount $INSTALL_PART to $NEW ... "
331
mkdir -p $NEW
331
mkdir -p $NEW
332
mount $INSTALL_PART $NEW || exit_now 1
332
mount $INSTALL_PART $NEW || exit_now 1
333
echo "done."; echo
333
echo "done."; echo
334
 
334
 
335
 
335
 
336
### copy root dirs
336
### copy root dirs
337
### -----------------------------------------------------------
337
### -----------------------------------------------------------
338
echo "Copy Live System to $INSTALL_PART ..."
338
echo "Copy Live System to $INSTALL_PART ..."
339
root_dirs=$( ls / )
339
root_dirs=$( ls / )
340
for dir in $root_dirs; do
340
for dir in $root_dirs; do
341
    # check if dir is not in $DIR_NOT_COPY
341
    # check if dir is not in $DIR_NOT_COPY
342
    do_not_copy=""
342
    do_not_copy=""
343
    for not_dir in $DIR_NOT_COPY; do
343
    for not_dir in $DIR_NOT_COPY; do
344
	if [ "$not_dir" = "/$dir" ]; then 
344
	if [ "$not_dir" = "/$dir" ]; then 
345
	    do_not_copy="yes"
345
	    do_not_copy="yes"
346
	    break
346
	    break
347
	fi
347
	fi
348
    done
348
    done
349
    # do not copy links
349
    # do not copy links
350
    [ -L /$dir ] && do_not_copy="yes"
350
    [ -L /$dir ] && do_not_copy="yes"
351
 
351
 
352
    fail=""
352
    fail=""
353
    if [ ! $do_not_copy ]; then
353
    if [ ! $do_not_copy ]; then
354
	echo -n "  * Copy  /$dir ... "
354
	echo -n "  * Copy  /$dir ... "
355
	cp -a /$dir $NEW || fail=true
355
	cp -a /$dir $NEW || fail=true
356
	echo "done."
356
	echo "done."
357
    fi
357
    fi
358
done
358
done
359
echo
359
echo
360
if [ $fail ]; then
360
if [ $fail ]; then
361
    echo "ERROR: Not everything was copied to $INSTALL_PART"
361
    echo "ERROR: Not everything was copied to $INSTALL_PART"
362
    exit_now 1
362
    exit_now 1
363
fi
363
fi
364
 
364
 
365
 
365
 
366
### move /usr/opt back to /opt
366
### move /usr/opt back to /opt
367
### -----------------------------------------------------------
367
### -----------------------------------------------------------
368
if [ -d $NEW/usr/opt ]; then
368
if [ -d $NEW/usr/opt ]; then
369
    echo -n "Move /opt back ... "
369
    echo -n "Move /opt back ... "
370
    mv $NEW/usr/opt $NEW/
370
    mv $NEW/usr/opt $NEW/
371
    echo "done."; echo
371
    echo "done."; echo
372
fi
372
fi
373
 
373
 
374
 
374
 
375
### create dirs which were not copied
375
### create dirs which were not copied
376
### -----------------------------------------------------------
376
### -----------------------------------------------------------
377
for dir in $DIR_NOT_COPY; do
377
for dir in $DIR_NOT_COPY; do
378
    mkdir $NEW/$dir
378
    mkdir $NEW/$dir
379
done
379
done
380
# we do not need this directories
380
# we do not need this directories
381
rmdir $NEW/livecd
381
rmdir $NEW/livecd
382
# if not yet existing, create
382
# if not yet existing, create
383
mkdir -p $NEW/srv
383
mkdir -p $NEW/srv
384
mkdir -p $NEW/selinux
384
mkdir -p $NEW/selinux
385
 
385
 
386
 
386
 
387
### copy back original files
387
### copy back original files
388
### -----------------------------------------------------------
388
### -----------------------------------------------------------
389
echo -n "Restore original files ... " 
389
echo -n "Restore original files ... " 
390
for file in $FILES_RESTORE; do
390
for file in $FILES_RESTORE; do
391
    [ -r $NEW/${file}.ori ] && mv -f $NEW/${file}.ori $NEW/${file} 
391
    [ -r $NEW/${file}.ori ] && mv -f $NEW/${file}.ori $NEW/${file} 
392
done
392
done
393
echo "done."; echo
393
echo "done."; echo
394
 
394
 
395
 
395
 
396
### define kernel version
396
### define kernel version
397
### -----------------------------------------------------------
397
### -----------------------------------------------------------
398
rpm --quiet -q kernel     && UP_installed=true
398
rpm --quiet -q kernel     && UP_installed=true
399
rpm --quiet -q kernel-smp && SMP_installed=true
399
rpm --quiet -q kernel-smp && SMP_installed=true
400
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
400
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
401
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
401
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
402
if [ ! $KERNEL_VERSION ]; then
402
if [ ! $KERNEL_VERSION ]; then
403
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
403
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
404
    exit_now 1
404
    exit_now 1
405
fi    
405
fi    
406
 
406
 
407
 
407
 
408
 
408
 
409
if [ ! $NOGRUB ]; then
409
if [ ! $NOGRUB ]; then
410
 
410
 
411
    ### Backup Master Boot Record MBR
411
    ### Backup Master Boot Record MBR
412
    ### -----------------------------------------------------------
412
    ### -----------------------------------------------------------
413
    if [ ! $NOGRUB ]; then
413
    if [ ! $NOGRUB ]; then
414
	# do we have already a backup?
414
	# do we have already a backup?
415
	MBR_FILENAME="MBR$( echo $MBR_DEV | tr / _ ).bak"
415
	MBR_FILENAME="MBR$( echo $MBR_DEV | tr / _ ).bak"
416
	if [ ! -e /tmp/$MBR_FILENAME ]; then
416
	if [ ! -e /tmp/$MBR_FILENAME ]; then
417
	    echo "Backup Master Boot Record (MBR) of $MBR_DEV ..."
417
	    echo "Backup Master Boot Record (MBR) of $MBR_DEV ..."
418
	    dd if=$MBR_DEV of=/tmp/$MBR_FILENAME bs=512 count=1
418
	    dd if=$MBR_DEV of=/tmp/$MBR_FILENAME bs=512 count=1
419
	fi
419
	fi
420
	cp -a /tmp/$MBR_FILENAME $NEW/$MBR_FILENAME
420
	cp -a /tmp/$MBR_FILENAME $NEW/$MBR_FILENAME
421
	echo "MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
421
	echo "MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
422
	echo
422
	echo
423
    fi
423
    fi
424
 
424
 
425
 
425
 
426
    ### install grub
426
    ### install grub
427
    ### -----------------------------------------------------------
427
    ### -----------------------------------------------------------
428
    echo "Run grub-install ... "
428
    echo "Run grub-install ... "
429
    mkdir -p $NEW/boot/grub
429
    mkdir -p $NEW/boot/grub
430
    if [ $FLOPPY ]; then
430
    if [ $FLOPPY ]; then
431
	grub-install --root-directory=$NEW $MBR_DEV
431
	grub-install --root-directory=$NEW $MBR_DEV
432
    else
432
    else
433
	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
433
	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
434
    fi
434
    fi
435
    echo "done."; echo
435
    echo "done."; echo
436
 
436
 
437
 
437
 
438
    ### check for device.map file 
438
    ### check for device.map file 
439
    ### -----------------------------------------------------------
439
    ### -----------------------------------------------------------
440
    DEVICE_MAP=$NEW/boot/grub/device.map
440
    DEVICE_MAP=$NEW/boot/grub/device.map
441
    if [ ! -e $NEW/boot/grub/device.map ]; then
441
    if [ ! -e $NEW/boot/grub/device.map ]; then
442
	echo "ERROR: $NEW/boot/grub/device.map not found"
442
	echo "ERROR: $NEW/boot/grub/device.map not found"
443
	exit_now 1
443
	exit_now 1
444
    fi
444
    fi
445
 
445
 
446
 
446
 
447
    ### convert dev syntax to grub syntax
447
    ### convert dev syntax to grub syntax
448
    ### -----------------------------------------------------------
448
    ### -----------------------------------------------------------
449
    GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
449
    GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
450
    GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
450
    GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
451
 
451
 
452
 
452
 
453
    ### find active Windows partition
453
    ### find active Windows partition
454
    ### -----------------------------------------------------------
454
    ### -----------------------------------------------------------
455
    if [ ! $WIN_PART ]; then
455
    if [ ! $WIN_PART ]; then
456
        # try to find active Windows partition
456
        # try to find active Windows partition
457
	WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
457
	WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
458
    fi
458
    fi
459
 
459
 
460
    if [ $WIN_PART ]; then
460
    if [ $WIN_PART ]; then
461
	WIN_installed=true
461
	WIN_installed=true
462
	WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
462
	WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
463
	WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
463
	WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
464
        # convert dev syntax to grub syntax
464
        # convert dev syntax to grub syntax
465
	GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
465
	GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
466
	GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
466
	GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
467
 
467
 
468
        # $GRUB_WIN_PART should be something like (hd0,0)
468
        # $GRUB_WIN_PART should be something like (hd0,0)
469
	echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
469
	echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
470
	echo "Will add entry for Windows in GRUB."
470
	echo "Will add entry for Windows in GRUB."
471
	echo
471
	echo
472
    fi
472
    fi
473
 
473
 
474
 
474
 
475
    ### create grub.conf file
475
    ### create grub.conf file
476
    ### -----------------------------------------------------------
476
    ### -----------------------------------------------------------
477
    echo "Create grub.conf ..."
477
    echo "Create grub.conf ..."
478
 
478
 
479
    TITLE="Linux"
479
    TITLE="Linux"
480
    [ -e $NEW/etc/redhat-release ] && TITLE=$( cat $NEW/etc/redhat-release )
480
    [ -e $NEW/etc/redhat-release ] && TITLE=$( cat $NEW/etc/redhat-release )
481
 
481
 
482
    DEFAULT=0
482
    DEFAULT=0
483
    # set default=1, if smp kernel is running
483
    # set default=1, if smp kernel is running
484
    uname -r | grep -q smp
484
    uname -r | grep -q smp
485
    [ "$?" = "0" ] && DEFAULT=1
485
    [ "$?" = "0" ] && DEFAULT=1
486
 
486
 
487
    cat > $NEW/boot/grub/grub.conf <<EOF
487
    cat > $NEW/boot/grub/grub.conf <<EOF
488
# grub.conf generated by $SCRIPTNAME
488
# grub.conf generated by $SCRIPTNAME
489
default=$DEFAULT
489
default=$DEFAULT
490
timeout=5
490
timeout=5
491
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
491
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
492
#hiddenmenu
492
#hiddenmenu
493
EOF
493
EOF
494
 
494
 
495
    if [ $UP_installed ]; then
495
    if [ $UP_installed ]; then
496
	echo "Add entry for UP kernel into grub.conf"
496
	echo "Add entry for UP kernel into grub.conf"
497
	cat >> $NEW/boot/grub/grub.conf <<EOF
497
	cat >> $NEW/boot/grub/grub.conf <<EOF
498
title $TITLE (${KERNEL_VERSION})
498
title $TITLE (${KERNEL_VERSION})
499
        root $GRUB_ROOT_PART
499
        root $GRUB_ROOT_PART
500
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
500
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
501
	initrd /boot/initrd-$KERNEL_VERSION.img
501
	initrd /boot/initrd-$KERNEL_VERSION.img
502
EOF
502
EOF
503
    fi
503
    fi
504
 
504
 
505
    if [ $SMP_installed ]; then
505
    if [ $SMP_installed ]; then
506
	echo "Add entry for SMP kernel into grub.conf"
506
	echo "Add entry for SMP kernel into grub.conf"
507
	cat >> $NEW/boot/grub/grub.conf <<EOF
507
	cat >> $NEW/boot/grub/grub.conf <<EOF
508
title $TITLE (${KERNEL_VERSION}smp)
508
title $TITLE (${KERNEL_VERSION}smp)
509
        root $GRUB_ROOT_PART
509
        root $GRUB_ROOT_PART
510
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
510
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
511
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
511
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
512
EOF
512
EOF
513
    fi
513
    fi
514
 
514
 
515
    if [ $WIN_installed ]; then
515
    if [ $WIN_installed ]; then
516
	echo "Add entry for Windows into grub.conf"
516
	echo "Add entry for Windows into grub.conf"
517
	cat >> $NEW/boot/grub/grub.conf <<EOF
517
	cat >> $NEW/boot/grub/grub.conf <<EOF
518
title Windows
518
title Windows
519
        rootnoverify $GRUB_WIN_PART
519
        rootnoverify $GRUB_WIN_PART
520
        chainloader +1
520
        chainloader +1
521
EOF
521
EOF
522
    fi
522
    fi
523
 
523
 
524
    chmod 600 $NEW/boot/grub/grub.conf
524
    chmod 600 $NEW/boot/grub/grub.conf
525
    ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
525
    ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
526
    ln -s ./grub.conf $NEW/boot/grub/menu.lst
526
    ln -s ./grub.conf $NEW/boot/grub/menu.lst
527
    echo "done."; echo
527
    echo "done."; echo
528
 
528
 
529
 
529
 
530
    ### create /etc/sysconfig/grub file
530
    ### create /etc/sysconfig/grub file
531
    ### -----------------------------------------------------------
531
    ### -----------------------------------------------------------
532
    cat > $NEW/etc/sysconfig/grub <<EOF    
532
    cat > $NEW/etc/sysconfig/grub <<EOF    
533
boot=$MBR_DEV
533
boot=$MBR_DEV
534
forcelba=0
534
forcelba=0
535
EOF
535
EOF
536
 
536
 
537
 
537
 
538
fi
538
fi
539
 
539
 
540
 
540
 
541
### install kernel and other files into /boot
541
### install kernel and other files into /boot
542
### -----------------------------------------------------------
542
### -----------------------------------------------------------
543
echo "Install kernel(s) ..."
543
echo "Install kernel(s) ..."
544
 
544
 
545
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
545
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
546
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
546
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
547
 
547
 
548
if [ ! $BOOT_DIR ]; then
548
if [ ! $BOOT_DIR ]; then
549
    echo "ERROR: No kernel found - installation failed"; echo
549
    echo "ERROR: No kernel found - installation failed"; echo
550
    exit_now 1
550
    exit_now 1
551
fi
551
fi
552
 
552
 
553
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
553
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
554
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
554
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
555
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
555
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
556
cp -a $BOOT_DIR/config-*           $NEW/boot/
556
cp -a $BOOT_DIR/config-*           $NEW/boot/
557
cp -a $BOOT_DIR/symvers-*.gz       $NEW/boot/        2>/dev/null
557
cp -a $BOOT_DIR/symvers-*.gz       $NEW/boot/        2>/dev/null
558
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/   2>/dev/null
558
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/   2>/dev/null
559
cp -a $BOOT_DIR/message.ja         $NEW/boot/        2>/dev/null
559
cp -a $BOOT_DIR/message.ja         $NEW/boot/        2>/dev/null
560
cp -a $BOOT_DIR/message            $NEW/boot/        2>/dev/null
560
cp -a $BOOT_DIR/message            $NEW/boot/        2>/dev/null
561
 
561
 
562
echo "done."; echo
562
echo "done."; echo
563
 
563
 
564
 
564
 
565
### create /etc/sysconfig/kernel file
565
### create /etc/sysconfig/kernel file
566
### -----------------------------------------------------------
566
### -----------------------------------------------------------
567
cat > $NEW/etc/sysconfig/kernel <<EOF    
567
cat > $NEW/etc/sysconfig/kernel <<EOF    
568
# UPDATEDEFAULT specifies if new-kernel-pkg should make
568
# UPDATEDEFAULT specifies if new-kernel-pkg should make
569
# new kernels the default
569
# new kernels the default
570
UPDATEDEFAULT=yes
570
UPDATEDEFAULT=yes
571
 
571
 
572
# DEFAULTKERNEL specifies the default kernel package type
572
# DEFAULTKERNEL specifies the default kernel package type
573
DEFAULTKERNEL=kernel
573
DEFAULTKERNEL=kernel
574
EOF
574
EOF
575
 
575
 
576
 
576
 
577
### create /etc/fstab
577
### create /etc/fstab
578
### -----------------------------------------------------------
578
### -----------------------------------------------------------
579
cat > $NEW/etc/fstab <<EOF
579
cat > $NEW/etc/fstab <<EOF
580
$INSTALL_PART         /                    ext3    defaults        1 1
580
$INSTALL_PART         /                    ext3    defaults        1 1
581
devpts            /dev/pts             devpts  gid=5,mode=620  0 0
581
devpts            /dev/pts             devpts  gid=5,mode=620  0 0
582
tmpfs             /dev/shm             tmpfs   defaults        0 0
582
tmpfs             /dev/shm             tmpfs   defaults        0 0
583
proc              /proc                proc    defaults        0 0
583
proc              /proc                proc    defaults        0 0
584
sysfs             /sys                 sysfs   defaults        0 0
584
sysfs             /sys                 sysfs   defaults        0 0
585
EOF
585
EOF
586
if [ $SWAP_PART ]; then
586
if [ $SWAP_PART ]; then
587
    echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
587
    echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
588
fi
588
fi
589
 
589
 
590
 
590
 
591
### make initrd 
591
### make initrd 
592
### (needs $NEW/etc/fstab to find correct modules for root filesystem !!)
592
### (needs $NEW/etc/fstab to find correct modules for root filesystem !!)
593
### -----------------------------------------------------------
593
### -----------------------------------------------------------
594
echo "Create initrd(s) ..."
594
echo "Create initrd(s) ..."
595
# initrd should not be build on tmpfs (we take $NEW/tmp instead of /tmp)
595
# initrd should not be build on tmpfs (we take $NEW/tmp instead of /tmp)
596
sed -i "s|^TMPDIR=.*|TMPDIR=\"$NEW/tmp\"|" /usr/sbin/livecd-mkinitrd
596
sed -i "s|^TMPDIR=.*|TMPDIR=\"$NEW/tmp\"|" /usr/sbin/livecd-mkinitrd
597
 
597
 
598
if [ $UP_installed ]; then
598
if [ $UP_installed ]; then
599
    depmod -a ${KERNEL_VERSION}
599
    depmod -a ${KERNEL_VERSION}
600
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
600
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
601
                    $NEW//boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
601
                    $NEW//boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
602
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
602
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
603
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
603
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
604
	exit_now 1
604
	exit_now 1
605
    fi
605
    fi
606
fi
606
fi
607
if [ $SMP_installed ]; then
607
if [ $SMP_installed ]; then
608
    depmod -a ${KERNEL_VERSION}smp
608
    depmod -a ${KERNEL_VERSION}smp
609
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
609
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
610
                    $NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
610
                    $NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
611
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
611
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
612
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
612
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
613
	exit_now 1
613
	exit_now 1
614
    fi
614
    fi
615
fi
615
fi
616
echo "done."; echo
616
echo "done."; echo
617
 
617
 
618
 
618
 
619
### remove LiveCD init.d scripts
619
### remove LiveCD init.d scripts
620
### -----------------------------------------------------------
620
### -----------------------------------------------------------
621
for file in $LIVECD_INIT_SCRIPTS; do
621
for file in $LIVECD_INIT_SCRIPTS; do
622
    rm -f $NEW/etc/rc.d/init.d/$file
622
    rm -f $NEW/etc/rc.d/init.d/$file
623
    for n in 0 1 2 3 4 5 6; do
623
    for n in 0 1 2 3 4 5 6; do
624
	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
624
	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
625
    done
625
    done
626
done
626
done
627
 
627
 
628
 
628
 
629
### restore cronjobs
629
### restore cronjobs
630
### -----------------------------------------------------------
630
### -----------------------------------------------------------
631
mv $NEW/etc/cron_backup/sysstat $NEW/etc/cron.d/ 2>/dev/null
631
mv $NEW/etc/cron_backup/sysstat       $NEW/etc/cron.d/ 2>/dev/null
-
 
632
mv $NEW/etc/cron_backup/cfengine      $NEW/etc/cron.d/ 2>/dev/null
-
 
633
mv $NEW/etc/cron_backup/psi-cronjobs  $NEW/etc/cron.d/ 2>/dev/null
632
mv $NEW/etc/cron_backup/00-makewhatis.cron.weekly $NEW/etc/cron.weekly/00-makewhatis.cron 2>/dev/null
634
mv $NEW/etc/cron_backup/00-makewhatis.cron.weekly $NEW/etc/cron.weekly/00-makewhatis.cron 2>/dev/null
633
mv $NEW/etc/cron_backup/* $NEW/etc/cron.daily/ 2>/dev/null
635
mv $NEW/etc/cron_backup/*             $NEW/etc/cron.daily/ 2>/dev/null
634
 
636
 
635
 
637
 
636
### prepare chroot to $NEW
638
### prepare chroot to $NEW
637
### -----------------------------------------------------------
639
### -----------------------------------------------------------
638
mount --bind /dev $NEW/dev
640
mount --bind /dev $NEW/dev
639
mount --bind /sys $NEW/sys
641
mount --bind /sys $NEW/sys
640
mount -t proc proc $NEW/proc
642
mount -t proc proc $NEW/proc
641
 
643
 
642
 
644
 
643
### turn on kudzu again
645
### turn on kudzu again
644
### -----------------------------------------------------------
646
### -----------------------------------------------------------
645
chroot $NEW chkconfig kudzu on
647
chroot $NEW chkconfig kudzu on
646
 
648
 
647
 
649
 
-
 
650
### turn on check_update again (only at PSI)
-
 
651
### -----------------------------------------------------------
-
 
652
chroot $NEW chkconfig check_update on 2>/dev/null
-
 
653
 
-
 
654
 
648
### remove some files
655
### remove some files
649
### -----------------------------------------------------------
656
### -----------------------------------------------------------
650
rm -rf $NEW/usr/share/applications/livecd-install-gui.desktop
657
rm -rf $NEW/usr/share/applications/livecd-install-gui.desktop
651
rm -rf $NEW/usr/share/applications/save-localdata.desktop
658
rm -rf $NEW/usr/share/applications/save-localdata.desktop
652
 
659
 
653
 
660
 
654
### remove RPMs that can break future updates  
661
### remove RPMs that can break future updates  
655
### -----------------------------------------------------------
662
### -----------------------------------------------------------
656
if [ ! $NORPMREMOVE ]; then
663
if [ ! $NORPMREMOVE ]; then
657
    echo "Remove RPMs that may break future updates ..."
664
    echo "Remove RPMs that may break future updates ..."
658
    chroot $NEW rpm -qa 2>/dev/null > /tmp/rpmlist
665
    chroot $NEW rpm -qa 2>/dev/null > /tmp/rpmlist
659
 
666
 
660
    # Scientific Linux RPMs
667
    # Scientific Linux RPMs
661
    RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_SL"
668
    RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_SL"
662
 
669
 
663
    # PSI Scientific Linux RPMs
670
    # PSI Scientific Linux RPMs
664
    if [ -e /etc/sysconfig/cfengine ]; then
671
    if [ -e /etc/sysconfig/cfengine ]; then
665
	RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_PSI"
672
	RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_PSI"
666
    fi
673
    fi
667
 
674
 
668
    for rpm in $RPMSTOREMOVE; do
675
    for rpm in $RPMSTOREMOVE; do
669
	rpms_remove=$( cat /tmp/rpmlist | grep "^$rpm" )
676
	rpms_remove=$( cat /tmp/rpmlist | grep "^$rpm" )
670
	for rpm_remove in $rpms_remove; do	
677
	for rpm_remove in $rpms_remove; do	
671
	    chroot $NEW rpm -e --nodeps $rpm_remove >/dev/null 2>&1
678
	    chroot $NEW rpm -e --nodeps $rpm_remove >/dev/null 2>&1
672
	    [ "$?" = "0" ] && echo " removing $rpm_remove"
679
	    [ "$?" = "0" ] && echo " removing $rpm_remove"
673
	done
680
	done
674
    done
681
    done
675
    echo "done."; echo
682
    echo "done."; echo
676
fi
683
fi
677
 
684
 
678
 
685
 
679
### disable nvidia driver 
686
### disable nvidia driver 
680
### -----------------------------------------------------------
687
### -----------------------------------------------------------
681
# not in case of a PSI installation
688
# not in case of a PSI installation
682
if [ ! -e /etc/sysconfig/cfengine ]; then
689
if [ ! -e /etc/sysconfig/psi ]; then
683
    if [ -e $NEW/etc/X11/xorg.conf.nv_SAVED ]; then
690
    if [ -e $NEW/etc/X11/xorg.conf.nv_SAVED ]; then
684
	echo "Remove nvidia driver and correct xorg.conf ..."
691
	echo "Remove nvidia driver and correct xorg.conf ..."
685
        # correct xorg.conf
692
        # correct xorg.conf
686
	sed -i "s/#nv_SAVED //" $NEW/etc/X11/xorg.conf
693
	sed -i "s/#nv_SAVED //" $NEW/etc/X11/xorg.conf
687
	sed -i "/.*Driver.*nvidia.*/d" $NEW/etc/X11/xorg.conf
694
	sed -i "/.*Driver.*nvidia.*/d" $NEW/etc/X11/xorg.conf
688
        # disable nvidia libs (if not yet done by rpm -e)
695
        # disable nvidia libs (if not yet done by rpm -e)
689
	LIB=lib
696
	LIB=lib
690
	[ $( arch ) = "x86_64" ] && LIB=lib64
697
	[ $( arch ) = "x86_64" ] && LIB=lib64
691
	mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libGLcore.a.saved_by_nvidia \
698
	mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libGLcore.a.saved_by_nvidia \
692
              $NEW/usr/X11R6/$LIB/modules/extensions/libGLcore.a 2>/dev/null
699
              $NEW/usr/X11R6/$LIB/modules/extensions/libGLcore.a 2>/dev/null
693
	mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libglx.a.saved_by_nvidia \
700
	mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libglx.a.saved_by_nvidia \
694
              $NEW/usr/X11R6/$LIB/modules/extensions/libglx.a 2>/dev/null
701
              $NEW/usr/X11R6/$LIB/modules/extensions/libglx.a 2>/dev/null
695
	rm -f $NEW/usr/X11R6/$LIB/modules/extensions/libglx.so
702
	rm -f $NEW/usr/X11R6/$LIB/modules/extensions/libglx.so
696
	rm -f $NEW/usr/X11R6/$LIB/libGL.so*
703
	rm -f $NEW/usr/X11R6/$LIB/libGL.so*
697
	rm -f $NEW/usr/$LIB/libGLcore.so
704
	rm -f $NEW/usr/$LIB/libGLcore.so
698
	echo "done."; echo
705
	echo "done."; echo
699
    fi
706
    fi
700
fi
707
fi
701
 
708
 
702
 
709
 
703
### umount $INSTALL_PART
710
### umount $INSTALL_PART
704
### -----------------------------------------------------------
711
### -----------------------------------------------------------
705
umount $NEW/dev
712
umount $NEW/dev
706
umount $NEW/sys
713
umount $NEW/sys
707
umount $NEW/proc
714
umount $NEW/proc
708
umount $INSTALL_PART
715
umount $INSTALL_PART
709
 
716
 
710
 
717
 
711
### print summary
718
### print summary
712
### -----------------------------------------------------------
719
### -----------------------------------------------------------
713
echo                     "--------------------------------------------------------------"
720
echo                     "--------------------------------------------------------------"
714
echo                     "  LiveCD installed on partition $INSTALL_PART"
721
echo                     "  LiveCD installed on partition $INSTALL_PART"
715
[ "$SWAP_PART" ] && echo "  Partition $SWAP_PART will be used as swap partition"
722
[ "$SWAP_PART" ] && echo "  Partition $SWAP_PART will be used as swap partition"
716
echo
723
echo
717
[ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record (MBR) of $MBR_DEV"
724
[ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record (MBR) of $MBR_DEV"
718
[ ! $NOGRUB ]    && echo "  MBR saved as $MBR_FILENAME on $INSTALL_PART and in /tmp"
725
[ ! $NOGRUB ]    && echo "  MBR saved as $MBR_FILENAME on $INSTALL_PART and in /tmp"
719
[ ! $NOGRUB ]    && echo "  If you have to restore MBR, execute under Linux:"
726
[ ! $NOGRUB ]    && echo "  If you have to restore MBR, execute under Linux:"
720
[ ! $NOGRUB ]    && echo "  # dd if=$MBR_FILENAME of=$MBR_DEV bs=512 count=1"
727
[ ! $NOGRUB ]    && echo "  # dd if=$MBR_FILENAME of=$MBR_DEV bs=512 count=1"
721
echo 
728
echo 
722
[ $WIN_PART ]    && echo "  Entry created in grub.conf for Windows partition $WIN_PART"
729
[ $WIN_PART ]    && echo "  Entry created in grub.conf for Windows partition $WIN_PART"
723
echo                     "--------------------------------------------------------------"
730
echo                     "--------------------------------------------------------------"
724
echo                     "End of $SCRIPTNAME"
731
echo                     "End of $SCRIPTNAME"
725
echo
732
echo