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