Subversion Repositories livecd

Rev

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

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