Add checkfstab (repair fstab and grup.conf if the rootdevice has changed)
authorArne Fitzenreiter <arne_f@ipfire.org>
Wed, 23 Jul 2008 14:52:31 +0000 (16:52 +0200)
committerArne Fitzenreiter <arne_f@ipfire.org>
Wed, 23 Jul 2008 14:52:31 +0000 (16:52 +0200)
config/rootfiles/common/initscripts
config/rootfiles/updater/filelists/core15
lfs/initscripts
src/initscripts/init.d/checkfstab [new file with mode: 0644]

index 1b4e0e0..836f26d 100644 (file)
@@ -9,6 +9,7 @@ etc/rc.d/init.d/apache
 #etc/rc.d/init.d/applejuice
 etc/rc.d/init.d/beep
 etc/rc.d/init.d/checkfs
+etc/rc.d/init.d/checkfstab
 #etc/rc.d/init.d/clamav
 etc/rc.d/init.d/cleanfs
 etc/rc.d/init.d/connectd
@@ -123,6 +124,7 @@ etc/rc.d/rc6.d/S99reboot
 etc/rc.d/rcsysinit.d/S00mountkernfs
 etc/rc.d/rcsysinit.d/S05modules
 etc/rc.d/rcsysinit.d/S10udev
+etc/rc.d/rcsysinit.d/S19checkfstab
 etc/rc.d/rcsysinit.d/S20swap
 etc/rc.d/rcsysinit.d/S30checkfs
 etc/rc.d/rcsysinit.d/S40mountfs
index f4ec6e1..2c19e7d 100644 (file)
@@ -19,3 +19,5 @@ bin/ntfs-3g
 lib/libntfs-3g.so
 lib/libntfs-3g.so.31
 lib/libntfs-3g.so.31.0.0
+etc/rc.d/init.d/checkfstab
+etc/rc.d/rcsysinit.d/S19checkfstab
index c56b2b9..fff10c1 100644 (file)
@@ -126,6 +126,7 @@ $(TARGET) :
        ln -sf ../init.d/mountkernfs /etc/rc.d/rcsysinit.d/S00mountkernfs
        ln -sf ../init.d/modules     /etc/rc.d/rcsysinit.d/S05modules
        ln -sf ../init.d/udev        /etc/rc.d/rcsysinit.d/S10udev
+       ln -sf ../init.d/checkfstab  /etc/rc.d/rcsysinit.d/S19checkfstab
        ln -sf ../init.d/swap        /etc/rc.d/rcsysinit.d/S20swap
        ln -sf ../init.d/checkfs     /etc/rc.d/rcsysinit.d/S30checkfs
        ln -sf ../init.d/mountfs     /etc/rc.d/rcsysinit.d/S40mountfs
diff --git a/src/initscripts/init.d/checkfstab b/src/initscripts/init.d/checkfstab
new file mode 100644 (file)
index 0000000..0ccf593
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+########################################################################
+# Begin $rc_base/init.d/checkfstab
+#
+# Description : Check and repair fstab if the drivename has changed
+#
+# Authors     : Arne Fitzenreiter - arne_f@ipfire.org
+#
+# Version     : 00.00
+#
+# Notes       :
+#
+########################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+
+case "${1}" in
+       start)
+               boot_mesg "Checking fstab rootdevice entry ..."
+               OLDROOT=`cat /etc/fstab | grep " / " | cut -d" " -f1`;
+               NEWROOT=`df | grep " /$" -m1 | cut -d" " -f1`;
+               OLDDRV=${OLDROOT::`expr length $OLDROOT`-1}
+               NEWDRV=${NEWROOT::`expr length $NEWROOT`-1}
+               if [ "$OLDROOT" == "$NEWROOT" ]; then
+                   echo_ok;
+                   exit 0;
+               fi
+               echo_failure;
+               boot_mesg "Warning! Rootdevice not match with fstab entry!"
+               boot_mesg
+               boot_mesg "Rootdevice:  $NEWROOT"
+               boot_mesg "fstab-entry: $OLDROOT"
+               boot_mesg
+               boot_mesg "Attempt to repair it ..."
+               mount -o remount,rw /
+               sed -i -e "s|$OLDDRV|$NEWDRV|g" /etc/fstab
+               mount /boot
+               sed -i -e "s|$OLDDRV|$NEWDRV|g" /boot/grub/grub.conf
+               umount /boot
+               echo_ok;
+               exit 0;
+               ;;
+       *)
+               echo "Usage: ${0} {start}"
+               exit 1
+               ;;
+esac
+
+# End $rc_base/init.d/checkfstab