fsck revision 124630
1#!/bin/sh
2#
3# $NetBSD: fsck,v 1.2 2001/06/18 06:42:35 lukem Exp $
4# $FreeBSD: head/etc/rc.d/fsck 124630 2004-01-17 11:52:37Z mtm $
5#
6
7# PROVIDE: fsck
8# REQUIRE: localswap
9# KEYWORD: FreeBSD
10
11. /etc/rc.subr
12
13name="fsck"
14start_cmd="fsck_start"
15stop_cmd=":"
16
17stop_boot()
18{
19	#	Terminate the process (which may include the parent /etc/rc)
20	#	if booting directly to multiuser mode.
21	#
22	if [ "$autoboot" = yes ]; then
23		kill -TERM $$
24	fi
25	exit 1
26}
27
28fsck_start()
29{
30	if [ "$autoboot" = no ]; then
31		echo "Fast boot: skipping disk checks."
32	elif [ "$autoboot" = yes ]; then
33					# During fsck ignore SIGQUIT
34		trap : 3
35
36		echo "Starting file system checks:"
37		if checkyesno background_fsck; then
38			fsck -F -p
39		else
40			fsck -p
41		fi
42
43		case $? in
44		0)
45			;;
46		2)
47			stop_boot
48			;;
49		4)
50			echo "Rebooting..."
51			reboot
52			echo "Reboot failed; help!"
53			stop_boot
54			;;
55		8)
56			if checkyesno fsck_y_enable; then
57				echo "File system preen failed, trying fsck -y."
58				fsck -y
59				case $? in
60				0)
61					;;
62				*)
63				echo "Automatic file system check failed; help!"
64					stop_boot
65					;;
66				esac
67			else
68				echo "Automatic file system check failed; help!"
69				stop_boot
70			fi
71			;;
72		12)
73			echo "Boot interrupted."
74			stop_boot
75			;;
76		130)
77			stop_boot
78			;;
79		*)
80			echo "Unknown error; help!"
81			stop_boot
82			;;
83		esac
84	fi
85}
86
87load_rc_config $name
88run_rc_command "$1"
89