2002-06-13 23:14:37 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: bgfsck
|
2005-07-22 01:57:37 +01:00
|
|
|
# REQUIRE: cron devfs syslogd
|
2004-10-07 14:55:26 +01:00
|
|
|
# KEYWORD: nojail
|
2002-06-13 23:14:37 +01:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="background-fsck"
|
|
|
|
rcvar="background_fsck"
|
2002-12-18 07:21:31 +00:00
|
|
|
start_cmd="bgfsck_start"
|
2015-09-13 05:02:52 +01:00
|
|
|
start_precmd="bgfsck_start_precmd"
|
2002-06-13 23:14:37 +01:00
|
|
|
stop_cmd=":"
|
|
|
|
|
2015-09-13 05:02:52 +01:00
|
|
|
bgfsck_start_precmd()
|
|
|
|
{
|
|
|
|
if [ $($ID -u) != 0 ]; then
|
|
|
|
err 1 "Must be root."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-07-13 07:46:09 +01:00
|
|
|
bgfsck_start()
|
2002-12-18 07:21:31 +00:00
|
|
|
{
|
2015-09-13 05:02:52 +01:00
|
|
|
: ${background_fsck_delay=0}
|
|
|
|
if [ -n "${rc_force}" ]; then
|
2007-03-11 06:53:07 +00:00
|
|
|
background_fsck_delay=0
|
|
|
|
fi
|
|
|
|
if [ ${background_fsck_delay} -lt 0 ]; then
|
2015-09-13 05:02:52 +01:00
|
|
|
warn "Background file system checks delayed indefinitely"
|
2007-03-11 06:53:07 +00:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2002-12-18 07:21:31 +00:00
|
|
|
bgfsck_msg='Starting background file system checks'
|
2007-03-11 06:53:07 +00:00
|
|
|
if [ "${background_fsck_delay}" -gt 0 ]; then
|
2002-12-18 07:21:31 +00:00
|
|
|
bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds"
|
|
|
|
fi
|
2007-03-11 06:53:07 +00:00
|
|
|
if [ -z "${rc_force}" ]; then
|
2009-10-10 23:17:03 +01:00
|
|
|
check_startmsgs && echo "${bgfsck_msg}."
|
2007-03-11 06:53:07 +00:00
|
|
|
fi
|
2002-12-18 07:21:31 +00:00
|
|
|
|
|
|
|
(sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \
|
2003-04-23 16:38:02 +01:00
|
|
|
logger -p daemon.notice -t fsck &
|
2002-12-18 07:21:31 +00:00
|
|
|
}
|
|
|
|
|
2002-06-13 23:14:37 +01:00
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|