Subversion Repositories livecd

Rev

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

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