xref: /dragonfly/etc/rc.d/fsck (revision 6e278935)
1#!/bin/sh
2#
3# $NetBSD: fsck,v 1.2 2001/06/18 06:42:35 lukem Exp $
4# $FreeBSD: src/etc/rc.d/fsck,v 1.4 2002/10/12 10:31:31 schweikh Exp $
5# $DragonFly: src/etc/rc.d/fsck,v 1.4 2005/11/19 21:47:32 swildner Exp $
6#
7
8# PROVIDE: fsck
9# REQUIRE: disks
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			fsck -p
38
39		case $? in
40		0)
41			;;
42		2)
43			stop_boot
44			;;
45		4)
46			echo "Rebooting..."
47			reboot
48			echo "Reboot failed; help!"
49			stop_boot
50			;;
51		8)
52			if checkyesno fsck_y_enable; then
53				echo "File system preen failed, trying fsck -y."
54				fsck -y
55				case $? in
56				0)
57					;;
58				*)
59					echo "Automatic file system check failed; help!"
60					stop_boot
61					;;
62				esac
63			else
64				echo "Automatic file system check failed; help!"
65				stop_boot
66			fi
67			;;
68		12)
69			echo "Boot interrupted."
70			stop_boot
71			;;
72		130)
73			stop_boot
74			;;
75		*)
76			echo "Unknown error; help!"
77			stop_boot
78			;;
79		esac
80	fi
81}
82
83load_rc_config $name
84run_rc_command "$1"
85