| 15 |
beyerle@PS |
1 |
#!/bin/bash
|
|
|
2 |
#
|
|
|
3 |
###############################################################
|
|
|
4 |
#
|
|
|
5 |
# Installes the LiveCD on local harddisk
|
|
|
6 |
#
|
|
|
7 |
# Boot LiveCD and run this script as root
|
|
|
8 |
#
|
|
|
9 |
# Urs Beyerle, PSI
|
|
|
10 |
#
|
|
|
11 |
###############################################################
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
###############################################################
|
|
|
15 |
# Definitions
|
|
|
16 |
###############################################################
|
|
|
17 |
|
|
|
18 |
# files which should be restored from .ori files
|
|
|
19 |
FILES_RESTORE="/etc/init.d/netfs \
|
|
|
20 |
/etc/init.d/autofs \
|
|
|
21 |
/etc/init.d/halt \
|
|
|
22 |
/etc/init.d/network
|
|
|
23 |
/etc/init.d/functions \
|
|
|
24 |
/etc/rc.d/rc.sysinit \
|
|
|
25 |
/etc/sysconfig/afs \
|
|
|
26 |
/etc/motd \
|
|
|
27 |
/etc/redhat-release \
|
| 16 |
beyerle@PS |
28 |
/etc/rc.d/rc.local \
|
| 15 |
beyerle@PS |
29 |
/etc/rc.d/rc.sysinit"
|
|
|
30 |
|
| 16 |
beyerle@PS |
31 |
LIVECD_INIT_SCRIPTS="runfirst \
|
|
|
32 |
runveryfirst \
|
|
|
33 |
runlast \
|
|
|
34 |
kudzu-auto"
|
| 15 |
beyerle@PS |
35 |
|
|
|
36 |
# Main directories which should be not be copied
|
| 16 |
beyerle@PS |
37 |
DIR_NOT_COPY="/proc \
|
|
|
38 |
/dev \
|
|
|
39 |
/livecd \
|
|
|
40 |
/boot \
|
|
|
41 |
/afs \
|
|
|
42 |
/sys \
|
|
|
43 |
/mnt \
|
|
|
44 |
/media"
|
| 15 |
beyerle@PS |
45 |
|
|
|
46 |
# Mount point of the new SL system
|
|
|
47 |
NEW=/mnt/harddisk
|
|
|
48 |
|
| 21 |
beyerle@PS |
49 |
# Name of the script
|
| 15 |
beyerle@PS |
50 |
SCRIPTNAME=$( basename $0 )
|
|
|
51 |
|
| 16 |
beyerle@PS |
52 |
|
|
|
53 |
|
| 21 |
beyerle@PS |
54 |
|
| 15 |
beyerle@PS |
55 |
###############################################################
|
|
|
56 |
# Functions
|
|
|
57 |
###############################################################
|
|
|
58 |
|
|
|
59 |
function usage() {
|
|
|
60 |
|
|
|
61 |
## Usage
|
|
|
62 |
# ----------------------------------------------------------
|
|
|
63 |
|
|
|
64 |
cat <<EOF
|
| 21 |
beyerle@PS |
65 |
|
| 22 |
beyerle@PS |
66 |
$SCRIPTNAME [OPTIONS] -mbr=[DEVICE] [PARTITION]
|
| 15 |
beyerle@PS |
67 |
|
| 21 |
beyerle@PS |
68 |
Installes LiveCD on PARTITION and the boot loader grub
|
|
|
69 |
into the Master Boot Record (MBR) of DEVICE.
|
| 15 |
beyerle@PS |
70 |
|
| 21 |
beyerle@PS |
71 |
OPTIONS:
|
| 15 |
beyerle@PS |
72 |
|
| 21 |
beyerle@PS |
73 |
-h --help print this screen
|
| 22 |
beyerle@PS |
74 |
-swap=[partition] use [partition] as swap
|
|
|
75 |
-win=[partition] your active Windows partition. If not given,
|
|
|
76 |
$SCRIPTNAME tries to find it
|
| 18 |
beyerle@PS |
77 |
-nogrub do not install grub (leave MBR untouched)
|
| 21 |
beyerle@PS |
78 |
-floppy needed, if grub should be installed on floppy
|
| 15 |
beyerle@PS |
79 |
-y answer all questions with yes
|
|
|
80 |
|
| 21 |
beyerle@PS |
81 |
|
|
|
82 |
Example:
|
|
|
83 |
|
| 22 |
beyerle@PS |
84 |
$SCRIPTNAME -swap=/dev/sda3 -mbr=/dev/sda /dev/sda2
|
| 21 |
beyerle@PS |
85 |
|
|
|
86 |
Will install LiveCD on /dev/sda2 (= second partition on
|
|
|
87 |
first SATA disk). All data on /dev/sda2 will be deleted.
|
|
|
88 |
/dev/sda3 has to be a Linux Swap partion. GRUB will be
|
|
|
89 |
installed in the MBR of /dev/sda (= first SATA disk).
|
|
|
90 |
|
| 15 |
beyerle@PS |
91 |
EOF
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
|
| 21 |
beyerle@PS |
95 |
function exit_now() {
|
|
|
96 |
|
|
|
97 |
local exitcode=$1
|
|
|
98 |
umount $INSTALL_PART 2>/dev/null
|
|
|
99 |
exit $exitcode
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
| 15 |
beyerle@PS |
104 |
###############################################################
|
|
|
105 |
# Main
|
|
|
106 |
###############################################################
|
|
|
107 |
|
| 16 |
beyerle@PS |
108 |
### are we root?
|
|
|
109 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
110 |
if [ "$( whoami )" != "root" ]; then
|
| 22 |
beyerle@PS |
111 |
echo "Please run this script as roo/home/l_beyerle/svn-livecd/livecd/trunkt."
|
| 21 |
beyerle@PS |
112 |
exit_now 1
|
| 15 |
beyerle@PS |
113 |
fi
|
|
|
114 |
|
| 16 |
beyerle@PS |
115 |
|
| 15 |
beyerle@PS |
116 |
### read options from command-line
|
| 16 |
beyerle@PS |
117 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
118 |
while [ $# -gt 0 ]; do
|
|
|
119 |
|
|
|
120 |
case "$1" in
|
|
|
121 |
-h)
|
| 21 |
beyerle@PS |
122 |
usage; exit_now;;
|
| 22 |
beyerle@PS |
123 |
|
| 21 |
beyerle@PS |
124 |
--help)
|
|
|
125 |
usage; exit_now;;
|
| 22 |
beyerle@PS |
126 |
|
| 15 |
beyerle@PS |
127 |
-swap)
|
| 22 |
beyerle@PS |
128 |
if echo $1 | grep -q '=' ; then
|
|
|
129 |
SWAP_PART=$( echo $1 | sed 's/^-swap=//' )
|
|
|
130 |
else
|
|
|
131 |
shift
|
|
|
132 |
SWAP_PART=$2
|
|
|
133 |
fi
|
|
|
134 |
shift; continue;;
|
|
|
135 |
|
| 15 |
beyerle@PS |
136 |
-mbr)
|
| 22 |
beyerle@PS |
137 |
if echo $1 | grep -q '=' ; then
|
|
|
138 |
MBR_DEV=$( echo $1 | sed 's/^-mbr=//' )
|
|
|
139 |
else
|
|
|
140 |
shift
|
|
|
141 |
MBR_DEV=$2
|
|
|
142 |
fi
|
|
|
143 |
shift; continue;;
|
|
|
144 |
|
|
|
145 |
-win)
|
|
|
146 |
if echo $1 | grep -q '=' ; then
|
|
|
147 |
WIN_PART=$( echo $1 | sed 's/^-win=//' )
|
|
|
148 |
else
|
|
|
149 |
shift
|
|
|
150 |
WIN_PART=$2
|
|
|
151 |
fi
|
|
|
152 |
shift; continue;;
|
|
|
153 |
|
| 16 |
beyerle@PS |
154 |
-nogrub)
|
|
|
155 |
NOGRUB=$1; shift; continue;;
|
| 22 |
beyerle@PS |
156 |
|
| 18 |
beyerle@PS |
157 |
-floppy)
|
|
|
158 |
FLOPPY=$1; shift; continue;;
|
| 22 |
beyerle@PS |
159 |
|
| 15 |
beyerle@PS |
160 |
-y)
|
|
|
161 |
YES=$1; shift; continue;;
|
|
|
162 |
|
|
|
163 |
*)
|
|
|
164 |
INSTALL_PART=$1; break;;
|
|
|
165 |
esac
|
|
|
166 |
|
|
|
167 |
done
|
|
|
168 |
echo
|
|
|
169 |
|
| 16 |
beyerle@PS |
170 |
|
| 22 |
beyerle@PS |
171 |
### test if $INSTALL_PART is defined and exists
|
|
|
172 |
### -----------------------------------------------------------
|
|
|
173 |
if [ ! $INSTALL_PART ]; then
|
|
|
174 |
echo "No partition defined for installation"
|
|
|
175 |
echo "Please see '$SCRIPTNAME -h'."; echo
|
|
|
176 |
exit_now 1
|
|
|
177 |
fi
|
|
|
178 |
|
|
|
179 |
|
| 15 |
beyerle@PS |
180 |
### test if MBR_DEV is given
|
| 16 |
beyerle@PS |
181 |
### -----------------------------------------------------------
|
|
|
182 |
if [ ! $NOGRUB ]; then
|
|
|
183 |
if [ ! $MBR_DEV ]; then
|
| 18 |
beyerle@PS |
184 |
echo "No MBR device defined."
|
| 16 |
beyerle@PS |
185 |
echo "Please see '$SCRIPTNAME -h'."; echo
|
| 21 |
beyerle@PS |
186 |
exit_now 1
|
| 16 |
beyerle@PS |
187 |
fi
|
| 15 |
beyerle@PS |
188 |
fi
|
|
|
189 |
|
| 16 |
beyerle@PS |
190 |
|
| 15 |
beyerle@PS |
191 |
### test if $INSTALL_PART exists
|
| 16 |
beyerle@PS |
192 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
193 |
fdisk -l | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
|
|
|
194 |
if [ "$?" != "0" ]; then
|
|
|
195 |
echo "Partition $INSTALL_PART not found! (see 'disk -l')"; echo
|
| 21 |
beyerle@PS |
196 |
exit_now 1
|
| 15 |
beyerle@PS |
197 |
fi
|
|
|
198 |
|
| 16 |
beyerle@PS |
199 |
|
| 15 |
beyerle@PS |
200 |
### set $INSTALL_DEV (eg. /dev/sda)
|
| 16 |
beyerle@PS |
201 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
202 |
INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
|
|
|
203 |
INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
### test if $SWAP_PART exists
|
| 16 |
beyerle@PS |
207 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
208 |
if [ $SWAP_PART ]; then
|
|
|
209 |
fdisk -l | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
|
|
|
210 |
if [ "$?" != "0" ]; then
|
|
|
211 |
echo "Swap partition $SWAP_PART not found! (see 'disk -l')"; echo
|
| 21 |
beyerle@PS |
212 |
exit_now 1
|
| 15 |
beyerle@PS |
213 |
fi
|
|
|
214 |
fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
|
|
|
215 |
if [ "$?" != "0" ]; then
|
|
|
216 |
echo "Partition $SWAP_PART is not a Linux swap partition! (see 'disk -l')"; echo
|
| 21 |
beyerle@PS |
217 |
exit_now 1
|
| 15 |
beyerle@PS |
218 |
fi
|
|
|
219 |
fi
|
|
|
220 |
|
|
|
221 |
|
|
|
222 |
### print warning
|
| 16 |
beyerle@PS |
223 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
224 |
echo "-----------------------------------------------------------"
|
|
|
225 |
echo " LiveCD will be installed on partition $INSTALL_PART."
|
|
|
226 |
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
|
| 16 |
beyerle@PS |
227 |
|
| 15 |
beyerle@PS |
228 |
echo
|
| 16 |
beyerle@PS |
229 |
[ ! $NOGRUB ] && echo " !! Master Boot Record of $MBR_DEV will be overwritten !!"
|
|
|
230 |
|
| 15 |
beyerle@PS |
231 |
echo " !! All data on $INSTALL_PART will be lost !!"
|
|
|
232 |
echo "-----------------------------------------------------------"
|
|
|
233 |
echo
|
|
|
234 |
|
|
|
235 |
|
|
|
236 |
### continue ?
|
| 16 |
beyerle@PS |
237 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
238 |
if [ ! $YES ]; then
|
|
|
239 |
echo -n "Continue (y/N)? "
|
| 18 |
beyerle@PS |
240 |
read key
|
| 15 |
beyerle@PS |
241 |
echo
|
| 21 |
beyerle@PS |
242 |
[ "$key" != "y" ] && exit_now 0
|
| 15 |
beyerle@PS |
243 |
fi
|
|
|
244 |
echo
|
|
|
245 |
|
|
|
246 |
|
| 21 |
beyerle@PS |
247 |
### Backup MBR
|
|
|
248 |
### -----------------------------------------------------------
|
|
|
249 |
### to do !!!!!!!!!!
|
|
|
250 |
###
|
|
|
251 |
|
|
|
252 |
|
| 15 |
beyerle@PS |
253 |
### format $INSTALL_PART
|
| 16 |
beyerle@PS |
254 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
255 |
echo -n "Format $INSTALL_PART, please wait ... "
|
| 21 |
beyerle@PS |
256 |
mkfs.ext3 -q $INSTALL_PART || exit_now 1
|
| 15 |
beyerle@PS |
257 |
echo "done."; echo
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
### mount $INSTALL_PART
|
| 16 |
beyerle@PS |
261 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
262 |
echo -n "Try to mount $INSTALL_PART to $NEW ... "
|
|
|
263 |
mkdir -p $NEW
|
| 21 |
beyerle@PS |
264 |
mount $INSTALL_PART $NEW || exit_now 1
|
| 15 |
beyerle@PS |
265 |
echo "done."; echo
|
|
|
266 |
|
|
|
267 |
|
|
|
268 |
### copy root dirs
|
| 16 |
beyerle@PS |
269 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
270 |
echo "Copy Live System to $INSTALL_PART:"
|
|
|
271 |
root_dirs=$( ls / )
|
|
|
272 |
for dir in $root_dirs; do
|
|
|
273 |
# check if dir is not in $DIR_NOT_COPY
|
|
|
274 |
do_not_copy=""
|
|
|
275 |
for not_dir in $DIR_NOT_COPY; do
|
|
|
276 |
if [ "$not_dir" = "/$dir" ]; then
|
|
|
277 |
do_not_copy="yes"
|
|
|
278 |
break
|
|
|
279 |
fi
|
|
|
280 |
done
|
|
|
281 |
# do not copy links
|
|
|
282 |
[ -L /$dir ] && do_not_copy="yes"
|
|
|
283 |
|
| 21 |
beyerle@PS |
284 |
fail=""
|
| 15 |
beyerle@PS |
285 |
if [ ! $do_not_copy ]; then
|
|
|
286 |
echo -n " * Copy /$dir ... "
|
| 21 |
beyerle@PS |
287 |
cp -a /$dir $NEW || fail=true
|
| 15 |
beyerle@PS |
288 |
echo "done."
|
|
|
289 |
fi
|
|
|
290 |
done
|
|
|
291 |
echo
|
| 21 |
beyerle@PS |
292 |
if [ $fail ]; then
|
|
|
293 |
echo "ERROR: Not everything was copied to $INSTALL_PART"
|
|
|
294 |
exit_now 1
|
|
|
295 |
fi
|
| 15 |
beyerle@PS |
296 |
|
|
|
297 |
|
| 16 |
beyerle@PS |
298 |
### move /usr/opt back to /opt
|
|
|
299 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
300 |
if [ -d $NEW/usr/opt ]; then
|
|
|
301 |
echo -n "Move /opt back ... "
|
|
|
302 |
mv $NEW/usr/opt $NEW/
|
|
|
303 |
echo "done."; echo
|
|
|
304 |
fi
|
|
|
305 |
|
|
|
306 |
|
|
|
307 |
### create dirs which were not copied
|
| 16 |
beyerle@PS |
308 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
309 |
for dir in $DIR_NOT_COPY; do
|
|
|
310 |
mkdir $NEW/$dir
|
|
|
311 |
done
|
|
|
312 |
rmdir $NEW/livecd $NEW/mnt
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
### copy back original files
|
| 16 |
beyerle@PS |
316 |
### -----------------------------------------------------------
|
| 15 |
beyerle@PS |
317 |
echo -n "Restore original files ... "
|
|
|
318 |
for file in $FILES_RESTORE; do
|
|
|
319 |
[ -r $NEW/${file}.ori ] && cp -a $NEW/${file}.ori $NEW/${file}
|
|
|
320 |
done
|
|
|
321 |
echo "done."; echo
|
|
|
322 |
|
|
|
323 |
|
| 21 |
beyerle@PS |
324 |
### do some mounts for chroot $NEW (no more needed)
|
| 16 |
beyerle@PS |
325 |
### -----------------------------------------------------------
|
| 21 |
beyerle@PS |
326 |
# mount --bind /dev $NEW/dev
|
|
|
327 |
# mount --bind /sys $NEW/sys
|
|
|
328 |
# mount -t proc proc $NEW/proc
|
| 15 |
beyerle@PS |
329 |
|
|
|
330 |
|
| 16 |
beyerle@PS |
331 |
### install grub
|
|
|
332 |
### -----------------------------------------------------------
|
|
|
333 |
echo "Run grub-install: "; echo
|
|
|
334 |
mkdir -p $NEW/boot/grub
|
| 18 |
beyerle@PS |
335 |
if [ $FLOPPY ]; then
|
|
|
336 |
grub-install --root-directory=$NEW $MBR_DEV
|
|
|
337 |
else
|
|
|
338 |
grub-install --no-floppy --root-directory=$NEW $MBR_DEV
|
|
|
339 |
fi
|
| 15 |
beyerle@PS |
340 |
echo "done."; echo
|
|
|
341 |
|
|
|
342 |
|
| 16 |
beyerle@PS |
343 |
### define kernel version
|
|
|
344 |
### -----------------------------------------------------------
|
|
|
345 |
rpm --quiet -q kernel && UP_installed=true
|
|
|
346 |
rpm --quiet -q kernel-smp && SMP_installed=true
|
|
|
347 |
[ $UP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
|
|
|
348 |
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp 2>/dev/null )
|
|
|
349 |
if [ ! $KERNEL_VERSION ]; then
|
|
|
350 |
echo "ERROR: Kernel version could not be determined - installation failed"; echo
|
| 21 |
beyerle@PS |
351 |
exit_now 1
|
| 16 |
beyerle@PS |
352 |
fi
|
| 15 |
beyerle@PS |
353 |
|
| 18 |
beyerle@PS |
354 |
|
| 22 |
beyerle@PS |
355 |
### check for device.map file
|
|
|
356 |
### -----------------------------------------------------------
|
|
|
357 |
DEVICE_MAP=$NEW/boot/grub/device.map
|
|
|
358 |
if [ ! -e $NEW/boot/grub/device.map ]; then
|
|
|
359 |
echo "ERROR: $NEW/boot/grub/device.map not found"
|
|
|
360 |
exit_now 1
|
|
|
361 |
fi
|
|
|
362 |
|
|
|
363 |
|
| 16 |
beyerle@PS |
364 |
### convert dev syntax to grub syntax
|
|
|
365 |
### -----------------------------------------------------------
|
| 22 |
beyerle@PS |
366 |
GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
|
| 16 |
beyerle@PS |
367 |
GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
|
| 15 |
beyerle@PS |
368 |
|
|
|
369 |
|
| 22 |
beyerle@PS |
370 |
### find active Windows partition
|
| 16 |
beyerle@PS |
371 |
### -----------------------------------------------------------
|
| 22 |
beyerle@PS |
372 |
if [ ! $WIN_PART ]; then
|
|
|
373 |
# try to find active Windows partition
|
|
|
374 |
WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
|
|
|
375 |
fi
|
| 15 |
beyerle@PS |
376 |
|
| 22 |
beyerle@PS |
377 |
if [ $WIN_PART ]; then
|
|
|
378 |
WIN_installed=true
|
|
|
379 |
WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
|
|
|
380 |
WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
|
|
|
381 |
# convert dev syntax to grub syntax
|
|
|
382 |
GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
|
|
|
383 |
GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
|
| 15 |
beyerle@PS |
384 |
|
| 22 |
beyerle@PS |
385 |
# $GRUB_WIN_PART should be something like (hd0,0)
|
|
|
386 |
echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )"
|
|
|
387 |
echo "Will add entry for Windows in GRUB."
|
|
|
388 |
echo
|
|
|
389 |
fi
|
|
|
390 |
|
|
|
391 |
|
| 15 |
beyerle@PS |
392 |
### create grub.conf file
|
| 16 |
beyerle@PS |
393 |
### -----------------------------------------------------------
|
| 21 |
beyerle@PS |
394 |
echo "Create grub.conf:"
|
| 15 |
beyerle@PS |
395 |
|
|
|
396 |
cat > $NEW/boot/grub/grub.conf <<EOF
|
|
|
397 |
# grub.conf generated by $SCRIPTNAME
|
|
|
398 |
default=0
|
|
|
399 |
timeout=5
|
|
|
400 |
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
|
|
|
401 |
#hiddenmenu
|
| 16 |
beyerle@PS |
402 |
EOF
|
|
|
403 |
|
|
|
404 |
if [ $UP_installed ]; then
|
| 21 |
beyerle@PS |
405 |
echo " Add entry for UP kernel into grub.conf"
|
| 16 |
beyerle@PS |
406 |
cat >> $NEW/boot/grub/grub.conf <<EOF
|
|
|
407 |
title Scientific Linux (${KERNEL_VERSION})
|
| 15 |
beyerle@PS |
408 |
root $GRUB_ROOT_PART
|
|
|
409 |
kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
|
|
|
410 |
initrd /boot/initrd-$KERNEL_VERSION.img
|
| 16 |
beyerle@PS |
411 |
EOF
|
|
|
412 |
fi
|
|
|
413 |
|
|
|
414 |
if [ $SMP_installed ]; then
|
| 21 |
beyerle@PS |
415 |
echo " Add entry for SMP kernel into grub.conf"
|
| 16 |
beyerle@PS |
416 |
cat >> $NEW/boot/grub/grub.conf <<EOF
|
|
|
417 |
title Scientific Linux (${KERNEL_VERSION}smp)
|
|
|
418 |
root $GRUB_ROOT_PART
|
|
|
419 |
kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
|
|
|
420 |
initrd /boot/initrd-${KERNEL_VERSION}smp.img
|
|
|
421 |
EOF
|
|
|
422 |
fi
|
|
|
423 |
|
|
|
424 |
if [ $WIN_installed ]; then
|
| 21 |
beyerle@PS |
425 |
echo " Add entry for Windows into grub.conf"
|
| 16 |
beyerle@PS |
426 |
cat >> $NEW/boot/grub/grub.conf <<EOF
|
| 15 |
beyerle@PS |
427 |
title Windows
|
|
|
428 |
rootnoverify $GRUB_WIN_PART
|
|
|
429 |
chainloader +1
|
|
|
430 |
EOF
|
| 16 |
beyerle@PS |
431 |
fi
|
| 15 |
beyerle@PS |
432 |
|
|
|
433 |
chmod 600 $NEW/boot/grub/grub.conf
|
|
|
434 |
ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
|
|
|
435 |
ln -s ./grub.conf $NEW/boot/grub/menu.lst
|
|
|
436 |
echo "done."; echo
|
|
|
437 |
|
|
|
438 |
|
| 16 |
beyerle@PS |
439 |
### install kernel into /boot
|
|
|
440 |
### -----------------------------------------------------------
|
| 21 |
beyerle@PS |
441 |
echo "Install kernel(s) ..."
|
| 15 |
beyerle@PS |
442 |
|
| 16 |
beyerle@PS |
443 |
[ -e /boot/vmlinuz ] && BOOT_DIR=/boot
|
|
|
444 |
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
|
| 15 |
beyerle@PS |
445 |
|
| 16 |
beyerle@PS |
446 |
if [ ! $BOOT_DIR ]; then
|
|
|
447 |
echo "ERROR: No kernel found - installation failed"; echo
|
| 21 |
beyerle@PS |
448 |
exit_now 1
|
| 16 |
beyerle@PS |
449 |
fi
|
|
|
450 |
|
|
|
451 |
cp -a $BOOT_DIR/vmlinuz $NEW/boot/vmlinuz-${KERNEL_VERSION}
|
|
|
452 |
cp -a $BOOT_DIR/vmlinuzs $NEW/boot/vmlinuz-${KERNEL_VERSION}smp 2>/dev/null
|
|
|
453 |
cp -a $BOOT_DIR/System.map-* $NEW/boot/
|
|
|
454 |
cp -a $BOOT_DIR/config-* $NEW/boot/
|
|
|
455 |
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
|
|
|
456 |
echo "done."; echo
|
|
|
457 |
|
|
|
458 |
|
| 21 |
beyerle@PS |
459 |
### create /etc/fstab
|
| 16 |
beyerle@PS |
460 |
### -----------------------------------------------------------
|
| 21 |
beyerle@PS |
461 |
cat > $NEW/etc/fstab <<EOF
|
|
|
462 |
$INSTALL_PART / ext3 defaults 1 1
|
|
|
463 |
devpts /dev/pts devpts gid=5,mode=620 0 0
|
|
|
464 |
tmpfs /dev/shm tmpfs defaults 0 0
|
|
|
465 |
proc /proc proc defaults 0 0
|
|
|
466 |
sysfs /sys sysfs defaults 0 0
|
|
|
467 |
EOF
|
|
|
468 |
if [ $SWAP_PART ]; then
|
|
|
469 |
echo "$SWAP_PART swap swap defaults 0 0" >> $NEW/etc/fstab
|
|
|
470 |
fi
|
|
|
471 |
|
|
|
472 |
|
|
|
473 |
### make initrd
|
|
|
474 |
### (needs $NEW/etc/fstab to find correct modules for root filesystem !!)
|
|
|
475 |
### -----------------------------------------------------------
|
|
|
476 |
echo "Create initrd(s) ..."
|
| 22 |
beyerle@PS |
477 |
# initrd should not be build on tmpfs (we take $NEW/tmp instead of /tmp)
|
|
|
478 |
sed -i "s|^TMPDIR=.*|TMPDIR=\"$NEW/tmp\"|" /usr/sbin/livecd-mkinitrd
|
|
|
479 |
|
| 16 |
beyerle@PS |
480 |
if [ $UP_installed ]; then
|
| 21 |
beyerle@PS |
481 |
depmod -a ${KERNEL_VERSION}
|
| 22 |
beyerle@PS |
482 |
/usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
|
| 21 |
beyerle@PS |
483 |
$NEW//boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
|
| 18 |
beyerle@PS |
484 |
if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
|
|
|
485 |
echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
|
| 21 |
beyerle@PS |
486 |
exit_now 1
|
| 18 |
beyerle@PS |
487 |
fi
|
| 16 |
beyerle@PS |
488 |
fi
|
|
|
489 |
if [ $SMP_installed ]; then
|
| 21 |
beyerle@PS |
490 |
depmod -a ${KERNEL_VERSION}smp
|
| 22 |
beyerle@PS |
491 |
/usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
|
| 21 |
beyerle@PS |
492 |
$NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
|
| 18 |
beyerle@PS |
493 |
if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
|
|
|
494 |
echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
|
| 21 |
beyerle@PS |
495 |
exit_now 1
|
| 18 |
beyerle@PS |
496 |
fi
|
| 16 |
beyerle@PS |
497 |
fi
|
|
|
498 |
echo "done."; echo
|
|
|
499 |
|
|
|
500 |
|
| 15 |
beyerle@PS |
501 |
### remove LiveCD init.d scripts
|
| 16 |
beyerle@PS |
502 |
### -----------------------------------------------------------
|
|
|
503 |
for file in $LIVECD_INIT_SCRIPTS; do
|
|
|
504 |
rm -f $NEW/etc/init.d/$file
|
|
|
505 |
for n in 0 1 2 3 4 5 6; do
|
|
|
506 |
rm -f $NEW/etc/rc.d/rc${n}.d/*$file
|
|
|
507 |
done
|
| 15 |
beyerle@PS |
508 |
done
|
|
|
509 |
|
| 16 |
beyerle@PS |
510 |
|
|
|
511 |
### restore cronjobs
|
|
|
512 |
### -----------------------------------------------------------
|
|
|
513 |
mv /etc/cron_backup/sysstat /etc/cron.d/ 2>/dev/null
|
|
|
514 |
mv /etc/cron_backup/00-makewhatis.cron.weekly /etc/cron.weekly/00-makewhatis.cron 2>/dev/null
|
|
|
515 |
mv /etc/cron_backup/* /etc/cron.daily/
|
|
|
516 |
|
|
|
517 |
|
| 18 |
beyerle@PS |
518 |
### turn on kudzu again
|
|
|
519 |
### -----------------------------------------------------------
|
|
|
520 |
chkconfig kudzu on
|
|
|
521 |
|
|
|
522 |
|
| 15 |
beyerle@PS |
523 |
### umount $INSTALL_PART
|
| 16 |
beyerle@PS |
524 |
### -----------------------------------------------------------
|
|
|
525 |
umount $INSTALL_PART
|
| 15 |
beyerle@PS |
526 |
|
| 22 |
beyerle@PS |
527 |
|
|
|
528 |
### print summary
|
|
|
529 |
### -----------------------------------------------------------
|
|
|
530 |
echo "-----------------------------------------------------------"
|
|
|
531 |
echo " LiveCD installed on partition $INSTALL_PART."
|
|
|
532 |
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
|
|
|
533 |
[ ! $NOGRUB ] && echo " GRUB installed in Master Boot Record of $MBR_DEV."
|
|
|
534 |
[ $WIN_PART ] && echo " Entry in grub.conf for Windows partition on $WIN_PART."
|
|
|
535 |
echo "-----------------------------------------------------------"
|
|
|
536 |
echo "End of $SCRIPTNAME."
|
|
|
537 |
echo
|