fsck revision 136224
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 136224 2004-10-07 13:55:26Z mtm $
5#
6
7# PROVIDE: fsck
8# REQUIRE: localswap
9# KEYWORD: nojail
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 [ ! -r /etc/fstab ]; then
33		echo "Warning! No /etc/fstab: skipping disk checks."
34	elif [ "$autoboot" = yes ]; then
35					# During fsck ignore SIGQUIT
36		trap : 3
37
38		echo "Starting file system checks:"
39		if checkyesno background_fsck; then
40			fsck -F -p
41		else
42			fsck -p
43		fi
44
45		case $? in
46		0)
47			;;
48		2)
49			stop_boot
50			;;
51		4)
52			echo "Rebooting..."
53			reboot
54			echo "Reboot failed; help!"
55			stop_boot
56			;;
57		8)
58			if checkyesno fsck_y_enable; then
59				echo "File system preen failed, trying fsck -y."
60				fsck -y
61				case $? in
62				0)
63					;;
64				*)
65				echo "Automatic file system check failed; help!"
66					stop_boot
67					;;
68				esac
69			else
70				echo "Automatic file system check failed; help!"
71				stop_boot
72			fi
73			;;
74		12)
75			echo "Boot interrupted."
76			stop_boot
77			;;
78		130)
79			stop_boot
80			;;
81		*)
82			echo "Unknown error; help!"
83			stop_boot
84			;;
85		esac
86	fi
87}
88
89load_rc_config $name
90run_rc_command "$1"
91