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