freebsd-nq/libexec/rc/rc.d/cleanvar
Bjoern A. Zeeb 0696600c41 Move the rc framework out of sbin/init into libexec/rc.
The reasons for this are forward looking to pkgbase:
 * /sbin/init is a special binary; try not to replace it with
   every package update because an rc script was touched.
   (a follow-up commit will make init its own package)
 * having rc in its own place will allow more easy replacement
   of the rc framework with alternatives, such as openrc.

Discussed with:		brd (during BSDCam), kmoore
Requested by:		cem, bz
PR:			231522
Approved by:		re (gjb)
2018-10-17 16:49:11 +00:00

48 lines
908 B
Bash
Executable File

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: cleanvar
# REQUIRE: var
. /etc/rc.subr
name="cleanvar"
desc="Purge /var directory"
rcvar="cleanvar_enable"
start_precmd="${name}_prestart"
start_cmd="${name}_start"
stop_cmd=":"
extra_commands="reload"
reload_cmd="${name}_start"
cleanvar_prestart()
{
# These files must be removed only the first time this script is run
# on boot.
#
rm -f /var/run/clean_var /var/spool/lock/clean_var
}
cleanvar_start()
{
if [ -d /var/run -a ! -f /var/run/clean_var ]; then
# Skip over logging sockets
find /var/run \( -type f -or -type s ! -name log -and ! -name logpriv \) -delete
>/var/run/clean_var
fi
if [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then
find /var/spool/lock -type f -delete
>/var/spool/lock/clean_var
fi
if [ -d /var/spool/uucp/.Temp ]; then
find /var/spool/uucp/.Temp -delete
fi
}
load_rc_config $name
run_rc_command "$1"