aboutsummaryrefslogtreecommitdiff
path: root/libexec/rc/rc.d/cleanvar
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/rc/rc.d/cleanvar')
-rwxr-xr-xlibexec/rc/rc.d/cleanvar50
1 files changed, 50 insertions, 0 deletions
diff --git a/libexec/rc/rc.d/cleanvar b/libexec/rc/rc.d/cleanvar
new file mode 100755
index 000000000000..dce5baa6875b
--- /dev/null
+++ b/libexec/rc/rc.d/cleanvar
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+#
+
+# 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 -x /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 -x /var/spool/lock -type f -delete
+ >/var/spool/lock/clean_var
+ fi
+ if [ -d /var/spool/uucp/.Temp ]; then
+ find -x /var/spool/uucp/.Temp -delete
+ fi
+}
+
+load_rc_config $name
+
+# doesn't make sense to run in a svcj
+cleanvar_svcj="NO"
+
+run_rc_command "$1"