1#!/bin/sh
2#
3# $FreeBSD: head/etc/rc.d/bgfsck 287614 2015-09-10 06:55:28Z hrs $
4#
5
6# PROVIDE: bgfsck
7# REQUIRE: cron devfs syslogd
8# KEYWORD: nojail
9
10. /etc/rc.subr
11
12name="background_fsck"
13rcvar="background_fsck"
14start_cmd="bgfsck_start"
15start_precmd="bgfsck_start_precmd"
16stop_cmd=":"
17
18bgfsck_start_precmd()
19{
20 if [ $($ID -u) != 0 ]; then
21 err 1 "Must be root."
22 fi
23}
24
25bgfsck_start()
26{
27 : ${background_fsck_delay=0}
28 if [ -n "${rc_force}" ]; then
29 background_fsck_delay=0
30 fi
31 if [ ${background_fsck_delay} -lt 0 ]; then
32 warn "Background file system checks delayed indefinitely"
33 return 0
34 fi
35
36 bgfsck_msg='Starting background file system checks'
37 if [ "${background_fsck_delay}" -gt 0 ]; then
38 bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds"
39 fi
40 if [ -z "${rc_force}" ]; then
41 check_startmsgs && echo "${bgfsck_msg}."
42 fi
43
44 (sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \
45 logger -p daemon.notice -t fsck &
46}
47
48load_rc_config $name
49run_rc_command "$1"
2#
3# $FreeBSD: head/etc/rc.d/bgfsck 287614 2015-09-10 06:55:28Z hrs $
4#
5
6# PROVIDE: bgfsck
7# REQUIRE: cron devfs syslogd
8# KEYWORD: nojail
9
10. /etc/rc.subr
11
12name="background_fsck"
13rcvar="background_fsck"
14start_cmd="bgfsck_start"
15start_precmd="bgfsck_start_precmd"
16stop_cmd=":"
17
18bgfsck_start_precmd()
19{
20 if [ $($ID -u) != 0 ]; then
21 err 1 "Must be root."
22 fi
23}
24
25bgfsck_start()
26{
27 : ${background_fsck_delay=0}
28 if [ -n "${rc_force}" ]; then
29 background_fsck_delay=0
30 fi
31 if [ ${background_fsck_delay} -lt 0 ]; then
32 warn "Background file system checks delayed indefinitely"
33 return 0
34 fi
35
36 bgfsck_msg='Starting background file system checks'
37 if [ "${background_fsck_delay}" -gt 0 ]; then
38 bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds"
39 fi
40 if [ -z "${rc_force}" ]; then
41 check_startmsgs && echo "${bgfsck_msg}."
42 fi
43
44 (sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \
45 logger -p daemon.notice -t fsck &
46}
47
48load_rc_config $name
49run_rc_command "$1"