Files
initscripts/SRC/initscripts/init.d/checkfs
Jay Larson 17afdf7765 The following changes were made:
* removed quotes around chroot command in usher
  * removed hwclock from Required-Start in checkfs
  * removed $local_fs from Required-Start in hostname
  * updated mountvirtfs to create /run/utmp
  * added 2 conditionals to readsvcs() in update-rc
2017-05-20 09:18:03 -05:00

125 lines
2.5 KiB
Bash
Executable File

#!/bin/sh
### BEGIN INIT INFO
# Provides: checkfs
# Required-Start: udev swap $time hostname
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Check filesystems for errors
# X-Required: true
### END INIT INFO
. /lib/lsb/init-functions
case "$1" in
start)
if [ -f /fastboot ] || grep -qwi 'fastboot' /proc/cmdline; then
log_init_msg "Fastboot enabled - skipping file system checks"
log_success_msg
exit 0
fi
log_init_msg "Mounting root file system in read-only mode"
mount -n -o remount,ro / >/dev/null
if [ $? != 0 ]; then
log_failure_msg
echo
echo "Failed to mount root filesystem in read-only mode."
echo
echo "Press Enter to halt"
read
/etc/init.d/halt stop
else
log_success_msg
fi
if [ -f /forcefsck ] || grep -qwi 'forcefsck' /proc/cmdline; then
checking='Checking file systems with force'
force='-f'
else
checking='Checking file systems'
fi
case "$FSCKFIX" in
1|y|yes)
fix='-y'
;;
*)
fix='-a'
;;
esac
case "$VERBOSE" in
1|y|yes)
echo
echo "$checking"
fsck $force $fix -A -C -T
;;
*)
log_init_msg "$checking"
fsck $force $fix -A -T >/dev/null
;;
esac
status=$?
case "$VERBOSE" in
1|y|yes)
echo
if [ $status == 0 ]; then
exit 0
else
log_init_msg "Filesystem issues detected"
fi
;;
esac
if [ $status == 0 ]; then
log_success_msg
elif [ $status != 1 ]; then
log_warning_msg
echo
echo "WARNING: File system errors were detected and repaired."
echo
elif [ $status == 2 -o $status == 3 ]; then
log_warning_msg
echo
echo "WARNING: File system errors were detected and repaired."
echo "The repairs require the system to be rebooted."
echo
echo "Press enter to reboot"
read
reboot -f
elif [ $status -gt 3 -a $status -lt 16 ]; then
log_failure_msg
echo
echo "File system errors were detected, but could not be"
echo "repaired automatically."
echo
echo "Press enter to halt"
read
/etc/init.d/halt stop
else
log_failure_msg
echo
echo "fsck exited with unexpected status: $status"
echo
exit $status
fi
;;
*)
echo "Usage: $0 [start]"
exit 1
;;
esac
exit 0