Subversion Repositories livecd

Rev

Rev 169 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 169 Rev 219
Line 5... Line 5...
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
9
# Urs Beyerle
-
 
10
# Brent L. Bates
10
#
11
#
11
###############################################################
12
###############################################################
12
 
13
 
13
 
14
 
14
###############################################################
15
###############################################################
Line 42... Line 43...
42
           /etc/init.d/functions \
43
           /etc/init.d/functions \
43
           /etc/rc.d/rc.sysinit \
44
           /etc/rc.d/rc.sysinit \
44
           /etc/sysconfig/afs \
45
           /etc/sysconfig/afs \
45
           /etc/motd \
46
           /etc/motd \
46
           /etc/redhat-release \
47
           /etc/redhat-release \
47
	   /etc/rc.d/rc.local"
48
           /etc/rc.d/rc.local"
48
 
49
 
49
# LiveCD init scripts will be removed
50
# LiveCD init scripts will be removed
50
LIVECD_INIT_SCRIPTS="runfirst \
51
LIVECD_INIT_SCRIPTS="runfirst \
51
                    runveryfirst \
52
                    runveryfirst \
52
                    runlast \
53
                    runlast \
Line 73... Line 74...
73
SCRIPTNAME=$( basename $0 )
74
SCRIPTNAME=$( basename $0 )
74
 
75
 
75
# dir of mounted /$MOUNTDIR/live
76
# dir of mounted /$MOUNTDIR/live
76
MOUNTDIR=livecd
77
MOUNTDIR=livecd
77
 
78
 
-
 
79
# Default File System Type
-
 
80
FS_TYPE=ext3
78
 
81
 
79
 
82
 
80
###############################################################
83
###############################################################
81
# Functions
84
# Functions
82
###############################################################
85
###############################################################
Line 86... Line 89...
86
   ## Usage
89
   ## Usage
87
   # ----------------------------------------------------------
90
   # ----------------------------------------------------------
88
 
91
 
89
   cat <<EOF
92
   cat <<EOF
90
   
93
   
91
  $SCRIPTNAME [OPTIONS] -mbr=[DEVICE] [PARTITION]
94
  $SCRIPTNAME [OPTIONS] -mbr=[DEVICE] [PARTITION | MOUNTED FILE SYSTEM]
92
 
95
 
93
    Installes LiveCD on PARTITION and the bootloader grub into 
96
    Installes LiveCD on PARTITION and the bootloader grub into 
94
    the Master Boot Record (MBR) of DEVICE. The MBR will be 
97
    the Master Boot Record (MBR) of DEVICE. The MBR will be 
95
    backed up to PARTITION.
98
    backed up to PARTITION.
96
 
99
 
97
  OPTIONS:
100
  OPTIONS:
98
 
101
 
99
    -h   --help       : Print this screen
102
    -h   --help          : Print this screen
100
    -swap=[partition] : Use [partition] as swap
103
    -swap=[partition(s)] : Use [partition(s)] as swap ("," or "|" separated)
101
    -win=[partition]  : Your active Windows partition. If not given, 
104
    -win=[partition]     : Your active Windows partition. If not given, 
102
                        $SCRIPTNAME tries to find it
105
                           $SCRIPTNAME tries to find it
103
    -nogrub           : Do not install grub. You have to install 
106
    -nogrub              : Do not install grub. You have to install 
104
                        manually a bootloader (not recommended)
107
                           manually a bootloader (not recommended)
105
    -floppy           : Needed, if grub should be installed on floppy
108
    -floppy              : Needed, if grub should be installed on floppy
106
                        In this case use -mbr=/dev/fd0 -floppy
109
                           In this case use -mbr=/dev/fd0 -floppy
107
    -norpmremove      : Do not remove RPMs that can break future 
110
    -norpmremove         : Do not remove RPMs that can break future 
108
                        updates (not recommended)
111
                           updates (not recommended)
-
 
112
    -fstype              : File system type (ext3,xfs,etc.), default is $FS_TYPE
109
    -y                : Answer all questions with yes
113
    -y                   : Answer all questions with yes
-
 
114
    -f                   : force formating 
110
 
115
 
111
  Example:
116
  Example:
112
 
117
 
113
  $SCRIPTNAME -swap=/dev/sda3 -mbr=/dev/sda /dev/sda2
118
  $SCRIPTNAME -swap=/dev/sda3 -mbr=/dev/sda /dev/sda2
114
 
119
 
Line 159... Line 164...
159
       --help)
164
       --help)
160
            usage; exit_now;;
165
            usage; exit_now;;
161
 
166
 
162
       -swap*)
167
       -swap*)
163
           if echo $1 | grep -q '=' ; then
168
           if echo $1 | grep -q '=' ; then
164
	       SWAP_PART=$( echo $1 | sed 's/^-swap=//' )
169
               SWAP_PART=$( echo $1 | sed 's/^-swap=//' )
165
	   else
170
           else
166
	       shift
171
               shift
167
               SWAP_PART=$1
172
               SWAP_PART=$1
168
	   fi
173
           fi
169
	   ;;
174
           ;;
170
 
175
 
171
       -mbr*)
176
       -mbr*)
172
           if echo $1 | grep -q '=' ; then
177
           if echo $1 | grep -q '=' ; then
173
	       MBR_DEV=$( echo $1 | sed 's/^-mbr=//' )
178
               MBR_DEV=$( echo $1 | sed 's/^-mbr=//' )
174
	   else
179
           else
175
	       shift
180
               shift
176
               MBR_DEV=$1
181
               MBR_DEV=$1
177
	   fi
182
           fi
-
 
183
           MBR_DEV=$( echo "$MBR_DEV" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
178
	   ;;
184
           ;;
179
 
185
 
180
       -win*)
186
       -win*)
181
           if echo $1 | grep -q '=' ; then
187
           if echo $1 | grep -q '=' ; then
182
	       WIN_PART=$( echo $1 | sed 's/^-win=//' )
188
               WIN_PART=$( echo $1 | sed 's/^-win=//' )
183
	   else
189
           else
184
	       shift
190
               shift
185
               WIN_PART=$1
191
               WIN_PART=$1
186
	   fi
192
           fi
187
	   ;;
193
           ;;
188
 
194
 
189
       -nogrub)
195
       -nogrub)
190
            NOGRUB=$1;;
196
            NOGRUB=$1;;
191
 
197
 
192
       -norpmremove)
198
       -norpmremove)
193
            NORPMREMOVE=$1;;
199
            NORPMREMOVE=$1;;
194
 
200
 
195
       -floppy)
201
       -floppy)
196
            FLOPPY=$1;;
202
            FLOPPY=$1;;
197
 
203
 
-
 
204
       -fstype)
-
 
205
            $FS_TYPE=$1;;
-
 
206
 
-
 
207
       -f)
-
 
208
            $FORCE=$1;;
-
 
209
 
198
       -y)
210
       -y)
199
            YES=$1;;
211
            YES=$1;;
200
 
212
 
201
       *)
213
       *)
202
            INSTALL_PART=$1;;
214
            INSTALL_PART=$1;;
Line 209... Line 221...
209
 
221
 
210
 
222
 
211
### display fdisk -l
223
### display fdisk -l
212
### -----------------------------------------------------------
224
### -----------------------------------------------------------
213
echo "Output of 'fdisk -l' ..."
225
echo "Output of 'fdisk -l' ..."
214
fdisk -l
226
fdisk -l 2>/dev/null
215
echo
227
echo
216
 
228
 
217
 
229
 
218
### test if $INSTALL_PART is defined
230
### test if $INSTALL_PART is defined
219
### -----------------------------------------------------------
231
### -----------------------------------------------------------
Line 226... Line 238...
226
 
238
 
227
### test if MBR_DEV is given
239
### test if MBR_DEV is given
228
### -----------------------------------------------------------
240
### -----------------------------------------------------------
229
if [ ! $NOGRUB ]; then
241
if [ ! $NOGRUB ]; then
230
    if [ ! $MBR_DEV ]; then
242
    if [ ! $MBR_DEV ]; then
231
	echo "No MBR device defined."
243
        echo "No MBR device defined."
232
	echo "Please see '$SCRIPTNAME -h'."
244
        echo "Please see '$SCRIPTNAME -h'."
233
	echo
245
        echo
234
	exit_now 1
246
        exit_now 1
235
    fi
247
    fi
236
fi
248
fi
-
 
249
 
-
 
250
 
-
 
251
### test if $INSTALL_PART is mounted
-
 
252
### -----------------------------------------------------------
-
 
253
df -T -l | sed -e 's/  */ /g' | grep -q "${INSTALL_PART}"
-
 
254
 
-
 
255
if [ "$?" = "0" ]; then
-
 
256
   ### This is a mounted partition
-
 
257
   ### -----------------------------------------------------------
-
 
258
   MOUNTED=1
-
 
259
 
-
 
260
   df -T -l | sed -e 's/  */ /g' | cut -d" " -f7 | grep -q "^${INSTALL_PART}$"
-
 
261
   if [ "$?" = "0" ]; then
-
 
262
 
-
 
263
      ### Was given the mount point
-
 
264
      ### -----------------------------------------------------------
-
 
265
      NEW=${INSTALL_PART}
-
 
266
      INSTALL_PART=`df -T -l | grep "${INSTALL_PART}$" | cut -d" " -f1`
-
 
267
   else
-
 
268
 
-
 
269
      ### Was given the mount partition
-
 
270
      ### -----------------------------------------------------------
-
 
271
      NEW=`df -T -l | grep "^${INSTALL_PART}" | sed -e 's/  */ /g' | cut -d" " -f7`
-
 
272
   fi
-
 
273
   FS_TYPE=`df -T -l | sed -e 's/  */ /g' | grep "^${INSTALL_PART}" | cut -d" " -f2`
-
 
274
 
-
 
275
   ### Get boot defice information
-
 
276
   ###    Check for separate mounted boot partition
-
 
277
   ### -----------------------------------------------------------
-
 
278
   INSTALL_DEV=`df -T -l | sed -e 's/  */ /g' | grep "boot$" | cut -d" " -f1`
-
 
279
   if [ "$?" = "0" ]; then
-
 
280
      ###    Separate boot partition
-
 
281
      ### -----------------------------------------------------------
-
 
282
      INSTALL_BOOT_DIR=""
-
 
283
   else
-
 
284
      ###    Install and boot all one partition
-
 
285
      ### -----------------------------------------------------------
-
 
286
      INSTALL_DEV=${INSTALL_PART}
-
 
287
      INSTALL_BOOT_DIR="/boot"
-
 
288
   fi
237
 
289
 
-
 
290
   ### Is the boot device a RAID device
-
 
291
   ### -----------------------------------------------------------
-
 
292
   mdadm -D $INSTALL_DEV 2>/dev/null | grep -q -i Version
-
 
293
   if [ "$?" = "0" ]; then
-
 
294
      ### Boot device is RAID
-
 
295
      ### -----------------------------------------------------------
-
 
296
      BOOT_DRIVE=`mdadm -D $INSTALL_DEV | grep -v ':$' | grep "/dev/" | sed -e 's/  */ /g' | cut -d" " -f8 |head -1`
-
 
297
      INSTALL_PART_NR=$( echo "$BOOT_DRIVE" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
-
 
298
      BOOT_DRIVE=$( echo "$BOOT_DRIVE" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
-
 
299
   else
-
 
300
      ### Boot device not RAID
-
 
301
      ### -----------------------------------------------------------
-
 
302
      INSTALL_PART_NR=$( echo "$INSTALL_DEV" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
-
 
303
      INSTALL_DEV=$( echo "$INSTALL_DEV" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
-
 
304
      BOOT_DRIVE=$INSTALL_DEV
-
 
305
   fi
-
 
306
else
-
 
307
   ### Partition is NOT mounted
-
 
308
   ### -----------------------------------------------------------
-
 
309
   MOUNTED=0
238
 
310
 
239
### test if $INSTALL_PART exists
311
   ### test if $INSTALL_PART exists
240
### -----------------------------------------------------------
312
   ### -----------------------------------------------------------
241
fdisk -l | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
313
   fdisk -l 2>/dev/null | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
242
if [ "$?" != "0" ]; then
314
   if [ "$?" != "0" ]; then
243
    echo "Partition $INSTALL_PART not found! See 'fdisk -l'."
315
       echo "Partition $INSTALL_PART not found! See 'fdisk -l'."
244
    echo "Or you have to reboot first to make the partition table active." 
316
       echo "Or you have to reboot first to make the partition table active." 
245
    echo
317
       echo
246
    exit_now 1
318
       exit_now 1
247
fi
319
   fi
248
 
320
 
249
 
321
 
250
### test if $INSTALL_PART is a Linux partition
322
   ### test if $INSTALL_PART is a Linux partition
251
### -----------------------------------------------------------
323
   ### -----------------------------------------------------------
252
fdisk -l | grep "Linux$" | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
324
   fdisk -l 2>/dev/null | grep "Linux$" | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
253
if [ "$?" != "0" ]; then
325
   if [ "$?" != "0" ]; then
254
    echo "Partition $INSTALL_PART is not a Linux partition! (see 'fdisk -l')."
326
       echo "Partition $INSTALL_PART is not a Linux partition! (see 'fdisk -l')."
255
    echo "Use fdisk and/or qtparted to create a Linux partition!"
327
       echo "Use fdisk and/or qtparted to create a Linux partition!"
256
    echo "You have to reboot first to make the partition table active."
328
       echo "You have to reboot first to make the partition table active."
257
    echo
329
       echo
258
    exit_now 1
330
       exit_now 1
-
 
331
   fi
-
 
332
 
-
 
333
   ### set $INSTALL_DEV (eg. /dev/sda)
-
 
334
   ### -----------------------------------------------------------
-
 
335
   INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
-
 
336
   BOOT_DRIVE=$INSTALL_DEV
-
 
337
   INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
-
 
338
   INSTALL_BOOT_DIR="/boot"
259
fi
339
fi
260
 
340
 
261
 
341
 
262
### test if $SWAP_PART exists and is a Linux Swap partition
342
### test if $SWAP_PART exists and is a Linux Swap partition
263
### -----------------------------------------------------------
343
### -----------------------------------------------------------
264
if [ $SWAP_PART ]; then
344
if [ "$SWAP_PART" ]; then
-
 
345
    SWAP_PART=`echo ${SWAP_PART} |tr '[,|]' ' '`
-
 
346
    for SWAP_PARTITION in $SWAP_PART ; do
265
    fdisk -l | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
347
       fdisk -l 2>/dev/null | cut -d" " -f1 | grep -q "^${SWAP_PARTITION}$"
266
    if [ "$?" != "0" ]; then
348
       if [ "$?" != "0" ]; then
267
	echo "Swap partition $SWAP_PART not found! (see 'fdisk -l')."
349
           echo "Swap partition $SWAP_PARTITION not found! (see 'fdisk -l')."
268
	echo "Or you have to reboot first to make the partition table active."
350
           echo "Or you have to reboot first to make the partition table active."
269
	echo
351
           echo
270
	exit_now 1
352
           exit_now 1
271
    fi
353
       fi
272
    fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
354
       fdisk -l 2>/dev/null | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PARTITION}$"
273
    if [ "$?" != "0" ]; then
355
       if [ "$?" != "0" ]; then
274
	echo "Partition $SWAP_PART is not a Linux swap partition! (see 'fdisk -l')."
356
           echo "Partition(s) $SWAP_PARTITION is/are not a Linux swap partition! (see 'fdisk -l')."
275
	echo "Use fdisk and/or qtparted to create a Linux Swap partition !"
357
           echo "Use fdisk and/or qtparted to create a Linux Swap partition !"
276
	echo "You have to reboot first to make the partition table active."
358
           echo "You have to reboot first to make the partition table active."
277
	echo
359
           echo
278
	exit_now 1
360
           exit_now 1
279
    fi
361
       fi
-
 
362
    done
280
fi
363
fi
281
 
364
 
282
 
365
 
283
### set $INSTALL_DEV (eg. /dev/sda)
-
 
284
### -----------------------------------------------------------
-
 
285
INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
-
 
286
INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
-
 
287
 
-
 
288
 
-
 
289
### print warning
366
### print warning
290
### -----------------------------------------------------------
367
### -----------------------------------------------------------
291
echo                     "------------------------------------------------------------"
368
echo                     "------------------------------------------------------------"
292
echo                     "   LiveCD will be installed on partition $INSTALL_PART"
369
echo                     "   LiveCD will be installed on partition $INSTALL_PART"
293
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
370
[ "$SWAP_PART" ] && echo " Partition(s) $SWAP_PART will be used as swap partition(s)."
294
[ ! $NOGRUB ]    && echo " GRUB will be installed in Master Boot Record of $MBR_DEV"
371
[ ! $NOGRUB ]    && echo " GRUB will be installed in Master Boot Record of $MBR_DEV"
295
echo                     "       !! All data on $INSTALL_PART will be lost !!"
372
echo                     "       !! All data on $INSTALL_PART will be lost !!"
296
echo                     "------------------------------------------------------------"
373
echo                     "------------------------------------------------------------"
297
echo
374
echo
298
 
375
 
Line 307... Line 384...
307
fi
384
fi
308
 
385
 
309
 
386
 
310
### format $SWAP_PART (don't format swap, if already formated)
387
### format $SWAP_PART (don't format swap, if already formated)
311
### -----------------------------------------------------------
388
### -----------------------------------------------------------
312
if [ $SWAP_PART ]; then
389
if [ "$SWAP_PART" ]; then
313
    echo "Make swap on $SWAP_PART ..."
390
    echo "Make swap on $SWAP_PART ..."
314
    swapoff -a >/dev/null 2>&1
391
    swapoff -a >/dev/null 2>&1
315
    swapon $SWAP_PART 2>/dev/null
392
    swapon -p 1 $SWAP_PART 2>/dev/null
316
    if [ "$?" != "0" ]; then
393
    if [ "$?" != "0" ]; then
-
 
394
        for SWAP_PARTITION in $SWAP_PART; do
317
	echo "Format $SWAP_PART as swap." 
395
           echo "Format $SWAP_PARTITION as swap." 
318
	mkswap $SWAP_PART
396
           mkswap $SWAP_PARTITION
-
 
397
        done
319
    fi
398
    fi
320
    echo
399
    echo
321
fi
400
fi
322
 
401
 
323
 
402
 
-
 
403
if [ $MOUNTED = "0" ]; then
324
### format $INSTALL_PART
404
    ### format $INSTALL_PART
325
### -----------------------------------------------------------
405
    ### -----------------------------------------------------------
326
echo -n "Format $INSTALL_PART, please wait ... " 
-
 
327
mkfs.ext3 -q $INSTALL_PART || exit_now 1
-
 
328
echo "done."; echo
-
 
329
 
406
 
-
 
407
    # define force option for mkfs command
-
 
408
    if [ "$FORCE" ] && [ "$FS_TYPE" = "ext3" ];     then  FORCE="-F"; fi
-
 
409
    if [ "$FORCE" ] && [ "$FS_TYPE" = "ext2" ];     then  FORCE="-F"; fi
-
 
410
    if [ "$FORCE" ] && [ "$FS_TYPE" = "xfs" ];      then  FORCE="-f"; fi
-
 
411
    if [ "$FORCE" ] && [ "$FS_TYPE" = "reiserfs" ]; then  FORCE=""; fi
-
 
412
    
-
 
413
    echo -n "Format $INSTALL_PART, please wait ... " 
-
 
414
    mkfs.$FS_TYPE $FORCE -q $INSTALL_PART || exit_now 1
-
 
415
    echo "done."; echo
330
 
416
 
331
### mount $INSTALL_PART
417
    ### mount $INSTALL_PART
332
### -----------------------------------------------------------
418
    ### -----------------------------------------------------------
333
echo -n "Try to mount $INSTALL_PART to $NEW ... "
419
    echo -n "Try to mount $INSTALL_PART to $NEW ... "
334
mkdir -p $NEW
420
    mkdir -p $NEW
335
mount $INSTALL_PART $NEW || exit_now 1
421
    mount $INSTALL_PART $NEW || exit_now 1
336
echo "done."; echo
422
    echo "done."; echo
-
 
423
fi
337
 
424
 
338
 
425
 
339
### copy root dirs
426
### copy root dirs
340
### -----------------------------------------------------------
427
### -----------------------------------------------------------
341
echo "Copy Live System to $INSTALL_PART ..."
428
echo "Copy Live System to $INSTALL_PART ..."
342
root_dirs=$( ls / )
429
root_dirs=$( ls / )
343
for dir in $root_dirs; do
430
for dir in $root_dirs; do
344
    # check if dir is not in $DIR_NOT_COPY
431
    # check if dir is not in $DIR_NOT_COPY
345
    do_not_copy=""
432
    do_not_copy=""
346
    for not_dir in $DIR_NOT_COPY; do
433
    for not_dir in $DIR_NOT_COPY; do
347
	if [ "$not_dir" = "/$dir" ]; then 
434
        if [ "$not_dir" = "/$dir" ]; then 
348
	    do_not_copy="yes"
435
            do_not_copy="yes"
349
	    break
436
            break
350
	fi
437
        fi
351
    done
438
    done
352
    # do not copy links
439
    # do not copy links
353
    [ -L /$dir ] && do_not_copy="yes"
440
    [ -L /$dir ] && do_not_copy="yes"
354
 
441
 
355
    fail=""
442
    fail=""
356
    if [ ! $do_not_copy ]; then
443
    if [ ! $do_not_copy ]; then
357
	echo -n "  * Copy  /$dir ... "
444
        echo -n "  * Copy  /$dir ... "
358
	cp -a /$dir $NEW || fail=true
445
        cp -a -f /$dir $NEW || fail=true
359
	echo "done."
446
        echo "done."
360
    fi
447
    fi
-
 
448
    fail=""
361
done
449
done
362
echo
450
echo
363
if [ $fail ]; then
451
if [ $fail ]; then
364
    echo "ERROR: Not everything was copied to $INSTALL_PART"
452
    echo "ERROR: Not everything was copied to $INSTALL_PART"
365
    exit_now 1
453
    exit_now 1
Line 376... Line 464...
376
 
464
 
377
 
465
 
378
### create dirs which were not copied
466
### create dirs which were not copied
379
### -----------------------------------------------------------
467
### -----------------------------------------------------------
380
for dir in $DIR_NOT_COPY; do
468
for dir in $DIR_NOT_COPY; do
-
 
469
   if [ ! -d $NEW$dir ]; then
381
    mkdir $NEW/$dir
470
       mkdir $NEW$dir
-
 
471
   fi
382
done
472
done
383
# we do not need this directories
473
# we do not need this directory
384
rmdir $NEW/livecd
474
rmdir $NEW/livecd
385
# if not yet existing, create
475
# if not yet existing, create
386
mkdir -p $NEW/srv
476
mkdir -p $NEW/srv
387
mkdir -p $NEW/selinux
477
mkdir -p $NEW/selinux
388
 
478
 
389
 
479
 
390
### copy back original files
480
### copy back original files
391
### -----------------------------------------------------------
481
### -----------------------------------------------------------
392
echo -n "Restore original files ... " 
482
echo -n "Restore original files ... " 
393
for file in $FILES_RESTORE; do
483
for file in $FILES_RESTORE; do
394
    [ -r $NEW/${file}.ori ] && mv -f $NEW/${file}.ori $NEW/${file} 
484
    [ -r $NEW${file}.ori ] && mv -f $NEW${file}.ori $NEW${file} 
395
done
485
done
396
echo "done."; echo
486
echo "done."; echo
397
 
487
 
398
 
488
 
399
### define kernel version
489
### define kernel version
Line 411... Line 501...
411
 
501
 
412
if [ ! $NOGRUB ]; then
502
if [ ! $NOGRUB ]; then
413
 
503
 
414
    ### Backup Master Boot Record MBR
504
    ### Backup Master Boot Record MBR
415
    ### -----------------------------------------------------------
505
    ### -----------------------------------------------------------
416
    if [ ! $NOGRUB ]; then
-
 
417
	# do we have already a backup?
506
    # do we have already a backup?
418
	MBR_FILENAME="MBR$( echo $MBR_DEV | tr / _ ).bak"
507
    MBR_FILENAME="MBR$( echo $MBR_DEV | tr / _ ).bak"
419
	if [ ! -e /tmp/$MBR_FILENAME ]; then
508
    if [ ! -e /tmp/$MBR_FILENAME ]; then
420
	    echo "Backup Master Boot Record (MBR) of $MBR_DEV ..."
509
        echo "Backup Master Boot Record (MBR) of $MBR_DEV ..."
421
	    dd if=$MBR_DEV of=/tmp/$MBR_FILENAME bs=512 count=1
510
        dd if=$MBR_DEV of=/tmp/$MBR_FILENAME bs=512 count=1
422
	fi
-
 
423
	cp -a /tmp/$MBR_FILENAME $NEW/$MBR_FILENAME
-
 
424
	echo "MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
-
 
425
	echo
-
 
426
    fi
511
    fi
-
 
512
    cp -a /tmp/$MBR_FILENAME $NEW/$MBR_FILENAME
-
 
513
    echo "MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
-
 
514
    echo
427
 
515
 
428
 
516
 
429
    ### install grub
517
    ### install grub
430
    ### -----------------------------------------------------------
518
    ### -----------------------------------------------------------
431
    echo "Run grub-install ... "
519
    echo "Run grub-install ... "
432
    mkdir -p $NEW/boot/grub
520
    mkdir -p $NEW/boot/grub
433
    if [ $FLOPPY ]; then
521
    if [ $FLOPPY ]; then
434
	grub-install --root-directory=$NEW $MBR_DEV
522
        grub-install --root-directory=$NEW $MBR_DEV 2>/dev/null || GRUB_FAILED="yes"
435
    else
523
    else
436
	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
524
        grub-install --no-floppy --root-directory=$NEW $MBR_DEV 2>/dev/null || GRUB_FAILED="yes"
437
    fi
525
    fi
438
    echo "done."; echo
526
    echo "done."; echo
439
 
527
 
440
 
528
 
441
    ### check for device.map file 
529
    ### check for device.map file 
442
    ### -----------------------------------------------------------
530
    ### -----------------------------------------------------------
443
    DEVICE_MAP=$NEW/boot/grub/device.map
531
    DEVICE_MAP=$NEW/boot/grub/device.map
444
    if [ ! -e $NEW/boot/grub/device.map ]; then
532
    if [ ! -e $NEW/boot/grub/device.map ]; then
445
	echo "ERROR: $NEW/boot/grub/device.map not found"
533
        echo "ERROR: $NEW/boot/grub/device.map not found"
446
	exit_now 1
534
        exit_now 1
447
    fi
535
    fi
448
 
536
 
449
 
537
 
450
    ### convert dev syntax to grub syntax
538
    ### convert dev syntax to grub syntax
451
    ### -----------------------------------------------------------
539
    ### -----------------------------------------------------------
452
    GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
540
    GRUB_INSTALL_DEV=$( grep $BOOT_DRIVE $DEVICE_MAP | awk '{ print $1 }' )
453
    GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
541
    GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
454
 
542
 
455
 
543
 
456
    ### find active Windows partition
544
    ### find active Windows partition
457
    ### -----------------------------------------------------------
545
    ### -----------------------------------------------------------
458
    if [ ! $WIN_PART ]; then
546
    if [ ! $WIN_PART ]; then
459
        # try to find active Windows partition
547
        # try to find active Windows partition
460
	WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
548
        WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
461
    fi
549
    fi
462
 
550
 
463
    if [ $WIN_PART ]; then
551
    if [ $WIN_PART ]; then
464
	WIN_installed=true
552
        WIN_installed=true
465
	WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
553
        WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
466
	WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
554
        WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
467
        # convert dev syntax to grub syntax
555
        # convert dev syntax to grub syntax
468
	GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
556
        GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
469
	GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
557
        GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
470
 
558
 
471
        # $GRUB_WIN_PART should be something like (hd0,0)
559
        # $GRUB_WIN_PART should be something like (hd0,0)
472
	echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
560
        echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
473
	echo "Will add entry for Windows in GRUB."
561
        echo "Will add entry for Windows in GRUB."
474
	echo
562
        echo
475
    fi
563
    fi
476
 
564
 
477
 
565
 
478
    ### create grub.conf file
566
    ### create grub.conf file
479
    ### -----------------------------------------------------------
567
    ### -----------------------------------------------------------
Line 488... Line 576...
488
    [ "$?" = "0" ] && DEFAULT=1
576
    [ "$?" = "0" ] && DEFAULT=1
489
 
577
 
490
    cat > $NEW/boot/grub/grub.conf <<EOF
578
    cat > $NEW/boot/grub/grub.conf <<EOF
491
# grub.conf generated by $SCRIPTNAME
579
# grub.conf generated by $SCRIPTNAME
492
default=$DEFAULT
580
default=$DEFAULT
493
timeout=5
581
timeout=10
494
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
582
splashimage=${GRUB_ROOT_PART}${INSTALL_BOOT_DIR}/grub/splash.xpm.gz
495
#hiddenmenu
583
#hiddenmenu
496
EOF
584
EOF
497
 
585
 
498
    if [ $UP_installed ]; then
586
    if [ $UP_installed ]; then
499
	echo "Add entry for UP kernel into grub.conf"
587
        echo "Add entry for UP kernel into grub.conf"
500
	cat >> $NEW/boot/grub/grub.conf <<EOF
588
        cat >> $NEW/boot/grub/grub.conf <<EOF
501
title $TITLE (${KERNEL_VERSION})
589
title $TITLE (${KERNEL_VERSION})
502
        root $GRUB_ROOT_PART
590
        root $GRUB_ROOT_PART
503
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
591
        kernel ${INSTALL_BOOT_DIR}/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
504
	initrd /boot/initrd-$KERNEL_VERSION.img
592
        initrd ${INSTALL_BOOT_DIR}/initrd-$KERNEL_VERSION.img
505
EOF
593
EOF
506
    fi
594
    fi
507
 
595
 
508
    if [ $SMP_installed ]; then
596
    if [ $SMP_installed ]; then
509
	echo "Add entry for SMP kernel into grub.conf"
597
        echo "Add entry for SMP kernel into grub.conf"
510
	cat >> $NEW/boot/grub/grub.conf <<EOF
598
        cat >> $NEW/boot/grub/grub.conf <<EOF
511
title $TITLE (${KERNEL_VERSION}smp)
599
title $TITLE (${KERNEL_VERSION}smp)
512
        root $GRUB_ROOT_PART
600
        root $GRUB_ROOT_PART
513
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
601
        kernel ${INSTALL_BOOT_DIR}/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
514
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
602
        initrd ${INSTALL_BOOT_DIR}/initrd-${KERNEL_VERSION}smp.img
515
EOF
603
EOF
516
    fi
604
    fi
517
 
605
 
518
    if [ $WIN_installed ]; then
606
    if [ $WIN_installed ]; then
519
	echo "Add entry for Windows into grub.conf"
607
        echo "Add entry for Windows into grub.conf"
520
	cat >> $NEW/boot/grub/grub.conf <<EOF
608
        cat >> $NEW/boot/grub/grub.conf <<EOF
521
title Windows
609
title Windows
522
        rootnoverify $GRUB_WIN_PART
610
        rootnoverify $GRUB_WIN_PART
523
        chainloader +1
611
        chainloader +1
524
EOF
612
EOF
525
    fi
613
    fi
Line 531... Line 619...
531
 
619
 
532
 
620
 
533
    ### create /etc/sysconfig/grub file
621
    ### create /etc/sysconfig/grub file
534
    ### -----------------------------------------------------------
622
    ### -----------------------------------------------------------
535
    cat > $NEW/etc/sysconfig/grub <<EOF    
623
    cat > $NEW/etc/sysconfig/grub <<EOF    
536
boot=$MBR_DEV
624
boot=$INSTALL_DEV
537
forcelba=0
625
forcelba=0
538
EOF
626
EOF
539
 
627
 
540
 
628
 
541
fi
629
fi
Line 578... Line 666...
578
 
666
 
579
 
667
 
580
### create /etc/fstab
668
### create /etc/fstab
581
### -----------------------------------------------------------
669
### -----------------------------------------------------------
582
cat > $NEW/etc/fstab <<EOF
670
cat > $NEW/etc/fstab <<EOF
583
$INSTALL_PART         /                    ext3    defaults        1 1
671
$INSTALL_PART	/		$FS_TYPE		defaults	1 1
584
devpts            /dev/pts             devpts  gid=5,mode=620  0 0
-
 
585
tmpfs             /dev/shm             tmpfs   defaults        0 0
-
 
586
proc              /proc                proc    defaults        0 0
-
 
587
sysfs             /sys                 sysfs   defaults        0 0
-
 
588
EOF
672
EOF
-
 
673
 
-
 
674
if [ -z "$INSTALL_BOOT_DIR" ]; then
-
 
675
   echo "$INSTALL_DEV	/boot		$FS_TYPE		defaults	1 2" >> $NEW/etc/fstab
-
 
676
fi
-
 
677
 
-
 
678
cat >> $NEW/etc/fstab <<EOF
-
 
679
devpts          /dev/pts        devpts          gid=5,mode=620  0 0
-
 
680
tmpfs	        /dev/shm        tmpfs           defaults        0 0
-
 
681
proc	        /proc           proc            defaults        0 0
-
 
682
sysfs		/sys            sysfs           defaults        0 0
-
 
683
EOF
-
 
684
 
589
if [ $SWAP_PART ]; then
685
if [ "$SWAP_PART" ]; then
-
 
686
    for SWAP_PARTITION in $SWAP_PART ; do
590
    echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
687
        echo "$SWAP_PARTITION	swap		swap		defaults,pri=1	0 0" >> $NEW/etc/fstab
-
 
688
    done
591
fi
689
fi
592
 
690
 
593
 
691
 
594
### make initrd 
692
### make initrd 
595
### (needs $NEW/etc/fstab to find correct modules for root filesystem !!)
693
### (needs $NEW/etc/fstab to find correct modules for root filesystem !!)
Line 599... Line 697...
599
sed -i "s|^TMPDIR=.*|TMPDIR=\"$NEW/tmp\"|" /usr/sbin/livecd-mkinitrd
697
sed -i "s|^TMPDIR=.*|TMPDIR=\"$NEW/tmp\"|" /usr/sbin/livecd-mkinitrd
600
 
698
 
601
if [ $UP_installed ]; then
699
if [ $UP_installed ]; then
602
    depmod -a ${KERNEL_VERSION}
700
    depmod -a ${KERNEL_VERSION}
603
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
701
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
604
                    $NEW//boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
702
                    $NEW/boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
605
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
703
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
606
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
704
        echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
607
	exit_now 1
705
        exit_now 1
608
    fi
706
    fi
609
fi
707
fi
610
if [ $SMP_installed ]; then
708
if [ $SMP_installed ]; then
611
    depmod -a ${KERNEL_VERSION}smp
709
    depmod -a ${KERNEL_VERSION}smp
612
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
710
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
613
                    $NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
711
                    $NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
614
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
712
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
615
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
713
        echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
616
	exit_now 1
714
        exit_now 1
617
    fi
715
    fi
618
fi
716
fi
619
echo "done."; echo
717
echo "done."; echo
620
 
718
 
621
 
719
 
Line 658... Line 756...
658
### fix some services which were disabled 
756
### fix some services which were disabled 
659
### because of diskless NFS client
757
### because of diskless NFS client
660
### -----------------------------------------------------------
758
### -----------------------------------------------------------
661
if [ -e /$MOUNTDIR/service.on ]; then
759
if [ -e /$MOUNTDIR/service.on ]; then
662
    cat /$MOUNTDIR/service.on | while read $serv; do
760
    cat /$MOUNTDIR/service.on | while read $serv; do
663
	chroot $NEW chkconfig $serv on
761
        chroot $NEW chkconfig $serv on
664
    done
762
    done
665
fi
763
fi
666
 
764
 
667
 
765
 
668
### remove some files
766
### remove some files
Line 680... Line 778...
680
    # Scientific Linux RPMs
778
    # Scientific Linux RPMs
681
    RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_SL"
779
    RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_SL"
682
 
780
 
683
    # PSI Scientific Linux RPMs
781
    # PSI Scientific Linux RPMs
684
    if [ -e /etc/sysconfig/psi ]; then
782
    if [ -e /etc/sysconfig/psi ]; then
685
	RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_PSI"
783
        RPMSTOREMOVE="$RPMS_TO_REMOVE $RPMS_TO_REMOVE_PSI"
686
    fi
784
    fi
687
 
785
 
688
    for rpm in $RPMSTOREMOVE; do
786
    for rpm in $RPMSTOREMOVE; do
689
	rpms_remove=$( cat /tmp/rpmlist | grep "^$rpm" )
787
        rpms_remove=$( cat /tmp/rpmlist | grep "^$rpm" )
690
	for rpm_remove in $rpms_remove; do	
788
        for rpm_remove in $rpms_remove; do        
691
	    chroot $NEW rpm -e --nodeps $rpm_remove >/dev/null 2>&1
789
            chroot $NEW rpm -e --nodeps $rpm_remove >/dev/null 2>&1
692
	    [ "$?" = "0" ] && echo " removing $rpm_remove"
790
            [ "$?" = "0" ] && echo " removing $rpm_remove"
693
	done
791
        done
694
    done
792
    done
695
    echo "done."; echo
793
    echo "done."; echo
696
fi
794
fi
697
 
795
 
698
 
796
 
699
### disable nvidia driver 
797
### disable nvidia driver 
700
### -----------------------------------------------------------
798
### -----------------------------------------------------------
701
# not in case of a PSI installation
799
# not in case of a PSI installation
702
if [ ! -e /etc/sysconfig/psi ]; then
800
if [ ! -e /etc/sysconfig/psi ]; then
703
    if [ -e $NEW/etc/X11/xorg.conf.nv_SAVED ]; then
801
    if [ -e $NEW/etc/X11/xorg.conf.nv_SAVED ]; then
704
	echo "Remove nvidia driver and correct xorg.conf ..."
802
        echo "Remove nvidia driver and correct xorg.conf ..."
705
        # correct xorg.conf
803
        # correct xorg.conf
706
	sed -i "s/#nv_SAVED //" $NEW/etc/X11/xorg.conf
804
        sed -i "s/#nv_SAVED //" $NEW/etc/X11/xorg.conf
707
	sed -i "/.*Driver.*nvidia.*/d" $NEW/etc/X11/xorg.conf
805
        sed -i "/.*Driver.*nvidia.*/d" $NEW/etc/X11/xorg.conf
708
        # disable nvidia libs (if not yet done by rpm -e)
806
        # disable nvidia libs (if not yet done by rpm -e)
709
	LIB=lib
807
        LIB=lib
710
	[ $( arch ) = "x86_64" ] && LIB=lib64
808
        [ $( arch ) = "x86_64" ] && LIB=lib64
711
	mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libGLcore.a.saved_by_nvidia \
809
        mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libGLcore.a.saved_by_nvidia \
712
              $NEW/usr/X11R6/$LIB/modules/extensions/libGLcore.a 2>/dev/null
810
              $NEW/usr/X11R6/$LIB/modules/extensions/libGLcore.a 2>/dev/null
713
	mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libglx.a.saved_by_nvidia \
811
        mv -f $NEW/usr/X11R6/$LIB/modules/extensions/xxx.libglx.a.saved_by_nvidia \
714
              $NEW/usr/X11R6/$LIB/modules/extensions/libglx.a 2>/dev/null
812
              $NEW/usr/X11R6/$LIB/modules/extensions/libglx.a 2>/dev/null
715
	rm -f $NEW/usr/X11R6/$LIB/modules/extensions/libglx.so
813
        rm -f $NEW/usr/X11R6/$LIB/modules/extensions/libglx.so
716
	rm -f $NEW/usr/X11R6/$LIB/libGL.so*
814
        rm -f $NEW/usr/X11R6/$LIB/libGL.so*
717
	rm -f $NEW/usr/$LIB/libGLcore.so
815
        rm -f $NEW/usr/$LIB/libGLcore.so
718
	echo "done."; echo
816
        echo "done."; echo
719
    fi
817
    fi
720
fi
818
fi
721
 
819
 
722
 
820
 
-
 
821
### install grub for the 2. time, if it failed before 
-
 
822
### (happens on xfs filesystem)
-
 
823
### -----------------------------------------------------------
-
 
824
if [ ! $NOGRUB ] && [ $GRUB_FAILED ]; then
-
 
825
 
-
 
826
    echo "Run grub-install for the 2. time ... "
-
 
827
    mkdir -p $NEW/boot/grub
-
 
828
    if [ $FLOPPY ]; then
-
 
829
        grub-install --root-directory=$NEW $MBR_DEV
-
 
830
    else
-
 
831
        grub-install --no-floppy --root-directory=$NEW $MBR_DEV
-
 
832
    fi
-
 
833
    echo "done."; echo
-
 
834
 
-
 
835
fi
-
 
836
 
723
### umount $INSTALL_PART
837
### umount $INSTALL_PART
724
### -----------------------------------------------------------
838
### -----------------------------------------------------------
725
umount $NEW/dev
839
umount $NEW/dev
726
umount $NEW/sys
840
umount $NEW/sys
727
umount $NEW/proc
841
umount $NEW/proc
-
 
842
UMOUNT_LIST=`df -l | grep "$NEW" | sed -e 's/  */ /g' | cut -d" " -f6 | sort -r`
728
umount $INSTALL_PART
843
umount $UMOUNT_LIST
729
 
844
 
730
 
845
 
731
### print summary
846
### print summary
732
### -----------------------------------------------------------
847
### -----------------------------------------------------------
733
echo                     "--------------------------------------------------------------"
848
echo                     "--------------------------------------------------------------"
734
echo                     "  LiveCD installed on partition $INSTALL_PART"
849
echo                     "  LiveCD installed on partition $INSTALL_PART"
735
[ "$SWAP_PART" ] && echo "  Partition $SWAP_PART will be used as swap partition"
850
[ "$SWAP_PART" ] && echo "  Partition(s) $SWAP_PART will be used as swap partition(s)"
736
echo
851
echo
737
[ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record (MBR) of $MBR_DEV"
852
[ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record (MBR) of $MBR_DEV"
738
[ ! $NOGRUB ]    && echo "  MBR saved as $MBR_FILENAME on $INSTALL_PART and in /tmp"
853
[ ! $NOGRUB ]    && echo "  MBR saved as $MBR_FILENAME on $INSTALL_PART and in /tmp"
739
[ ! $NOGRUB ]    && echo "  If you have to restore MBR, execute under Linux:"
854
[ ! $NOGRUB ]    && echo "  If you have to restore MBR, execute under Linux:"
740
[ ! $NOGRUB ]    && echo "  # dd if=$MBR_FILENAME of=$MBR_DEV bs=512 count=1"
855
[ ! $NOGRUB ]    && echo "  # dd if=$MBR_FILENAME of=$MBR_DEV bs=512 count=1"