Subversion Repositories livecd

Rev

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

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