[1c48007] | 1 | #!/bin/sh
|
---|
| 2 | # Begin /etc/init.d/checkfs
|
---|
| 3 |
|
---|
| 4 | ### BEGIN INIT INFO
|
---|
| 5 | # Provides: checkfs
|
---|
| 6 | # Required-Start: udev swap $time
|
---|
[614a14e] | 7 | # Should-Start:
|
---|
[1c48007] | 8 | # Required-Stop:
|
---|
| 9 | # Should-Stop:
|
---|
| 10 | # Default-Start: sysinit
|
---|
| 11 | # Default-Stop:
|
---|
| 12 | # Short-Description: Checks local filesystems before mounting.
|
---|
| 13 | # Description: Checks local filesystmes before mounting.
|
---|
| 14 | # X-LFS-Default-Start: S30
|
---|
| 15 | # X-LFS-Default-Stop:
|
---|
| 16 | # X-LFS-Provided-By: LFS
|
---|
| 17 | ### END INIT INFO
|
---|
| 18 |
|
---|
| 19 | . /lib/lsb/init-functions
|
---|
| 20 |
|
---|
| 21 | case "${1}" in
|
---|
| 22 | start)
|
---|
| 23 | if [ -f /fastboot ]; then
|
---|
| 24 | echo "${INFO}/fastboot found!"
|
---|
| 25 | log_success_msg "Will not perform file system checks as requested."
|
---|
| 26 | exit 0
|
---|
| 27 | fi
|
---|
| 28 |
|
---|
| 29 | mount -n -o remount,ro / >/dev/null
|
---|
| 30 | if [ ${?} != 0 ]
|
---|
| 31 | then
|
---|
| 32 | log_failure_msg "Mounting root file system in read-only mode"
|
---|
| 33 | echo "${FAILURE}FAILURE:\n"
|
---|
| 34 | echo -n "${FIALURE}Cannot check root filesystem because it "
|
---|
| 35 | echo "${FAILURE}could not be mounted"
|
---|
| 36 | echo "${FAILURE}in read-only mode.\n\n"
|
---|
| 37 | echo -n "${FAILURE}After you press Enter, this system will be "
|
---|
| 38 | echo "${FAILURE}halted and powered off.\n"
|
---|
| 39 | echo "${INFO}Press enter to continue...${NORMAL}"
|
---|
| 40 | read ENTER
|
---|
| 41 | /etc/rc.d/init.d/halt stop
|
---|
| 42 | fi
|
---|
| 43 |
|
---|
| 44 | if [ -f /forcefsck ]
|
---|
| 45 | then
|
---|
| 46 | echo "${INFO}/forcefsck found!"
|
---|
| 47 | log_success_msg "${INFO}Forcing file system checks as requested."
|
---|
| 48 | options="-f"
|
---|
| 49 | else
|
---|
| 50 | options=""
|
---|
| 51 | fi
|
---|
| 52 |
|
---|
| 53 | # Note: -a option used to be -p; but this fails e.g.
|
---|
| 54 | # on fsck.minix
|
---|
| 55 | fsck ${options} -a -A -C -T
|
---|
| 56 | error_value=${?}
|
---|
| 57 |
|
---|
| 58 | if [ "${error_value}" = 0 ]
|
---|
| 59 | then
|
---|
| 60 | log_success_msg "Checking file systems..."
|
---|
| 61 | elif [ "${error_value}" = 1 ]
|
---|
| 62 | then
|
---|
| 63 | log_warning_msg "Checking file systems..."
|
---|
| 64 | echo "${WARNING}WARNING:\n"
|
---|
| 65 | echo "${WARNING}File system errors were found and have been"
|
---|
| 66 | echo "${WARNING}corrected. You may want to double-check that"
|
---|
| 67 | echo "${WARNING}everything was fixed properly.${NORMAL}"
|
---|
| 68 | elif [ "${error_value}" = 2 -o "${error_value}" = 3 ]; then
|
---|
| 69 | log_warning_msg "Checking file systems..."
|
---|
| 70 | echo "${WARNING}WARNING:\n"
|
---|
| 71 | echo "${WARNING}File system errors were found and have been been"
|
---|
| 72 | echo "${WARNING}corrected, but the nature of the errors require"
|
---|
| 73 | echo "${WARNING}this system to be rebooted.\n"
|
---|
| 74 | echo "After you press enter, this system will be rebooted.\n"
|
---|
| 75 | echo "${INFO}Press Enter to continue...${NORMAL}"
|
---|
| 76 | read ENTER
|
---|
| 77 | reboot -f
|
---|
| 78 | elif [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then
|
---|
| 79 | log_failure_msg "Checking file systems..."
|
---|
| 80 | echo "${FAILURE}FAILURE:\n"
|
---|
| 81 | echo "${FAILURE}File system errors were encountered that could"
|
---|
| 82 | echo "${FAILURE}not be fixed automatically. This system cannot"
|
---|
| 83 | echo "${FAILURE}continue to boot and will therefore be halted"
|
---|
| 84 | echo "${FAILURE}until those errors are fixed manually by a"
|
---|
| 85 | echo "${FAILURE}System Administrator.\n"
|
---|
| 86 | echo "${FAILURE}After you press Enter, this system will be"
|
---|
| 87 | echo "${FAILURE}halted and powered off.\n"
|
---|
| 88 | echo "${INFO}Press Enter to continue...${NORMAL}"
|
---|
| 89 | read ENTER
|
---|
| 90 | /etc/rc.d/init.d/halt stop
|
---|
| 91 | elif [ "${error_value}" -ge 16 ]; then
|
---|
| 92 | log_failure_msg "Checking file systems..."
|
---|
| 93 | echo "${FAILURE}FAILURE:\n"
|
---|
| 94 | echo "${FAILURE}Unexpected Failure running fsck. Exited with error"
|
---|
| 95 | echo "${FAILURE}code: ${error_value}.${NORMAL}"
|
---|
| 96 | exit ${error_value}
|
---|
| 97 | fi
|
---|
| 98 | ;;
|
---|
| 99 | *)
|
---|
| 100 | echo "Usage: ${0} {start}"
|
---|
| 101 | exit 1
|
---|
| 102 | ;;
|
---|
| 103 | esac
|
---|
| 104 |
|
---|
| 105 | # End /etc/init.d/checkfs
|
---|