Subversion Repositories livecd

Rev

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

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