Subversion Repositories livecd

Rev

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

Rev 17 Rev 18
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
###############################################################
3
###############################################################
4
#
4
#
5
# Installes the LiveCD on local harddisk
5
# Installes the LiveCD on local harddisk
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
# files which should be restored from .ori files
18
# files which should be restored from .ori files
19
FILES_RESTORE="/etc/init.d/netfs \
19
FILES_RESTORE="/etc/init.d/netfs \
20
           /etc/init.d/autofs \
20
           /etc/init.d/autofs \
21
           /etc/init.d/halt \
21
           /etc/init.d/halt \
22
           /etc/init.d/network
22
           /etc/init.d/network
23
           /etc/init.d/functions \
23
           /etc/init.d/functions \
24
           /etc/rc.d/rc.sysinit \
24
           /etc/rc.d/rc.sysinit \
25
           /etc/sysconfig/afs \
25
           /etc/sysconfig/afs \
26
           /etc/motd \
26
           /etc/motd \
27
           /etc/redhat-release \
27
           /etc/redhat-release \
28
	   /etc/rc.d/rc.local \
28
	   /etc/rc.d/rc.local \
29
           /etc/rc.d/rc.sysinit"
29
           /etc/rc.d/rc.sysinit"
30
 
30
 
31
LIVECD_INIT_SCRIPTS="runfirst \
31
LIVECD_INIT_SCRIPTS="runfirst \
32
                    runveryfirst \
32
                    runveryfirst \
33
                    runlast \
33
                    runlast \
34
                    kudzu-auto"
34
                    kudzu-auto"
35
 
35
 
36
# Main directories which should be not be copied
36
# Main directories which should be not be copied
37
DIR_NOT_COPY="/proc \
37
DIR_NOT_COPY="/proc \
38
              /dev \
38
              /dev \
39
              /livecd \
39
              /livecd \
40
              /boot \
40
              /boot \
41
              /afs \
41
              /afs \
42
              /sys \
42
              /sys \
43
              /mnt \
43
              /mnt \
44
              /media"
44
              /media"
45
 
45
 
46
# Mount point of the new SL system
46
# Mount point of the new SL system
47
NEW=/mnt/harddisk
47
NEW=/mnt/harddisk
48
 
48
 
49
SCRIPTNAME=$( basename $0 )
49
SCRIPTNAME=$( basename $0 )
50
 
50
 
51
 
51
 
52
 
52
 
53
###############################################################
53
###############################################################
54
# Functions
54
# Functions
55
###############################################################
55
###############################################################
56
 
56
 
57
function usage() {
57
function usage() {
58
 
58
 
59
   ## Usage
59
   ## Usage
60
   # ----------------------------------------------------------
60
   # ----------------------------------------------------------
61
 
61
 
62
   cat <<EOF
62
   cat <<EOF
63
 
63
 
64
   $SCRIPTNAME [OPTIONS] -mbr [DEVICE] [PARTITION]
64
   $SCRIPTNAME [OPTIONS] -mbr [DEVICE] [PARTITION]
65
 
65
 
66
   Installes LiveCD on PARTITION and the boot loader grub
66
   Installes LiveCD on PARTITION and the boot loader grub
67
   into the Master Boot Record (MBR) of DEVICE.
67
   into the Master Boot Record (MBR) of DEVICE.
68
 
68
 
69
   OPTIONS:
69
   OPTIONS:
70
 
70
 
71
    -h                  print this screen
71
    -h                  print this screen
72
    -swap [partition]  	use [partition] as swap
72
    -swap [partition]  	use [partition] as swap
73
    -nogrub             do not install grub
73
    -nogrub             do not install grub (leave MBR untouched) 
-
 
74
    -floppy             need, if grub should be isntalled on a floopy
74
    -y                  answer all questions with yes
75
    -y                  answer all questions with yes
75
 
76
 
76
EOF
77
EOF
77
}
78
}
78
 
79
 
79
 
80
 
80
###############################################################
81
###############################################################
81
# Main
82
# Main
82
###############################################################
83
###############################################################
83
 
84
 
84
### are we root?
85
### are we root?
85
### -----------------------------------------------------------
86
### -----------------------------------------------------------
86
if [ "$( whoami )" != "root" ]; then
87
if [ "$( whoami )" != "root" ]; then
87
    echo "Please run this script as root."
88
    echo "Please run this script as root."
88
    # exit 1
89
    # exit 1
89
fi
90
fi
90
 
91
 
91
 
92
 
92
### read options from command-line
93
### read options from command-line
93
### -----------------------------------------------------------
94
### -----------------------------------------------------------
94
while [ $# -gt 0 ]; do
95
while [ $# -gt 0 ]; do
95
 
96
 
96
    case "$1" in
97
    case "$1" in
97
       -h)
98
       -h)
98
            usage; exit;;
99
            usage; exit;;
99
       -swap)
100
       -swap)
100
            shift; SWAP_PART=$1; shift; continue;;
101
            shift; SWAP_PART=$1; shift; continue;;
101
       -mbr)
102
       -mbr)
102
            shift; MBR_DEV=$1; shift; continue;;
103
            shift; MBR_DEV=$1; shift; continue;;
103
       -nogrub)
104
       -nogrub)
104
            NOGRUB=$1; shift; continue;;
105
            NOGRUB=$1; shift; continue;;
-
 
106
       -floppy)
-
 
107
            FLOPPY=$1; shift; continue;;
105
       -y)
108
       -y)
106
            YES=$1; shift; continue;;
109
            YES=$1; shift; continue;;
107
 
110
 
108
       *)
111
       *)
109
            INSTALL_PART=$1; break;;
112
            INSTALL_PART=$1; break;;
110
    esac
113
    esac
111
 
114
 
112
done
115
done
113
echo
116
echo
114
 
117
 
115
 
118
 
116
### test if MBR_DEV is given
119
### test if MBR_DEV is given
117
### -----------------------------------------------------------
120
### -----------------------------------------------------------
118
if [ ! $NOGRUB ]; then
121
if [ ! $NOGRUB ]; then
119
    if [ ! $MBR_DEV ]; then
122
    if [ ! $MBR_DEV ]; then
120
	echo "No MBR device defined - where should grub be installed?"
123
	echo "No MBR device defined."
121
	echo "Please see '$SCRIPTNAME -h'."; echo
124
	echo "Please see '$SCRIPTNAME -h'."; echo
122
	exit 1
125
	exit 1
123
    fi
126
    fi
124
fi
127
fi
125
 
128
 
126
 
129
 
127
### test if $INSTALL_PART defined and exists
130
### test if $INSTALL_PART defined and exists
128
### -----------------------------------------------------------
131
### -----------------------------------------------------------
129
if [ ! $INSTALL_PART ]; then
132
if [ ! $INSTALL_PART ]; then
130
    echo "No partition defined for installation"
133
    echo "No partition defined for installation"
131
    echo "Please see '$SCRIPTNAME -h'."; echo
134
    echo "Please see '$SCRIPTNAME -h'."; echo
132
    exit 1
135
    exit 1
133
fi
136
fi
134
 
137
 
135
 
138
 
136
### test if $INSTALL_PART exists
139
### test if $INSTALL_PART exists
137
### -----------------------------------------------------------
140
### -----------------------------------------------------------
138
fdisk -l | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
141
fdisk -l | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
139
if [ "$?" != "0" ]; then
142
if [ "$?" != "0" ]; then
140
    echo "Partition $INSTALL_PART not found! (see 'disk -l')"; echo
143
    echo "Partition $INSTALL_PART not found! (see 'disk -l')"; echo
141
    exit 1
144
    exit 1
142
fi
145
fi
143
 
146
 
144
 
147
 
145
### set $INSTALL_DEV (eg. /dev/sda)
148
### set $INSTALL_DEV (eg. /dev/sda)
146
### -----------------------------------------------------------
149
### -----------------------------------------------------------
147
INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
150
INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
148
INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
151
INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
149
 
152
 
150
 
153
 
151
### test if $SWAP_PART exists
154
### test if $SWAP_PART exists
152
### -----------------------------------------------------------
155
### -----------------------------------------------------------
153
if [ $SWAP_PART ]; then
156
if [ $SWAP_PART ]; then
154
    fdisk -l | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
157
    fdisk -l | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
155
    if [ "$?" != "0" ]; then
158
    if [ "$?" != "0" ]; then
156
	echo "Swap partition $SWAP_PART not found! (see 'disk -l')"; echo
159
	echo "Swap partition $SWAP_PART not found! (see 'disk -l')"; echo
157
	exit 1
160
	exit 1
158
    fi
161
    fi
159
    fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
162
    fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
160
    if [ "$?" != "0" ]; then
163
    if [ "$?" != "0" ]; then
161
	echo "Partition $SWAP_PART is not a Linux swap partition! (see 'disk -l')"; echo
164
	echo "Partition $SWAP_PART is not a Linux swap partition! (see 'disk -l')"; echo
162
	exit 1
165
	exit 1
163
    fi
166
    fi
164
fi
167
fi
165
 
168
 
166
 
169
 
167
### print warning
170
### print warning
168
### -----------------------------------------------------------
171
### -----------------------------------------------------------
169
echo "-----------------------------------------------------------"
172
echo "-----------------------------------------------------------"
170
echo "   LiveCD will be installed on partition $INSTALL_PART."
173
echo "   LiveCD will be installed on partition $INSTALL_PART."
171
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
174
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
172
 
175
 
173
echo
176
echo
174
[ ! $NOGRUB ] && echo " !! Master Boot Record of $MBR_DEV will be overwritten !!"
177
[ ! $NOGRUB ] && echo " !! Master Boot Record of $MBR_DEV will be overwritten !!"
175
 
178
 
176
echo "     !! All data on $INSTALL_PART will be lost !!"
179
echo "     !! All data on $INSTALL_PART will be lost !!"
177
echo "-----------------------------------------------------------"
180
echo "-----------------------------------------------------------"
178
echo
181
echo
179
 
182
 
180
 
183
 
181
### continue ?
184
### continue ?
182
### -----------------------------------------------------------
185
### -----------------------------------------------------------
183
if [ ! $YES ]; then
186
if [ ! $YES ]; then
184
    echo -n "Continue (y/N)? "
187
    echo -n "Continue (y/N)? "
185
    read -n 1 key
188
    read key
186
    echo
189
    echo
187
    [ "$key" != "y" ] && exit 0
190
    [ "$key" != "y" ] && exit 0
188
fi
191
fi
189
echo
192
echo
190
 
193
 
191
 
194
 
192
### format $INSTALL_PART
195
### format $INSTALL_PART
193
### -----------------------------------------------------------
196
### -----------------------------------------------------------
194
echo -n "Format $INSTALL_PART, please wait ... " 
197
echo -n "Format $INSTALL_PART, please wait ... " 
195
mkfs.ext3 -q $INSTALL_PART || exit 1
198
mkfs.ext3 -q $INSTALL_PART || exit 1
196
echo "done."; echo
199
echo "done."; echo
197
 
200
 
198
 
201
 
199
### mount $INSTALL_PART
202
### mount $INSTALL_PART
200
### -----------------------------------------------------------
203
### -----------------------------------------------------------
201
echo -n "Try to mount $INSTALL_PART to $NEW ... "
204
echo -n "Try to mount $INSTALL_PART to $NEW ... "
202
mkdir -p $NEW
205
mkdir -p $NEW
203
mount $INSTALL_PART $NEW || exit 1
206
mount $INSTALL_PART $NEW || exit 1
204
echo "done."; echo
207
echo "done."; echo
205
 
208
 
206
 
209
 
207
### copy root dirs
210
### copy root dirs
208
### -----------------------------------------------------------
211
### -----------------------------------------------------------
209
echo "Copy Live System to $INSTALL_PART:"
212
echo "Copy Live System to $INSTALL_PART:"
210
root_dirs=$( ls / )
213
root_dirs=$( ls / )
211
for dir in $root_dirs; do
214
for dir in $root_dirs; do
212
    # check if dir is not in $DIR_NOT_COPY
215
    # check if dir is not in $DIR_NOT_COPY
213
    do_not_copy=""
216
    do_not_copy=""
214
    for not_dir in $DIR_NOT_COPY; do
217
    for not_dir in $DIR_NOT_COPY; do
215
	if [ "$not_dir" = "/$dir" ]; then 
218
	if [ "$not_dir" = "/$dir" ]; then 
216
	    do_not_copy="yes"
219
	    do_not_copy="yes"
217
	    break
220
	    break
218
	fi
221
	fi
219
    done
222
    done
220
    # do not copy links
223
    # do not copy links
221
    [ -L /$dir ] && do_not_copy="yes"
224
    [ -L /$dir ] && do_not_copy="yes"
222
 
225
 
223
    if [ ! $do_not_copy ]; then
226
    if [ ! $do_not_copy ]; then
224
	echo -n "  * Copy  /$dir ... "
227
	echo -n "  * Copy  /$dir ... "
225
	cp -a /$dir $NEW
228
	cp -a /$dir $NEW
226
	echo "done."
229
	echo "done."
227
    fi
230
    fi
228
done
231
done
229
echo
232
echo
230
 
233
 
231
 
234
 
232
### move /usr/opt back to /opt
235
### move /usr/opt back to /opt
233
### -----------------------------------------------------------
236
### -----------------------------------------------------------
234
if [ -d $NEW/usr/opt ]; then
237
if [ -d $NEW/usr/opt ]; then
235
    echo -n "Move /opt back ... "
238
    echo -n "Move /opt back ... "
236
    mv $NEW/usr/opt $NEW/
239
    mv $NEW/usr/opt $NEW/
237
    echo "done."; echo
240
    echo "done."; echo
238
fi
241
fi
239
 
242
 
240
 
243
 
241
### create dirs which were not copied
244
### create dirs which were not copied
242
### -----------------------------------------------------------
245
### -----------------------------------------------------------
243
for dir in $DIR_NOT_COPY; do
246
for dir in $DIR_NOT_COPY; do
244
    mkdir $NEW/$dir
247
    mkdir $NEW/$dir
245
done
248
done
246
rmdir $NEW/livecd $NEW/mnt
249
rmdir $NEW/livecd $NEW/mnt
247
 
250
 
248
 
251
 
249
### copy back original files
252
### copy back original files
250
### -----------------------------------------------------------
253
### -----------------------------------------------------------
251
echo -n "Restore original files ... " 
254
echo -n "Restore original files ... " 
252
for file in $FILES_RESTORE; do
255
for file in $FILES_RESTORE; do
253
    [ -r $NEW/${file}.ori ] && cp -a $NEW/${file}.ori $NEW/${file} 
256
    [ -r $NEW/${file}.ori ] && cp -a $NEW/${file}.ori $NEW/${file} 
254
done
257
done
255
echo "done."; echo
258
echo "done."; echo
256
 
259
 
257
 
260
 
258
### do some mounts for chroot $NEW
261
### do some mounts for chroot $NEW
259
### -----------------------------------------------------------
262
### -----------------------------------------------------------
260
mount --bind /dev $NEW/dev
263
mount --bind /dev $NEW/dev
261
mount --bind /sys $NEW/sys 
264
mount --bind /sys $NEW/sys 
262
mount -t proc proc $NEW/proc
265
mount -t proc proc $NEW/proc
263
 
266
 
264
 
267
 
265
### install grub
268
### install grub
266
### -----------------------------------------------------------
269
### -----------------------------------------------------------
267
echo "Run grub-install: "; echo
270
echo "Run grub-install: "; echo
268
mkdir -p $NEW/boot/grub
271
mkdir -p $NEW/boot/grub
-
 
272
if [ $FLOPPY ]; then
269
grub-install --root-directory=$NEW $MBR_DEV
273
    grub-install --root-directory=$NEW $MBR_DEV
-
 
274
else
-
 
275
    grub-install --no-floppy --root-directory=$NEW $MBR_DEV
-
 
276
fi
270
echo "done."; echo
277
echo "done."; echo
271
 
278
 
272
 
279
 
273
### define kernel version
280
### define kernel version
274
### -----------------------------------------------------------
281
### -----------------------------------------------------------
275
rpm --quiet -q kernel     && UP_installed=true
282
rpm --quiet -q kernel     && UP_installed=true
276
rpm --quiet -q kernel-smp && SMP_installed=true
283
rpm --quiet -q kernel-smp && SMP_installed=true
277
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
284
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
278
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
285
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
279
if [ ! $KERNEL_VERSION ]; then
286
if [ ! $KERNEL_VERSION ]; then
280
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
287
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
281
    exit 1
288
    exit 1
282
fi    
289
fi    
-
 
290
[ $UP_installed ]   && echo "UP kernel found."
-
 
291
[ $SMP_installed ]  && echo "SMP kernel found."
-
 
292
echo
-
 
293
 
283
 
294
 
284
### convert dev syntax to grub syntax
295
### convert dev syntax to grub syntax
285
### -----------------------------------------------------------
296
### -----------------------------------------------------------
286
device_map=$NEW/boot/grub/device.map
297
device_map=$NEW/boot/grub/device.map
287
GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $device_map | awk '{ print $1 }' )
298
GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $device_map | awk '{ print $1 }' )
288
GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
299
GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
289
 
300
 
290
 
301
 
291
### define active Windows partition -  to be fixed  !!!
302
### define active Windows partition -  to be fixed  !!!
292
### -----------------------------------------------------------
303
### -----------------------------------------------------------
293
WIN_installed=true
304
WIN_installed=true
294
GRUB_WIN_PART=(hd0,0)
305
GRUB_WIN_PART=(hd0,0)
295
 
306
 
296
 
307
 
297
### create grub.conf file
308
### create grub.conf file
298
### -----------------------------------------------------------
309
### -----------------------------------------------------------
299
echo "Create grub.conf"
310
echo "Create grub.conf"
300
 
311
 
301
cat > $NEW/boot/grub/grub.conf <<EOF
312
cat > $NEW/boot/grub/grub.conf <<EOF
302
# grub.conf generated by $SCRIPTNAME
313
# grub.conf generated by $SCRIPTNAME
303
default=0
314
default=0
304
timeout=5
315
timeout=5
305
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
316
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
306
#hiddenmenu
317
#hiddenmenu
307
EOF
318
EOF
308
 
319
 
309
if [ $UP_installed ]; then
320
if [ $UP_installed ]; then
-
 
321
    echo "Add entry for UP kernel into grub.conf"
310
    cat >> $NEW/boot/grub/grub.conf <<EOF
322
    cat >> $NEW/boot/grub/grub.conf <<EOF
311
title Scientific Linux (${KERNEL_VERSION})
323
title Scientific Linux (${KERNEL_VERSION})
312
        root $GRUB_ROOT_PART
324
        root $GRUB_ROOT_PART
313
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
325
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
314
	initrd /boot/initrd-$KERNEL_VERSION.img
326
	initrd /boot/initrd-$KERNEL_VERSION.img
315
EOF
327
EOF
316
fi
328
fi
317
 
329
 
318
if [ $SMP_installed ]; then
330
if [ $SMP_installed ]; then
-
 
331
    echo "Add entry for SMP kernel into grub.conf"
319
    cat >> $NEW/boot/grub/grub.conf <<EOF
332
    cat >> $NEW/boot/grub/grub.conf <<EOF
320
title Scientific Linux (${KERNEL_VERSION}smp)
333
title Scientific Linux (${KERNEL_VERSION}smp)
321
        root $GRUB_ROOT_PART
334
        root $GRUB_ROOT_PART
322
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
335
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
323
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
336
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
324
EOF
337
EOF
325
fi
338
fi
326
 
339
 
327
if [ $WIN_installed ]; then
340
if [ $WIN_installed ]; then
-
 
341
    echo "Add entry for Windows into grub.conf"
328
    cat >> $NEW/boot/grub/grub.conf <<EOF
342
    cat >> $NEW/boot/grub/grub.conf <<EOF
329
title Windows
343
title Windows
330
        rootnoverify $GRUB_WIN_PART
344
        rootnoverify $GRUB_WIN_PART
331
        chainloader +1
345
        chainloader +1
332
EOF
346
EOF
333
fi
347
fi
334
 
348
 
335
chmod 600 $NEW/boot/grub/grub.conf
349
chmod 600 $NEW/boot/grub/grub.conf
336
ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
350
ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
337
ln -s ./grub.conf $NEW/boot/grub/menu.lst
351
ln -s ./grub.conf $NEW/boot/grub/menu.lst
338
echo "done."; echo
352
echo "done."; echo
339
 
353
 
340
 
354
 
341
### install kernel into /boot
355
### install kernel into /boot
342
### -----------------------------------------------------------
356
### -----------------------------------------------------------
343
echo "Install kernel(s)"
357
echo "Install kernel(s)"
344
 
358
 
345
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
359
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
346
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
360
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
347
 
361
 
348
if [ ! $BOOT_DIR ]; then
362
if [ ! $BOOT_DIR ]; then
349
    echo "ERROR: No kernel found - installation failed"; echo
363
    echo "ERROR: No kernel found - installation failed"; echo
350
    exit 1
364
    exit 1
351
fi
365
fi
352
 
366
 
353
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
367
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
354
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
368
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
355
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
369
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
356
cp -a $BOOT_DIR/config-*           $NEW/boot/
370
cp -a $BOOT_DIR/config-*           $NEW/boot/
357
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
371
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
358
echo "done."; echo
372
echo "done."; echo
359
 
373
 
360
 
374
 
361
### make initrd
375
### make initrd
362
### -----------------------------------------------------------
376
### -----------------------------------------------------------
363
echo "Create initrd(s)"
377
echo "Create initrd(s)"
364
if [ $UP_installed ]; then
378
if [ $UP_installed ]; then
-
 
379
    chroot $NEW depmod -a
365
    chroot $NEW \
380
    chroot $NEW \
366
    /sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install ${KERNEL_VERSION}
381
    livecd-mkinitrd $NEW/boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
-
 
382
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
-
 
383
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
-
 
384
	exit 1
-
 
385
    fi
367
fi
386
fi
368
if [ $SMP_installed ]; then
387
if [ $SMP_installed ]; then
-
 
388
    chroot $NEW depmod -a
369
    chroot $NEW \
389
    chroot $NEW \
370
    /sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install ${KERNEL_VERSION}smp
390
    livecd-mkinitrd $NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
-
 
391
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
-
 
392
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
-
 
393
	exit 1
-
 
394
    fi
371
fi
395
fi
372
echo "done."; echo
396
echo "done."; echo
373
 
397
 
374
 
398
 
375
### create /etc/fstab
399
### create /etc/fstab
376
### -----------------------------------------------------------
400
### -----------------------------------------------------------
377
cat > $NEW/etc/fstab <<EOF
401
cat > $NEW/etc/fstab <<EOF
378
$INSTALL_PART         /                    ext3    defaults        1 1
402
$INSTALL_PART         /                    ext3    defaults        1 1
379
devpts            /dev/pts             devpts  gid=5,mode=620  0 0
403
devpts            /dev/pts             devpts  gid=5,mode=620  0 0
380
tmpfs             /dev/shm             tmpfs   defaults        0 0
404
tmpfs             /dev/shm             tmpfs   defaults        0 0
381
proc              /proc                proc    defaults        0 0
405
proc              /proc                proc    defaults        0 0
382
sysfs             /sys                 sysfs   defaults        0 0
406
sysfs             /sys                 sysfs   defaults        0 0
383
EOF
407
EOF
384
 
408
 
385
if [ $SWAP_PART ]; then
409
if [ $SWAP_PART ]; then
386
    echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
410
    echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
387
fi
411
fi
388
 
412
 
389
 
413
 
390
### remove LiveCD init.d scripts
414
### remove LiveCD init.d scripts
391
### -----------------------------------------------------------
415
### -----------------------------------------------------------
392
for file in $LIVECD_INIT_SCRIPTS; do
416
for file in $LIVECD_INIT_SCRIPTS; do
393
    rm -f $NEW/etc/init.d/$file
417
    rm -f $NEW/etc/init.d/$file
394
    for n in 0 1 2 3 4 5 6; do
418
    for n in 0 1 2 3 4 5 6; do
395
	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
419
	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
396
    done
420
    done
397
done
421
done
398
 
422
 
399
 
423
 
400
### restore cronjobs
424
### restore cronjobs
401
### -----------------------------------------------------------
425
### -----------------------------------------------------------
402
mv /etc/cron_backup/sysstat /etc/cron.d/ 2>/dev/null
426
mv /etc/cron_backup/sysstat /etc/cron.d/ 2>/dev/null
403
mv /etc/cron_backup/00-makewhatis.cron.weekly /etc/cron.weekly/00-makewhatis.cron 2>/dev/null
427
mv /etc/cron_backup/00-makewhatis.cron.weekly /etc/cron.weekly/00-makewhatis.cron 2>/dev/null
404
mv /etc/cron_backup/* /etc/cron.daily/
428
mv /etc/cron_backup/* /etc/cron.daily/
405
 
429
 
406
 
430
 
-
 
431
### turn on kudzu again
-
 
432
### -----------------------------------------------------------
-
 
433
chkconfig kudzu on
-
 
434
 
-
 
435
 
407
### umount $INSTALL_PART
436
### umount $INSTALL_PART
408
### -----------------------------------------------------------
437
### -----------------------------------------------------------
409
umount $NEW/dev
438
umount $NEW/dev
410
umount $NEW/sys 
439
umount $NEW/sys 
411
umount $NEW/proc
440
umount $NEW/proc
-
 
441
 
412
umount $INSTALL_PART
442
umount $INSTALL_PART
413
 
443