1#!/bin/sh 2# 3# 4 5# PROVIDE: bgfsck 6# REQUIRE: cron devfs syslogd 7# KEYWORD: nojail 8 9. /etc/rc.subr 10 11name="background_fsck" 12desc="Run fsck in background" 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 startmsg "${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 49 50# doesn't make sense to run in a svcj 51bgfsck_svcj="NO" 52 53run_rc_command "$1" 54