Subversion Repositories livecd

Rev

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

Rev 169 Rev 219
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
###############################################################
3
###############################################################
4
#
4
#
5
# Installes the LiveCD on local hard disk
5
# Installes the LiveCD on local hard disk
6
# 
6
# 
7
# Boot LiveCD and run this script as root
7
# Boot LiveCD and run this script as root
8
#
8
#
9
# Urs Beyerle
9
# Urs Beyerle
-
 
10
# Brent L. Bates
10
#
11
#
11
###############################################################
12
###############################################################
12
 
13
 
13
 
14
 
14
###############################################################
15
###############################################################
15
# Definitions
16
# Definitions
16
###############################################################
17
###############################################################
17
 
18
 
18
# set PATH
19
# set PATH
19
PATH="/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin"
20
PATH="/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin"
20
 
21
 
21
# RPMs that are no longer needed and may break future udpates
22
# RPMs that are no longer needed and may break future udpates
22
RPMS_TO_REMOVE="kernel-module-squashfs \
23
RPMS_TO_REMOVE="kernel-module-squashfs \
23
                kernel-module-unionfs \
24
                kernel-module-unionfs \
24
                kernel-module-aufs \
25
                kernel-module-aufs \
25
                unionfs-.* \
26
                unionfs-.* \
26
                aufs-.* \
27
                aufs-.* \
27
                squashfs-.*"
28
                squashfs-.*"
28
 
29
 
29
# RPMs that can break future Scientific Linux updates
30
# RPMs that can break future Scientific Linux updates
30
# because there are not part of Scientific Linux
31
# because there are not part of Scientific Linux
31
RPMS_TO_REMOVE_SL=""
32
RPMS_TO_REMOVE_SL=""
32
                   
33
                   
33
# RPMs that can break future PSI SL updates
34
# RPMs that can break future PSI SL updates
34
# because there are not part of PSI Scientific Linux
35
# because there are not part of PSI Scientific Linux
35
RPMS_TO_REMOVE_PSI=""
36
RPMS_TO_REMOVE_PSI=""
36
                   
37
                   
37
# files which should be restored from .ori files
38
# files which should be restored from .ori files
38
FILES_RESTORE="/etc/init.d/netfs \
39
FILES_RESTORE="/etc/init.d/netfs \
39
           /etc/init.d/autofs \
40
           /etc/init.d/autofs \
40
           /etc/init.d/halt \
41
           /etc/init.d/halt \
41
           /etc/init.d/network
42
           /etc/init.d/network
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 \
53
                    kudzu-auto \
54
                    kudzu-auto \
54
                    login"
55
                    login"
55
 
56
 
56
# Main directories which should be not be copied
57
# Main directories which should be not be copied
57
DIR_NOT_COPY="/proc \
58
DIR_NOT_COPY="/proc \
58
              /dev \
59
              /dev \
59
              /livecd \
60
              /livecd \
60
              /boot \
61
              /boot \
61
              /afs \
62
              /afs \
62
              /sys \
63
              /sys \
63
              /media \
64
              /media \
64
              /misc \
65
              /misc \
65
              /mnt \
66
              /mnt \
66
              /net \
67
              /net \
67
              /initrd"
68
              /initrd"
68
 
69
 
69
# Mount point of the new SL system
70
# Mount point of the new SL system
70
NEW=/mnt/harddisk
71
NEW=/mnt/harddisk
71
 
72
 
72
# Name of the script
73
# Name of the script
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
###############################################################
83
 
86
 
84
function usage() {
87
function usage() {
85
 
88
 
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
 
115
    Will install LiveCD on /dev/sda2 (= second partition on 
120
    Will install LiveCD on /dev/sda2 (= second partition on 
116
    first SATA disk). All data on /dev/sda2 will be deleted.
121
    first SATA disk). All data on /dev/sda2 will be deleted.
117
    /dev/sda3 has to be a Linux Swap partion. GRUB will be 
122
    /dev/sda3 has to be a Linux Swap partion. GRUB will be 
118
    installed in the MBR of /dev/sda (= first SATA disk).
123
    installed in the MBR of /dev/sda (= first SATA disk).
119
   
124
   
120
  Remarks:
125
  Remarks:
121
 
126
 
122
    To display your hard disk partitions, user 'fdisk -l'.
127
    To display your hard disk partitions, user 'fdisk -l'.
123
    Use fdisk, qtparted or parted to create an empty Linux
128
    Use fdisk, qtparted or parted to create an empty Linux
124
    partition.
129
    partition.
125
 
130
 
126
EOF
131
EOF
127
}
132
}
128
 
133
 
129
 
134
 
130
function exit_now() {
135
function exit_now() {
131
 
136
 
132
    local exitcode=$1
137
    local exitcode=$1
133
    umount $INSTALL_PART 2>/dev/null
138
    umount $INSTALL_PART 2>/dev/null
134
    exit $exitcode
139
    exit $exitcode
135
}
140
}
136
 
141
 
137
 
142
 
138
 
143
 
139
###############################################################
144
###############################################################
140
# Main
145
# Main
141
###############################################################
146
###############################################################
142
 
147
 
143
### are we root?
148
### are we root?
144
### -----------------------------------------------------------
149
### -----------------------------------------------------------
145
if [ "$( whoami )" != "root" ]; then
150
if [ "$( whoami )" != "root" ]; then
146
    echo; echo "Please run this script as root: 'su - -c $SCRIPTNAME'"; echo
151
    echo; echo "Please run this script as root: 'su - -c $SCRIPTNAME'"; echo
147
    exit_now 1
152
    exit_now 1
148
fi
153
fi
149
 
154
 
150
 
155
 
151
### read options from command-line
156
### read options from command-line
152
### -----------------------------------------------------------
157
### -----------------------------------------------------------
153
while [ $# -gt 0 ]; do
158
while [ $# -gt 0 ]; do
154
 
159
 
155
    case "$1" in
160
    case "$1" in
156
       -h)
161
       -h)
157
            usage; exit_now;;
162
            usage; exit_now;;
158
 
163
 
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;;
203
    esac
215
    esac
204
 
216
 
205
    shift
217
    shift
206
 
218
 
207
done
219
done
208
echo
220
echo
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
### -----------------------------------------------------------
220
if [ ! $INSTALL_PART ]; then
232
if [ ! $INSTALL_PART ]; then
221
    echo "No partition defined for installation."
233
    echo "No partition defined for installation."
222
    echo "Please see '$SCRIPTNAME -h'."; echo
234
    echo "Please see '$SCRIPTNAME -h'."; echo
223
    exit_now 1
235
    exit_now 1
224
fi
236
fi
225
 
237
 
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
 
299
 
376
 
300
### continue?
377
### continue?
301
### -----------------------------------------------------------
378
### -----------------------------------------------------------
302
if [ ! $YES ]; then
379
if [ ! $YES ]; then
303
    echo -n "Continue (y/N)? "
380
    echo -n "Continue (y/N)? "
304
    read key
381
    read key
305
    echo
382
    echo
306
    [ "$key" != "y" ] && exit_now 0
383
    [ "$key" != "y" ] && exit_now 0
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
366
fi
454
fi
367
 
455
 
368
 
456
 
369
### move /usr/opt back to /opt
457
### move /usr/opt back to /opt
370
### -----------------------------------------------------------
458
### -----------------------------------------------------------
371
if [ -d $NEW/usr/opt ]; then
459
if [ -d $NEW/usr/opt ]; then
372
    echo -n "Move /opt back ... "
460
    echo -n "Move /opt back ... "
373
    mv $NEW/usr/opt $NEW/
461
    mv $NEW/usr/opt $NEW/
374
    echo "done."; echo
462
    echo "done."; echo
375
fi
463
fi
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
400
### -----------------------------------------------------------
490
### -----------------------------------------------------------
401
rpm --quiet -q kernel     && UP_installed=true
491
rpm --quiet -q kernel     && UP_installed=true
402
rpm --quiet -q kernel-smp && SMP_installed=true
492
rpm --quiet -q kernel-smp && SMP_installed=true
403
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
493
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
404
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
494
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
405
if [ ! $KERNEL_VERSION ]; then
495
if [ ! $KERNEL_VERSION ]; then
406
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
496
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
407
    exit_now 1
497
    exit_now 1
408
fi    
498
fi    
409
 
499
 
410
 
500
 
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
    ### -----------------------------------------------------------
480
    echo "Create grub.conf ..."
568
    echo "Create grub.conf ..."
481
 
569
 
482
    TITLE="Linux"
570
    TITLE="Linux"
483
    [ -e $NEW/etc/redhat-release ] && TITLE=$( cat $NEW/etc/redhat-release )
571
    [ -e $NEW/etc/redhat-release ] && TITLE=$( cat $NEW/etc/redhat-release )
484
 
572
 
485
    DEFAULT=0
573
    DEFAULT=0
486
    # set default=1, if smp kernel is running
574
    # set default=1, if smp kernel is running
487
    uname -r | grep -q smp
575
    uname -r | grep -q smp
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
526
 
614
 
527
    chmod 600 $NEW/boot/grub/grub.conf
615
    chmod 600 $NEW/boot/grub/grub.conf
528
    ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
616
    ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
529
    ln -s ./grub.conf $NEW/boot/grub/menu.lst
617
    ln -s ./grub.conf $NEW/boot/grub/menu.lst
530
    echo "done."; echo
618
    echo "done."; echo
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
542
 
630
 
543
 
631
 
544
### install kernel and other files into /boot
632
### install kernel and other files into /boot
545
### -----------------------------------------------------------
633
### -----------------------------------------------------------
546
echo "Install kernel(s) ..."
634
echo "Install kernel(s) ..."
547
 
635
 
548
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
636
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
549
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
637
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
550
 
638
 
551
if [ ! $BOOT_DIR ]; then
639
if [ ! $BOOT_DIR ]; then
552
    echo "ERROR: No kernel found - installation failed"; echo
640
    echo "ERROR: No kernel found - installation failed"; echo
553
    exit_now 1
641
    exit_now 1
554
fi
642
fi
555
 
643
 
556
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
644
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
557
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
645
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
558
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
646
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
559
cp -a $BOOT_DIR/config-*           $NEW/boot/
647
cp -a $BOOT_DIR/config-*           $NEW/boot/
560
cp -a $BOOT_DIR/symvers-*.gz       $NEW/boot/        2>/dev/null
648
cp -a $BOOT_DIR/symvers-*.gz       $NEW/boot/        2>/dev/null
561
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/   2>/dev/null
649
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/   2>/dev/null
562
cp -a $BOOT_DIR/message.ja         $NEW/boot/        2>/dev/null
650
cp -a $BOOT_DIR/message.ja         $NEW/boot/        2>/dev/null
563
cp -a $BOOT_DIR/message            $NEW/boot/        2>/dev/null
651
cp -a $BOOT_DIR/message            $NEW/boot/        2>/dev/null
564
 
652
 
565
echo "done."; echo
653
echo "done."; echo
566
 
654
 
567
 
655
 
568
### create /etc/sysconfig/kernel file
656
### create /etc/sysconfig/kernel file
569
### -----------------------------------------------------------
657
### -----------------------------------------------------------
570
cat > $NEW/etc/sysconfig/kernel <<EOF    
658
cat > $NEW/etc/sysconfig/kernel <<EOF    
571
# UPDATEDEFAULT specifies if new-kernel-pkg should make
659
# UPDATEDEFAULT specifies if new-kernel-pkg should make
572
# new kernels the default
660
# new kernels the default
573
UPDATEDEFAULT=yes
661
UPDATEDEFAULT=yes
574
 
662
 
575
# DEFAULTKERNEL specifies the default kernel package type
663
# DEFAULTKERNEL specifies the default kernel package type
576
DEFAULTKERNEL=kernel
664
DEFAULTKERNEL=kernel
577
EOF
665
EOF
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 !!)
596
### -----------------------------------------------------------
694
### -----------------------------------------------------------
597
echo "Create initrd(s) ..."
695
echo "Create initrd(s) ..."
598
# initrd should not be build on tmpfs (we take $NEW/tmp instead of /tmp)
696
# initrd should not be build on tmpfs (we take $NEW/tmp instead of /tmp)
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
 
622
### remove LiveCD init.d scripts
720
### remove LiveCD init.d scripts
623
### -----------------------------------------------------------
721
### -----------------------------------------------------------
624
for file in $LIVECD_INIT_SCRIPTS; do
722
for file in $LIVECD_INIT_SCRIPTS; do
625
    rm -f $NEW/etc/rc.d/init.d/$file
723
    rm -f $NEW/etc/rc.d/init.d/$file
626
    for n in 0 1 2 3 4 5 6; do
724
    for n in 0 1 2 3 4 5 6; do
627
	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
725
	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
628
    done
726
    done
629
done
727
done
630
 
728
 
631
 
729
 
632
### restore cronjobs
730
### restore cronjobs
633
### -----------------------------------------------------------
731
### -----------------------------------------------------------
634
mv $NEW/etc/cron_backup/sysstat       $NEW/etc/cron.d/ 2>/dev/null
732
mv $NEW/etc/cron_backup/sysstat       $NEW/etc/cron.d/ 2>/dev/null
635
mv $NEW/etc/cron_backup/cfengine      $NEW/etc/cron.d/ 2>/dev/null
733
mv $NEW/etc/cron_backup/cfengine      $NEW/etc/cron.d/ 2>/dev/null
636
mv $NEW/etc/cron_backup/psi-cronjobs  $NEW/etc/cron.d/ 2>/dev/null
734
mv $NEW/etc/cron_backup/psi-cronjobs  $NEW/etc/cron.d/ 2>/dev/null
637
mv $NEW/etc/cron_backup/00-makewhatis.cron.weekly $NEW/etc/cron.weekly/00-makewhatis.cron 2>/dev/null
735
mv $NEW/etc/cron_backup/00-makewhatis.cron.weekly $NEW/etc/cron.weekly/00-makewhatis.cron 2>/dev/null
638
mv $NEW/etc/cron_backup/*             $NEW/etc/cron.daily/ 2>/dev/null
736
mv $NEW/etc/cron_backup/*             $NEW/etc/cron.daily/ 2>/dev/null
639
 
737
 
640
 
738
 
641
### prepare chroot to $NEW
739
### prepare chroot to $NEW
642
### -----------------------------------------------------------
740
### -----------------------------------------------------------
643
mount --bind /dev $NEW/dev
741
mount --bind /dev $NEW/dev
644
mount --bind /sys $NEW/sys
742
mount --bind /sys $NEW/sys
645
mount -t proc proc $NEW/proc
743
mount -t proc proc $NEW/proc
646
 
744
 
647
 
745
 
648
### turn on kudzu again
746
### turn on kudzu again
649
### -----------------------------------------------------------
747
### -----------------------------------------------------------
650
chroot $NEW chkconfig kudzu on
748
chroot $NEW chkconfig kudzu on
651
 
749
 
652
 
750
 
653
### turn on check_update again (only at PSI)
751
### turn on check_update again (only at PSI)
654
### -----------------------------------------------------------
752
### -----------------------------------------------------------
655
chroot $NEW chkconfig check_update on 2>/dev/null
753
chroot $NEW chkconfig check_update on 2>/dev/null
656
 
754
 
657
 
755
 
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
669
### -----------------------------------------------------------
767
### -----------------------------------------------------------
670
rm -rf $NEW/usr/share/applications/livecd-install-gui.desktop
768
rm -rf $NEW/usr/share/applications/livecd-install-gui.desktop
671
rm -rf $NEW/usr/share/applications/save-localdata.desktop
769
rm -rf $NEW/usr/share/applications/save-localdata.desktop
672
 
770
 
673
 
771
 
674
### remove RPMs that can break future updates  
772
### remove RPMs that can break future updates  
675
### -----------------------------------------------------------
773
### -----------------------------------------------------------
676
if [ ! $NORPMREMOVE ]; then
774
if [ ! $NORPMREMOVE ]; then
677
    echo "Remove RPMs that may break future updates ..."
775
    echo "Remove RPMs that may break future updates ..."
678
    chroot $NEW rpm -qa 2>/dev/null > /tmp/rpmlist
776
    chroot $NEW rpm -qa 2>/dev/null > /tmp/rpmlist
679
 
777
 
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"
741
echo 
856
echo 
742
[ $WIN_PART ]    && echo "  Entry created in grub.conf for Windows partition $WIN_PART"
857
[ $WIN_PART ]    && echo "  Entry created in grub.conf for Windows partition $WIN_PART"
743
echo                     "--------------------------------------------------------------"
858
echo                     "--------------------------------------------------------------"
744
echo                     "End of $SCRIPTNAME"
859
echo                     "End of $SCRIPTNAME"
745
echo
860
echo