2002-06-13 22:14:37 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# $FreeBSD$
|
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: cleanvar
|
2012-09-11 05:04:59 +00:00
|
|
|
# REQUIRE: var
|
2002-06-13 22:14:37 +00:00
|
|
|
|
2005-12-19 10:57:00 +00:00
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="cleanvar"
|
2016-04-23 16:10:54 +00:00
|
|
|
desc="Purge /var directory"
|
2012-01-14 02:18:41 +00:00
|
|
|
rcvar="cleanvar_enable"
|
2005-12-19 10:57:00 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2012-07-13 06:46:09 +00:00
|
|
|
cleanvar_start()
|
2005-12-19 10:57:00 +00:00
|
|
|
{
|
|
|
|
if [ -d /var/run -a ! -f /var/run/clean_var ]; then
|
2018-02-06 21:35:41 +00:00
|
|
|
# Skip over logging sockets
|
|
|
|
find /var/run \( -type f -or -type s ! -name log -and ! -name logpriv \) -delete
|
2005-12-19 10:57:00 +00:00
|
|
|
>/var/run/clean_var
|
|
|
|
fi
|
|
|
|
if [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then
|
2018-02-06 21:35:41 +00:00
|
|
|
find /var/spool/lock -type f -delete
|
2005-12-19 10:57:00 +00:00
|
|
|
>/var/spool/lock/clean_var
|
|
|
|
fi
|
2018-02-06 21:35:41 +00:00
|
|
|
if [ -d /var/spool/uucp/.Temp ]; then
|
|
|
|
find /var/spool/uucp/.Temp -delete
|
|
|
|
fi
|
2005-12-19 10:57:00 +00:00
|
|
|
}
|
2002-06-13 22:14:37 +00:00
|
|
|
|
2005-12-19 10:57:00 +00:00
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|