]>
Commit | Line | Data |
---|---|---|
ba3e5905 AF |
1 | #!/bin/sh |
2 | ######################################################################## | |
3 | # Begin $rc_base/init.d/checkfstab | |
4 | # | |
5 | # Description : Check and repair fstab if the drivename has changed | |
6 | # | |
7 | # Authors : Arne Fitzenreiter - arne_f@ipfire.org | |
8 | # | |
9 | # Version : 00.00 | |
10 | # | |
11 | # Notes : | |
12 | # | |
13 | ######################################################################## | |
14 | ||
15 | . /etc/sysconfig/rc | |
16 | . ${rc_functions} | |
17 | ||
18 | case "${1}" in | |
19 | start) | |
27159f53 | 20 | boot_mesg "Checking fstab bootdevice ..." |
a7748862 AF |
21 | ROOTPOS=`expr index "$CMDLINE" root=` |
22 | NEWROOT=`echo ${CMDLINE:$ROOTPOS} | cut -d"=" -f2 | cut -d" " -f1`; | |
27159f53 AF |
23 | OLDBOOT=`cat /etc/fstab | grep -m1 "/boot" | cut -d" " -f1 | cut -f1`; |
24 | OLDDRV=${OLDBOOT::`expr length $OLDBOOT`-1} | |
ba3e5905 | 25 | NEWDRV=${NEWROOT::`expr length $NEWROOT`-1} |
27159f53 | 26 | if [ "$OLDDRV" == "$NEWDRV" ]; then |
ba3e5905 AF |
27 | echo_ok; |
28 | exit 0; | |
29 | fi | |
30 | echo_failure; | |
27159f53 | 31 | boot_mesg "Warning! Bootdrive not match with fstab!" |
ba3e5905 | 32 | boot_mesg |
27159f53 AF |
33 | boot_mesg "Bootdrive: $NEWDRV" |
34 | boot_mesg "fstab-entry: $OLDDRV" | |
ba3e5905 AF |
35 | boot_mesg |
36 | boot_mesg "Attempt to repair it ..." | |
37 | mount -o remount,rw / | |
38 | sed -i -e "s|$OLDDRV|$NEWDRV|g" /etc/fstab | |
39 | mount /boot | |
40 | sed -i -e "s|$OLDDRV|$NEWDRV|g" /boot/grub/grub.conf | |
41 | umount /boot | |
42 | echo_ok; | |
43 | exit 0; | |
44 | ;; | |
45 | *) | |
46 | echo "Usage: ${0} {start}" | |
47 | exit 1 | |
48 | ;; | |
49 | esac | |
50 | ||
51 | # End $rc_base/init.d/checkfstab |