]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/initscripts/init.d/checkfstab
0ccf593d994bfa1fb86290670f1bce8d2a9c0630
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / checkfstab
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)
20 boot_mesg "Checking fstab rootdevice entry ..."
21 OLDROOT=`cat /etc/fstab | grep " / " | cut -d" " -f1`;
22 NEWROOT=`df | grep " /$" -m1 | cut -d" " -f1`;
23 OLDDRV=${OLDROOT::`expr length $OLDROOT`-1}
24 NEWDRV=${NEWROOT::`expr length $NEWROOT`-1}
25 if [ "$OLDROOT" == "$NEWROOT" ]; then
26 echo_ok;
27 exit 0;
28 fi
29 echo_failure;
30 boot_mesg "Warning! Rootdevice not match with fstab entry!"
31 boot_mesg
32 boot_mesg "Rootdevice: $NEWROOT"
33 boot_mesg "fstab-entry: $OLDROOT"
34 boot_mesg
35 boot_mesg "Attempt to repair it ..."
36 mount -o remount,rw /
37 sed -i -e "s|$OLDDRV|$NEWDRV|g" /etc/fstab
38 mount /boot
39 sed -i -e "s|$OLDDRV|$NEWDRV|g" /boot/grub/grub.conf
40 umount /boot
41 echo_ok;
42 exit 0;
43 ;;
44 *)
45 echo "Usage: ${0} {start}"
46 exit 1
47 ;;
48 esac
49
50 # End $rc_base/init.d/checkfstab