]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - etc/rc.d/fsck
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / etc / rc.d / fsck
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: fsck
7 # REQUIRE: swap
8 # KEYWORD: nojail
9
10 . /etc/rc.subr
11
12 name="fsck"
13 start_cmd="fsck_start"
14 stop_cmd=":"
15
16 fsck_start()
17 {
18         if [ "$autoboot" = no ]; then
19                 echo "Fast boot: skipping disk checks."
20         elif [ ! -r /etc/fstab ]; then
21                 echo "Warning! No /etc/fstab: skipping disk checks."
22         elif [ "$autoboot" = yes ]; then
23                                         # During fsck ignore SIGQUIT
24                 trap : 3
25
26                 check_startmsgs && echo "Starting file system checks:"
27                 if checkyesno background_fsck; then
28                         fsck -F -p
29                 else
30                         fsck -p
31                 fi
32
33                 case $? in
34                 0)
35                         ;;
36                 2)
37                         stop_boot
38                         ;;
39                 4)
40                         echo "Rebooting..."
41                         reboot
42                         echo "Reboot failed; help!"
43                         stop_boot
44                         ;;
45                 8)
46                         if checkyesno fsck_y_enable; then
47                                 echo "File system preen failed, trying fsck -y ${fsck_y_flags}"
48                                 fsck -y ${fsck_y_flags}
49                                 case $? in
50                                 0)
51                                         ;;
52                                 *)
53                                 echo "Automatic file system check failed; help!"
54                                         stop_boot
55                                         ;;
56                                 esac
57                         else
58                                 echo "Automatic file system check failed; help!"
59                                 stop_boot
60                         fi
61                         ;;
62                 12)
63                         echo "Boot interrupted."
64                         stop_boot
65                         ;;
66                 130)
67                         stop_boot
68                         ;;
69                 *)
70                         echo "Unknown error; help!"
71                         stop_boot
72                         ;;
73                 esac
74         fi
75 }
76
77 load_rc_config $name
78 run_rc_command "$1"