]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - src/initscripts/init.d/checkfstab
OpenVPN converter: Fix coding style and verbose output.
[people/teissler/ipfire-2.x.git] / src / initscripts / init.d / checkfstab
index 0ccf593d994bfa1fb86290670f1bce8d2a9c0630..ea845458f826424e0e7340a7487ded7644413851 100644 (file)
 
 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}
+               #Skip if root is set by UUID
+               if (grep "root=UUID=" /proc/cmdline > /dev/null); then
+                       exit 0;
+               fi
+               boot_mesg "Checking fstab bootdevice ..."
+               read CMDLINE < /proc/cmdline
+               ROOTPOS=${CMDLINE%%root=*}
+               ROOTPOS=${#ROOTPOS}
+               NEWROOT=`echo ${CMDLINE:$ROOTPOS} | cut -d"=" -f2 | cut -d" " -f1`;
+               OLDBOOT=`cat /etc/fstab | grep -m1 "    /       " | cut -d" " -f1 | cut -f1`;
+               OLDDRV=${OLDBOOT::`expr length $OLDBOOT`-1}
                NEWDRV=${NEWROOT::`expr length $NEWROOT`-1}
-               if [ "$OLDROOT" == "$NEWROOT" ]; then
+               if [ "$OLDDRV" == "$NEWDRV" ]; then
                    echo_ok;
                    exit 0;
                fi
                echo_failure;
-               boot_mesg "Warning! Rootdevice not match with fstab entry!"
+               boot_mesg "Warning! Bootdrive not match with fstab!"
                boot_mesg
-               boot_mesg "Rootdevice:  $NEWROOT"
-               boot_mesg "fstab-entry: $OLDROOT"
+               boot_mesg "Bootdrive:   $NEWDRV"
+               boot_mesg "fstab-entry: $OLDDRV"
                boot_mesg
+               if [ "${OLDDRV:0:4}" == "UUID" ]; then
+                       #Short sleep because the kernel has not finished hardware detections
+                       #and made many messages here and the password question is not readable
+                       sleep 3
+                       boot_mesg "${FAILURE}Error OLD Bootdrive is already a UUID. Can't fix."
+                       boot_mesg "${NORMAL}"
+                       sulogin
+                       reboot -f
+               fi
                boot_mesg "Attempt to repair it ..."
                mount -o remount,rw /
                sed -i -e "s|$OLDDRV|$NEWDRV|g" /etc/fstab