Subversion Repositories livecd

Rev

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

Rev 63 Rev 65
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
307
### format $SWAP_PART
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
    mkswap $SWAP_PART
311
    mkswap $SWAP_PART
312
    echo
312
    echo
313
fi
313
fi
314
 
314
 
315
 
315
 
316
### format $INSTALL_PART
316
### format $INSTALL_PART
317
### -----------------------------------------------------------
317
### -----------------------------------------------------------
318
echo -n "Format $INSTALL_PART, please wait ... " 
318
echo -n "Format $INSTALL_PART, please wait ... " 
319
mkfs.ext3 -q $INSTALL_PART || exit_now 1
319
mkfs.ext3 -q $INSTALL_PART || exit_now 1
320
echo "done."; echo
320
echo "done."; echo
321
 
321
 
322
 
322
 
323
### mount $INSTALL_PART
323
### mount $INSTALL_PART
324
### -----------------------------------------------------------
324
### -----------------------------------------------------------
325
echo -n "Try to mount $INSTALL_PART to $NEW ... "
325
echo -n "Try to mount $INSTALL_PART to $NEW ... "
326
mkdir -p $NEW
326
mkdir -p $NEW
327
mount $INSTALL_PART $NEW || exit_now 1
327
mount $INSTALL_PART $NEW || exit_now 1
328
echo "done."; echo
328
echo "done."; echo
329
 
329
 
330
 
330
 
331
### copy root dirs
331
### copy root dirs
332
### -----------------------------------------------------------
332
### -----------------------------------------------------------
333
echo "Copy Live System to $INSTALL_PART ..."
333
echo "Copy Live System to $INSTALL_PART ..."
334
root_dirs=$( ls / )
334
root_dirs=$( ls / )
335
for dir in $root_dirs; do
335
for dir in $root_dirs; do
336
    # check if dir is not in $DIR_NOT_COPY
336
    # check if dir is not in $DIR_NOT_COPY
337
    do_not_copy=""
337
    do_not_copy=""
338
    for not_dir in $DIR_NOT_COPY; do
338
    for not_dir in $DIR_NOT_COPY; do
339
	if [ "$not_dir" = "/$dir" ]; then 
339
	if [ "$not_dir" = "/$dir" ]; then 
340
	    do_not_copy="yes"
340
	    do_not_copy="yes"
341
	    break
341
	    break
342
	fi
342
	fi
343
    done
343
    done
344
    # do not copy links
344
    # do not copy links
345
    [ -L /$dir ] && do_not_copy="yes"
345
    [ -L /$dir ] && do_not_copy="yes"
346
 
346
 
347
    fail=""
347
    fail=""
348
    if [ ! $do_not_copy ]; then
348
    if [ ! $do_not_copy ]; then
349
	echo -n "  * Copy  /$dir ... "
349
	echo -n "  * Copy  /$dir ... "
350
	cp -a /$dir $NEW || fail=true
350
	cp -a /$dir $NEW || fail=true
351
	echo "done."
351
	echo "done."
352
    fi
352
    fi
353
done
353
done
354
echo
354
echo
355
if [ $fail ]; then
355
if [ $fail ]; then
356
    echo "ERROR: Not everything was copied to $INSTALL_PART"
356
    echo "ERROR: Not everything was copied to $INSTALL_PART"
357
    exit_now 1
357
    exit_now 1
358
fi
358
fi
359
 
359
 
360
 
360
 
361
### move /usr/opt back to /opt
361
### move /usr/opt back to /opt
362
### -----------------------------------------------------------
362
### -----------------------------------------------------------
363
if [ -d $NEW/usr/opt ]; then
363
if [ -d $NEW/usr/opt ]; then
364
    echo -n "Move /opt back ... "
364
    echo -n "Move /opt back ... "
365
    mv $NEW/usr/opt $NEW/
365
    mv $NEW/usr/opt $NEW/
366
    echo "done."; echo
366
    echo "done."; echo
367
fi
367
fi
368
 
368
 
369
 
369
 
370
### create dirs which were not copied
370
### create dirs which were not copied
371
### -----------------------------------------------------------
371
### -----------------------------------------------------------
372
for dir in $DIR_NOT_COPY; do
372
for dir in $DIR_NOT_COPY; do
373
    mkdir $NEW/$dir
373
    mkdir $NEW/$dir
374
done
374
done
375
# we do not need this directories
375
# we do not need this directories
376
rmdir $NEW/livecd
376
rmdir $NEW/livecd
377
# if not yet existing, create
377
# if not yet existing, create
378
mkdir -p $NEW/srv
378
mkdir -p $NEW/srv
379
mkdir -p $NEW/selinux
379
mkdir -p $NEW/selinux
380
 
380
 
381
 
381
 
382
### copy back original files
382
### copy back original files
383
### -----------------------------------------------------------
383
### -----------------------------------------------------------
384
echo -n "Restore original files ... " 
384
echo -n "Restore original files ... " 
385
for file in $FILES_RESTORE; do
385
for file in $FILES_RESTORE; do
386
    [ -r $NEW/${file}.ori ] && mv -f $NEW/${file}.ori $NEW/${file} 
386
    [ -r $NEW/${file}.ori ] && mv -f $NEW/${file}.ori $NEW/${file} 
387
done
387
done
388
echo "done."; echo
388
echo "done."; echo
389
 
389
 
390
 
390
 
391
### define kernel version
391
### define kernel version
392
### -----------------------------------------------------------
392
### -----------------------------------------------------------
393
rpm --quiet -q kernel     && UP_installed=true
393
rpm --quiet -q kernel     && UP_installed=true
394
rpm --quiet -q kernel-smp && SMP_installed=true
394
rpm --quiet -q kernel-smp && SMP_installed=true
395
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
395
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
396
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
396
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
397
if [ ! $KERNEL_VERSION ]; then
397
if [ ! $KERNEL_VERSION ]; then
398
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
398
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
399
    exit_now 1
399
    exit_now 1
400
fi    
400
fi    
401
 
401
 
402
 
402
 
403
 
403
 
404
if [ ! $NOGRUB ]; then
404
if [ ! $NOGRUB ]; then
405
 
405
 
406
    ### Backup Master Boot Record MBR
406
    ### Backup Master Boot Record MBR
407
    ### -----------------------------------------------------------
407
    ### -----------------------------------------------------------
408
    if [ ! $NOGRUB ]; then
408
    if [ ! $NOGRUB ]; then
409
	# do we have already a backup?
409
	# do we have already a backup?
410
	MBR_FILENAME="MBR$( echo $MBR_DEV | tr / _ ).bak"
410
	MBR_FILENAME="MBR$( echo $MBR_DEV | tr / _ ).bak"
411
	if [ ! -e /tmp/$MBR_FILENAME ]; then
411
	if [ ! -e /tmp/$MBR_FILENAME ]; then
412
	    echo "Backup Master Boot Record (MBR) of $MBR_DEV ..."
412
	    echo "Backup Master Boot Record (MBR) of $MBR_DEV ..."
413
	    dd if=$MBR_DEV of=/tmp/$MBR_FILENAME bs=512 count=1
413
	    dd if=$MBR_DEV of=/tmp/$MBR_FILENAME bs=512 count=1
414
	fi
414
	fi
415
	cp -a /tmp/$MBR_FILENAME $NEW/$MBR_FILENAME
415
	cp -a /tmp/$MBR_FILENAME $NEW/$MBR_FILENAME
416
	echo "MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
416
	echo "MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
417
	echo
417
	echo
418
    fi
418
    fi
419
 
419
 
420
 
420
 
421
    ### install grub
421
    ### install grub
422
    ### -----------------------------------------------------------
422
    ### -----------------------------------------------------------
423
    echo "Run grub-install ... "
423
    echo "Run grub-install ... "
424
    mkdir -p $NEW/boot/grub
424
    mkdir -p $NEW/boot/grub
425
    if [ $FLOPPY ]; then
425
    if [ $FLOPPY ]; then
426
	grub-install --root-directory=$NEW $MBR_DEV
426
	grub-install --root-directory=$NEW $MBR_DEV
427
    else
427
    else
428
	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
428
	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
429
    fi
429
    fi
430
    echo "done."; echo
430
    echo "done."; echo
431
 
431
 
432
 
432
 
433
    ### check for device.map file 
433
    ### check for device.map file 
434
    ### -----------------------------------------------------------
434
    ### -----------------------------------------------------------
435
    DEVICE_MAP=$NEW/boot/grub/device.map
435
    DEVICE_MAP=$NEW/boot/grub/device.map
436
    if [ ! -e $NEW/boot/grub/device.map ]; then
436
    if [ ! -e $NEW/boot/grub/device.map ]; then
437
	echo "ERROR: $NEW/boot/grub/device.map not found"
437
	echo "ERROR: $NEW/boot/grub/device.map not found"
438
	exit_now 1
438
	exit_now 1
439
    fi
439
    fi
440
 
440
 
441
 
441
 
442
    ### convert dev syntax to grub syntax
442
    ### convert dev syntax to grub syntax
443
    ### -----------------------------------------------------------
443
    ### -----------------------------------------------------------
444
    GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
444
    GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
445
    GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
445
    GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
446
 
446
 
447
 
447
 
448
    ### find active Windows partition
448
    ### find active Windows partition
449
    ### -----------------------------------------------------------
449
    ### -----------------------------------------------------------
450
    if [ ! $WIN_PART ]; then
450
    if [ ! $WIN_PART ]; then
451
        # try to find active Windows partition
451
        # try to find active Windows partition
452
	WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
452
	WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
453
    fi
453
    fi
454
 
454
 
455
    if [ $WIN_PART ]; then
455
    if [ $WIN_PART ]; then
456
	WIN_installed=true
456
	WIN_installed=true
457
	WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
457
	WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
458
	WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
458
	WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
459
        # convert dev syntax to grub syntax
459
        # convert dev syntax to grub syntax
460
	GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
460
	GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
461
	GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
461
	GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
462
 
462
 
463
        # $GRUB_WIN_PART should be something like (hd0,0)
463
        # $GRUB_WIN_PART should be something like (hd0,0)
464
	echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
464
	echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
465
	echo "Will add entry for Windows in GRUB."
465
	echo "Will add entry for Windows in GRUB."
466
	echo
466
	echo
467
    fi
467
    fi
468
 
468
 
469
 
469
 
470
    ### create grub.conf file
470
    ### create grub.conf file
471
    ### -----------------------------------------------------------
471
    ### -----------------------------------------------------------
472
    echo "Create grub.conf ..."
472
    echo "Create grub.conf ..."
473
 
473
 
474
    TITLE="Linux"
474
    TITLE="Linux"
475
    [ -e $NEW//etc/redhat-release ] && TITLE=$( cat $NEW/etc/redhat-release )
475
    [ -e $NEW//etc/redhat-release ] && TITLE=$( cat $NEW/etc/redhat-release )
476
 
476
 
477
    DEFAULT=0
477
    DEFAULT=0
478
    # set default=1, if smp kernel is running
478
    # set default=1, if smp kernel is running
479
    uname -r | grep -q smp
479
    uname -r | grep -q smp
480
    [ "$?" = "0" ] && DEFAULT=1
480
    [ "$?" = "0" ] && DEFAULT=1
481
 
481
 
482
    cat > $NEW/boot/grub/grub.conf <<EOF
482
    cat > $NEW/boot/grub/grub.conf <<EOF
483
# grub.conf generated by $SCRIPTNAME
483
# grub.conf generated by $SCRIPTNAME
484
default=$DEFAULT
484
default=$DEFAULT
485
timeout=5
485
timeout=5
486
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
486
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
487
#hiddenmenu
487
#hiddenmenu
488
EOF
488
EOF
489
 
489
 
490
    if [ $UP_installed ]; then
490
    if [ $UP_installed ]; then
491
	echo "Add entry for UP kernel into grub.conf"
491
	echo "Add entry for UP kernel into grub.conf"
492
	cat >> $NEW/boot/grub/grub.conf <<EOF
492
	cat >> $NEW/boot/grub/grub.conf <<EOF
493
title $TITLE (${KERNEL_VERSION})
493
title $TITLE (${KERNEL_VERSION})
494
        root $GRUB_ROOT_PART
494
        root $GRUB_ROOT_PART
495
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
495
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
496
	initrd /boot/initrd-$KERNEL_VERSION.img
496
	initrd /boot/initrd-$KERNEL_VERSION.img
497
EOF
497
EOF
498
    fi
498
    fi
499
 
499
 
500
    if [ $SMP_installed ]; then
500
    if [ $SMP_installed ]; then
501
	echo "Add entry for SMP kernel into grub.conf"
501
	echo "Add entry for SMP kernel into grub.conf"
502
	cat >> $NEW/boot/grub/grub.conf <<EOF
502
	cat >> $NEW/boot/grub/grub.conf <<EOF
503
title $TITLE (${KERNEL_VERSION}smp)
503
title $TITLE (${KERNEL_VERSION}smp)
504
        root $GRUB_ROOT_PART
504
        root $GRUB_ROOT_PART
505
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
505
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
506
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
506
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
507
EOF
507
EOF
508
    fi
508
    fi
509
 
509
 
510
    if [ $WIN_installed ]; then
510
    if [ $WIN_installed ]; then
511
	echo "Add entry for Windows into grub.conf"
511
	echo "Add entry for Windows into grub.conf"
512
	cat >> $NEW/boot/grub/grub.conf <<EOF
512
	cat >> $NEW/boot/grub/grub.conf <<EOF
513
title Windows
513
title Windows
514
        rootnoverify $GRUB_WIN_PART
514
        rootnoverify $GRUB_WIN_PART
515
        chainloader +1
515
        chainloader +1
516
EOF
516
EOF
517
    fi
517
    fi
518
 
518
 
519
    chmod 600 $NEW/boot/grub/grub.conf
519
    chmod 600 $NEW/boot/grub/grub.conf
520
    ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
520
    ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
521
    ln -s ./grub.conf $NEW/boot/grub/menu.lst
521
    ln -s ./grub.conf $NEW/boot/grub/menu.lst
522
    echo "done."; echo
522
    echo "done."; echo
523
 
523
 
524
 
524
 
525
    ### create /etc/sysconfig/grub file
525
    ### create /etc/sysconfig/grub file
526
    ### -----------------------------------------------------------
526
    ### -----------------------------------------------------------
527
    cat > $NEW/etc/sysconfig/grub <<EOF    
527
    cat > $NEW/etc/sysconfig/grub <<EOF    
528
boot=$MBR_DEV
528
boot=$MBR_DEV
529
forcelba=0
529
forcelba=0
530
EOF
530
EOF
531
 
531
 
532
 
532
 
533
fi
533
fi
534
 
534
 
535
 
535
 
536
### install kernel and other files into /boot
536
### install kernel and other files into /boot
537
### -----------------------------------------------------------
537
### -----------------------------------------------------------
538
echo "Install kernel(s) ..."
538
echo "Install kernel(s) ..."
539
 
539
 
540
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
540
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
541
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
541
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
542
 
542
 
543
if [ ! $BOOT_DIR ]; then
543
if [ ! $BOOT_DIR ]; then
544
    echo "ERROR: No kernel found - installation failed"; echo
544
    echo "ERROR: No kernel found - installation failed"; echo
545
    exit_now 1
545
    exit_now 1
546
fi
546
fi
547
 
547
 
548
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
548
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
549
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
549
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
550
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
550
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
551
cp -a $BOOT_DIR/config-*           $NEW/boot/
551
cp -a $BOOT_DIR/config-*           $NEW/boot/
552
cp -a $BOOT_DIR/symvers-*.gz       $NEW/boot/        2>/dev/null
552
cp -a $BOOT_DIR/symvers-*.gz       $NEW/boot/        2>/dev/null
553
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
553
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
554
cp -a $BOOT_DIR/message.ja         $NEW/boot/        2>/dev/null
554
cp -a $BOOT_DIR/message.ja         $NEW/boot/        2>/dev/null
555
cp -a $BOOT_DIR/message            $NEW/boot/        2>/dev/null
555
cp -a $BOOT_DIR/message            $NEW/boot/        2>/dev/null
556
 
556
 
557
echo "done."; echo
557
echo "done."; echo
558
 
558
 
559
 
559
 
560
### create /etc/sysconfig/kernel file
560
### create /etc/sysconfig/kernel file
561
### -----------------------------------------------------------
561
### -----------------------------------------------------------
562
cat > $NEW/etc/sysconfig/kernel <<EOF    
562
cat > $NEW/etc/sysconfig/kernel <<EOF    
563
# UPDATEDEFAULT specifies if new-kernel-pkg should make
563
# UPDATEDEFAULT specifies if new-kernel-pkg should make
564
# new kernels the default
564
# new kernels the default
565
UPDATEDEFAULT=yes
565
UPDATEDEFAULT=yes
566
 
566
 
567
# DEFAULTKERNEL specifies the default kernel package type
567
# DEFAULTKERNEL specifies the default kernel package type
568
DEFAULTKERNEL=kernel
568
DEFAULTKERNEL=kernel
569
EOF
569
EOF
570
 
570
 
571
 
571
 
572
### create /etc/fstab
572
### create /etc/fstab
573
### -----------------------------------------------------------
573
### -----------------------------------------------------------
574
cat > $NEW/etc/fstab <<EOF
574
cat > $NEW/etc/fstab <<EOF
575
$INSTALL_PART         /                    ext3    defaults        1 1
575
$INSTALL_PART         /                    ext3    defaults        1 1
576
devpts            /dev/pts             devpts  gid=5,mode=620  0 0
576
devpts            /dev/pts             devpts  gid=5,mode=620  0 0
577
tmpfs             /dev/shm             tmpfs   defaults        0 0
577
tmpfs             /dev/shm             tmpfs   defaults        0 0
578
proc              /proc                proc    defaults        0 0
578
proc              /proc                proc    defaults        0 0
579
sysfs             /sys                 sysfs   defaults        0 0
579
sysfs             /sys                 sysfs   defaults        0 0
580
EOF
580
EOF
581
if [ $SWAP_PART ]; then
581
if [ $SWAP_PART ]; then
582
    echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
582
    echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
583
fi
583
fi
584
 
584
 
585
 
585
 
586
### make initrd 
586
### make initrd 
587
### (needs $NEW/etc/fstab to find correct modules for root filesystem !!)
587
### (needs $NEW/etc/fstab to find correct modules for root filesystem !!)
588
### -----------------------------------------------------------
588
### -----------------------------------------------------------
589
echo "Create initrd(s) ..."
589
echo "Create initrd(s) ..."
590
# initrd should not be build on tmpfs (we take $NEW/tmp instead of /tmp)
590
# initrd should not be build on tmpfs (we take $NEW/tmp instead of /tmp)
591
sed -i "s|^TMPDIR=.*|TMPDIR=\"$NEW/tmp\"|" /usr/sbin/livecd-mkinitrd
591
sed -i "s|^TMPDIR=.*|TMPDIR=\"$NEW/tmp\"|" /usr/sbin/livecd-mkinitrd
592
 
592
 
593
if [ $UP_installed ]; then
593
if [ $UP_installed ]; then
594
    depmod -a ${KERNEL_VERSION}
594
    depmod -a ${KERNEL_VERSION}
595
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
595
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
596
                    $NEW//boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
596
                    $NEW//boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
597
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
597
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
598
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
598
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
599
	exit_now 1
599
	exit_now 1
600
    fi
600
    fi
601
fi
601
fi
602
if [ $SMP_installed ]; then
602
if [ $SMP_installed ]; then
603
    depmod -a ${KERNEL_VERSION}smp
603
    depmod -a ${KERNEL_VERSION}smp
604
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
604
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
605
                    $NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
605
                    $NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
606
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
606
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
607
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
607
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
608
	exit_now 1
608
	exit_now 1
609
    fi
609
    fi
610
fi
610
fi
611
echo "done."; echo
611
echo "done."; echo
612
 
612
 
613
 
613
 
614
### remove LiveCD init.d scripts
614
### remove LiveCD init.d scripts
615
### -----------------------------------------------------------
615
### -----------------------------------------------------------
616
for file in $LIVECD_INIT_SCRIPTS; do
616
for file in $LIVECD_INIT_SCRIPTS; do
617
    rm -f $NEW/etc/rc.d/init.d/$file
617
    rm -f $NEW/etc/rc.d/init.d/$file
618
    for n in 0 1 2 3 4 5 6; do
618
    for n in 0 1 2 3 4 5 6; do
619
	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
619
	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
620
    done
620
    done
621
done
621
done
622
 
622
 
623
 
623
 
624
### restore cronjobs
624
### restore cronjobs
625
### -----------------------------------------------------------
625
### -----------------------------------------------------------
626
mv $NEW/etc/cron_backup/sysstat $NEW/etc/cron.d/ 2>/dev/null
626
mv $NEW/etc/cron_backup/sysstat $NEW/etc/cron.d/ 2>/dev/null
627
mv $NEW/etc/cron_backup/00-makewhatis.cron.weekly $NEW/etc/cron.weekly/00-makewhatis.cron 2>/dev/null
627
mv $NEW/etc/cron_backup/00-makewhatis.cron.weekly $NEW/etc/cron.weekly/00-makewhatis.cron 2>/dev/null
628
mv $NEW/etc/cron_backup/* $NEW/etc/cron.daily/ 2>/dev/null
628
mv $NEW/etc/cron_backup/* $NEW/etc/cron.daily/ 2>/dev/null
629
 
629
 
630
 
630
 
631
### prepare chroot to $NEW
631
### prepare chroot to $NEW
632
### -----------------------------------------------------------
632
### -----------------------------------------------------------
633
mount --bind /dev $NEW/dev
633
mount --bind /dev $NEW/dev
634
mount --bind /sys $NEW/sys
634
mount --bind /sys $NEW/sys
635
mount -t proc proc $NEW/proc
635
mount -t proc proc $NEW/proc
636
 
636
 
637
 
637
 
638
### turn on kudzu again
638
### turn on kudzu again
639
### -----------------------------------------------------------
639
### -----------------------------------------------------------
640
chroot $NEW chkconfig kudzu on
640
chroot $NEW chkconfig kudzu on
641
 
641
 
642
 
642
 
-
 
643
### remove some files
-
 
644
### -----------------------------------------------------------
-
 
645
rm -rf $NEW/usr/share/applications/livecd-install-gui.desktop
-
 
646
rm -rf $NEW/usr/share/applications/save-localdata.desktop
-
 
647
 
-
 
648
 
643
### remove RPMs that can break future updates  
649
### remove RPMs that can break future updates  
644
### -----------------------------------------------------------
650
### -----------------------------------------------------------
645
if [ ! $NORPMREMOVE ]; then
651
if [ ! $NORPMREMOVE ]; then
646
    echo "Remove RPMs that may break future updates ..."
652
    echo "Remove RPMs that may break future updates ..."
647
    chroot $NEW rpm -qa 2>/dev/null > /tmp/rpmlist
653
    chroot $NEW rpm -qa 2>/dev/null > /tmp/rpmlist
648
 
654
 
649
    # Scientific Linux RPMs
655
    # Scientific Linux RPMs
650
    RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_SL"
656
    RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_SL"
651
 
657
 
652
    # PSI Scientific Linux RPMs
658
    # PSI Scientific Linux RPMs
653
    if [ -e /etc/sysconfig/cfengine ]; then
659
    if [ -e /etc/sysconfig/cfengine ]; then
654
	RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_PSI"
660
	RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_PSI"
655
    fi
661
    fi
656
 
662
 
657
    for rpm in $RPMSTOREMOVE; do
663
    for rpm in $RPMSTOREMOVE; do
658
	rpms_remove=$( cat /tmp/rpmlist | grep "^$rpm" )
664
	rpms_remove=$( cat /tmp/rpmlist | grep "^$rpm" )
659
	for rpm_remove in $rpms_remove; do	
665
	for rpm_remove in $rpms_remove; do	
660
	    chroot $NEW rpm -e --nodeps $rpm_remove >/dev/null 2>&1
666
	    chroot $NEW rpm -e --nodeps $rpm_remove >/dev/null 2>&1
661
	    [ "$?" = "0" ] && echo " removing $rpm_remove"
667
	    [ "$?" = "0" ] && echo " removing $rpm_remove"
662
	done
668
	done
663
    done
669
    done
664
    echo "done."; echo
670
    echo "done."; echo
665
fi
671
fi
666
 
672
 
667
 
673
 
668
### disable nvidia driver 
674
### disable nvidia driver 
669
### -----------------------------------------------------------
675
### -----------------------------------------------------------
670
# not in case of a PSI installation
676
# not in case of a PSI installation
671
if [ ! -e /etc/sysconfig/cfengine ]; then
677
if [ ! -e /etc/sysconfig/cfengine ]; then
672
    if [ -e $NEW/etc/X11/xorg.conf.nv_SAVED ]; then
678
    if [ -e $NEW/etc/X11/xorg.conf.nv_SAVED ]; then
673
	echo "Remove nvidia driver and correct xorg.conf ..."
679
	echo "Remove nvidia driver and correct xorg.conf ..."
674
        # correct xorg.conf
680
        # correct xorg.conf
675
	sed -i "s/#nv_SAVED //" $NEW/etc/X11/xorg.conf
681
	sed -i "s/#nv_SAVED //" $NEW/etc/X11/xorg.conf
676
	sed -i "/.*Driver.*nvidia.*/d" $NEW/etc/X11/xorg.conf
682
	sed -i "/.*Driver.*nvidia.*/d" $NEW/etc/X11/xorg.conf
677
        # disable nvidia libs (if not yet done by rpm -e)
683
        # disable nvidia libs (if not yet done by rpm -e)
678
	LIB=lib
684
	LIB=lib
679
	[ $( arch ) = "x86_64" ] && LIB=lib64
685
	[ $( arch ) = "x86_64" ] && LIB=lib64
680
	mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libGLcore.a.saved_by_nvidia \
686
	mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libGLcore.a.saved_by_nvidia \
681
              $NEW/usr/X11R6/$LIB/modules/extensions/libGLcore.a 2>/dev/null
687
              $NEW/usr/X11R6/$LIB/modules/extensions/libGLcore.a 2>/dev/null
682
	mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libglx.a.saved_by_nvidia \
688
	mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libglx.a.saved_by_nvidia \
683
              $NEW/usr/X11R6/$LIB/modules/extensions/libglx.a 2>/dev/null
689
              $NEW/usr/X11R6/$LIB/modules/extensions/libglx.a 2>/dev/null
684
	rm -f $NEW/usr/X11R6/$LIB/modules/extensions/libglx.so
690
	rm -f $NEW/usr/X11R6/$LIB/modules/extensions/libglx.so
685
	rm -f $NEW/usr/X11R6/$LIB/libGL.so*
691
	rm -f $NEW/usr/X11R6/$LIB/libGL.so*
686
	rm -f $NEW/usr/$LIB/libGLcore.so
692
	rm -f $NEW/usr/$LIB/libGLcore.so
687
	echo "done."; echo
693
	echo "done."; echo
688
    fi
694
    fi
689
fi
695
fi
690
 
696
 
691
 
697
 
692
### umount $INSTALL_PART
698
### umount $INSTALL_PART
693
### -----------------------------------------------------------
699
### -----------------------------------------------------------
694
umount $NEW/dev
700
umount $NEW/dev
695
umount $NEW/sys
701
umount $NEW/sys
696
umount $NEW/proc
702
umount $NEW/proc
697
umount $INSTALL_PART
703
umount $INSTALL_PART
698
 
704
 
699
 
705
 
700
### print summary
706
### print summary
701
### -----------------------------------------------------------
707
### -----------------------------------------------------------
702
echo                     "--------------------------------------------------------------"
708
echo                     "--------------------------------------------------------------"
703
echo                     "  LiveCD installed on partition $INSTALL_PART"
709
echo                     "  LiveCD installed on partition $INSTALL_PART"
704
[ "$SWAP_PART" ] && echo "  Partition $SWAP_PART will be used as swap partition"
710
[ "$SWAP_PART" ] && echo "  Partition $SWAP_PART will be used as swap partition"
705
echo
711
echo
706
[ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record (MBR) of $MBR_DEV"
712
[ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record (MBR) of $MBR_DEV"
707
[ ! $NOGRUB ]    && echo "  MBR saved as $MBR_FILENAME on $INSTALL_PART and in /tmp"
713
[ ! $NOGRUB ]    && echo "  MBR saved as $MBR_FILENAME on $INSTALL_PART and in /tmp"
708
[ ! $NOGRUB ]    && echo "  If you have to restore MBR, execute under Linux:"
714
[ ! $NOGRUB ]    && echo "  If you have to restore MBR, execute under Linux:"
709
[ ! $NOGRUB ]    && echo "  # dd if=$MBR_FILENAME of=$MBR_DEV bs=512 count=1"
715
[ ! $NOGRUB ]    && echo "  # dd if=$MBR_FILENAME of=$MBR_DEV bs=512 count=1"
710
echo 
716
echo 
711
[ $WIN_PART ]    && echo "  Entry created in grub.conf for Windows partition $WIN_PART"
717
[ $WIN_PART ]    && echo "  Entry created in grub.conf for Windows partition $WIN_PART"
712
echo                     "--------------------------------------------------------------"
718
echo                     "--------------------------------------------------------------"
713
echo                     "End of $SCRIPTNAME"
719
echo                     "End of $SCRIPTNAME"
714
echo
720
echo