Subversion Repositories livecd

Rev

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

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