1 |
gordonr |
1.1 |
upgrade |
2 |
|
|
text |
3 |
|
|
cdrom |
4 |
|
|
bootloader --location=mbr |
5 |
|
|
zerombr yes |
6 |
|
|
|
7 |
|
|
%post |
8 |
|
|
/sbin/syslogd & |
9 |
slords |
1.2 |
sleep 2 |
10 |
gordonr |
1.1 |
/sbin/e-smith/signal-event post-upgrade |
11 |
|
|
|
12 |
slords |
1.2 |
# HACK - fix selinux config |
13 |
|
|
perl -p -i -e 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config |
14 |
gordonr |
1.1 |
|
15 |
slords |
1.2 |
%pre |
16 |
|
|
#!/bin/sh |
17 |
|
|
set -x |
18 |
|
|
|
19 |
|
|
# let's assume it's a SCSI system |
20 |
|
|
if grep -q 'sda$' /proc/partitions; then |
21 |
|
|
disk=sda |
22 |
|
|
else |
23 |
|
|
# No SCSI Drives is must be IDE |
24 |
|
|
media=`cat /proc/ide/hda/media` |
25 |
|
|
if [ $media == "disk" ] ; then |
26 |
|
|
disk=hda |
27 |
|
|
fi |
28 |
|
|
fi |
29 |
|
|
|
30 |
|
|
set $disk |
31 |
|
|
found=`echo $#` |
32 |
|
|
if [ $found -gt "0" ] ; then |
33 |
|
|
# Dump out current partitions |
34 |
|
|
sfdisk -d /dev/$disk > /tmp/oldparts |
35 |
|
|
|
36 |
|
|
# Check if we have any ext2/3 or swap partitions |
37 |
|
|
if grep -q 'Id=8[23]' /tmp/oldparts; then |
38 |
gordonr |
1.3 |
echo -n "Converting partitions to RAID..." >/dev/tty1 |
39 |
slords |
1.2 |
# Convert ext2/3 and swap partitions to raid autodetect |
40 |
|
|
sed 's/Id=8[32]/Id=fd/' /tmp/oldparts > /tmp/newparts |
41 |
|
|
|
42 |
|
|
# Find swap partition for future checks |
43 |
|
|
swap=`grep 'Id=82' /tmp/oldparts | sed "s/$disk\([0-9]\+\) :.*/md\1/"` |
44 |
|
|
|
45 |
|
|
# Loop throught partitions and convert to degraded raid1 |
46 |
|
|
for part in `grep 'Id=8[23]' /tmp/oldparts | sed 's/ :.*//'`; do |
47 |
|
|
mdpart=`echo $part | sed "s/$disk\([0-9]\+\)/md\1/"` |
48 |
gordonr |
1.3 |
|
49 |
|
|
echo -n "$part..." >/dev/tty1 |
50 |
slords |
1.2 |
mdadm --create $mdpart --run --level=1 --raid-devices=2 $part missing |
51 |
|
|
if [ "$mdpart" == "$swap" ]; then |
52 |
|
|
# Recreate swap partition |
53 |
|
|
mkswap $swap |
54 |
|
|
else |
55 |
|
|
# Resize ext2/3 partitions (fix superblock - part 1) |
56 |
|
|
resize2fs -f $mdpart |
57 |
|
|
fi |
58 |
|
|
done |
59 |
gordonr |
1.3 |
|
60 |
|
|
echo "done" >/dev/tty1 |
61 |
|
|
|
62 |
slords |
1.2 |
# Write out new converted partition table |
63 |
|
|
sfdisk --force /dev/$disk < /tmp/newparts |
64 |
|
|
|
65 |
gordonr |
1.3 |
echo -n "Running fsck on converted partitions..." >/dev/tty1 |
66 |
|
|
|
67 |
slords |
1.2 |
mkdir /mnt/tmp |
68 |
|
|
for part in `grep 'Id=fd' /tmp/newparts | sed "s/$disk\([0-9]\+\) :.*/md\1/"`; do |
69 |
|
|
if [ "$part" != "$swap" ]; then |
70 |
|
|
# Resize ext2/3 partitions (fix superblock - part 2) |
71 |
gordonr |
1.3 |
echo -n "$part..." >/dev/tty1 |
72 |
slords |
1.2 |
e2fsck -f $part |
73 |
|
|
|
74 |
|
|
# Check for /etc/fstab on partitions and convert entries |
75 |
|
|
mount $part /mnt/tmp |
76 |
|
|
if [ -r /mnt/tmp/etc/fstab ]; then |
77 |
|
|
cat /mnt/tmp/etc/fstab | sed "s/$disk\([0-9]\+\)/md\1/" > /mnt/tmp/etc/fstab.tmp |
78 |
|
|
mv /mnt/tmp/etc/fstab.tmp /mnt/tmp/etc/fstab |
79 |
|
|
fi |
80 |
|
|
umount /mnt/tmp |
81 |
|
|
fi |
82 |
|
|
done |
83 |
gordonr |
1.3 |
echo "done" >/dev/tty1 |
84 |
slords |
1.2 |
rmdir /mnt/tmp |
85 |
|
|
mdadm --stop --scan |
86 |
|
|
fi |
87 |
|
|
fi |