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