fsck revision 298514
1#!/bin/sh
2#
3# $FreeBSD: head/etc/rc.d/fsck 298514 2016-04-23 16:10:54Z lme $
4#
5
6# PROVIDE: fsck
7# REQUIRE: swap
8# KEYWORD: nojail
9
10. /etc/rc.subr
11
12name="fsck"
13desc="Run file system checks"
14start_cmd="fsck_start"
15stop_cmd=":"
16
17fsck_start()
18{
19	if [ "$autoboot" = no ]; then
20		echo "Fast boot: skipping disk checks."
21	elif [ ! -r /etc/fstab ]; then
22		echo "Warning! No /etc/fstab: skipping disk checks."
23	elif [ "$autoboot" = yes ]; then
24		# During fsck ignore SIGQUIT
25		trap : 3
26
27		check_startmsgs && echo "Starting file system checks:"
28		if checkyesno background_fsck; then
29			fsck -F -p
30		else
31			fsck -p
32		fi
33
34		case $? in
35		0)
36			;;
37		2)
38			stop_boot
39			;;
40		4)
41			echo "Rebooting..."
42			reboot
43			echo "Reboot failed; help!"
44			stop_boot
45			;;
46		8)
47			if checkyesno fsck_y_enable; then
48				echo "File system preen failed, trying fsck -y ${fsck_y_flags}"
49				fsck -y ${fsck_y_flags}
50				case $? in
51				0)
52					;;
53				*)
54				echo "Automatic file system check failed; help!"
55					stop_boot
56					;;
57				esac
58			else
59				echo "Automatic file system check failed; help!"
60				stop_boot
61			fi
62			;;
63		12)
64			echo "Boot interrupted."
65			stop_boot
66			;;
67		130)
68			stop_boot
69			;;
70		*)
71			echo "Unknown error; help!"
72			stop_boot
73			;;
74		esac
75	fi
76}
77
78load_rc_config $name
79run_rc_command "$1"
80