fsck revision 124618
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 124618 2004-01-17 10:40:45Z 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
44		case $? in
45		0)
46			;;
47		2)
48			stop_boot
49			;;
50		4)
51			echo "Rebooting..."
52			reboot
53			echo "Reboot failed; help!"
54			stop_boot
55			;;
56		8)
57			if checkyesno fsck_y_enable; then
58				echo "File system preen failed, trying fsck -y."
59				fsck -y
60				case $? in
61				0)
62					;;
63				*)
64				echo "Automatic file system check failed; help!"
65					stop_boot
66					;;
67				esac
68			else
69				echo "Automatic file system check failed; help!"
70				stop_boot
71			fi
72			;;
73		12)
74			echo "Boot interrupted."
75			stop_boot
76			;;
77		130)
78			stop_boot
79			;;
80		*)
81			echo "Unknown error; help!"
82			stop_boot
83			;;
84		esac
85	fi
86}
87
88load_rc_config $name
89run_rc_command "$1"
90