]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/initscripts/init.d/checkfstab
core81: set need reboot flag and restart apache.
[people/teissler/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 #Skip if root is set by UUID
21 if (grep "root=UUID=" /proc/cmdline > /dev/null); then
22 exit 0;
23 fi
24 boot_mesg "Checking fstab bootdevice ..."
25 read CMDLINE < /proc/cmdline
26 ROOTPOS=${CMDLINE%%root=*}
27 ROOTPOS=${#ROOTPOS}
28 NEWROOT=`echo ${CMDLINE:$ROOTPOS} | cut -d"=" -f2 | cut -d" " -f1`;
29 OLDBOOT=`cat /etc/fstab | grep -m1 " / " | cut -d" " -f1 | cut -f1`;
30 OLDDRV=${OLDBOOT::`expr length $OLDBOOT`-1}
31 NEWDRV=${NEWROOT::`expr length $NEWROOT`-1}
32 if [ "$OLDDRV" == "$NEWDRV" ]; then
33 echo_ok;
34 exit 0;
35 fi
36 echo_failure;
37 boot_mesg "Warning! Bootdrive not match with fstab!"
38 boot_mesg
39 boot_mesg "Bootdrive: $NEWDRV"
40 boot_mesg "fstab-entry: $OLDDRV"
41 boot_mesg
42 if [ "${OLDDRV:0:4}" == "UUID" ]; then
43 #Short sleep because the kernel has not finished hardware detections
44 #and made many messages here and the password question is not readable
45 sleep 3
46 boot_mesg "${FAILURE}Error OLD Bootdrive is already a UUID. Can't fix."
47 boot_mesg "${NORMAL}"
48 sulogin
49 reboot -f
50 fi
51 boot_mesg "Attempt to repair it ..."
52 mount -o remount,rw /
53 sed -i -e "s|$OLDDRV|$NEWDRV|g" /etc/fstab
54 mount /boot
55 sed -i -e "s|$OLDDRV|$NEWDRV|g" /boot/grub/grub.conf
56 umount /boot
57 echo_ok;
58 exit 0;
59 ;;
60 *)
61 echo "Usage: ${0} {start}"
62 exit 1
63 ;;
64 esac
65
66 # End $rc_base/init.d/checkfstab