cleanvar revision 136224
167754Smsmith#!/bin/sh 267754Smsmith# 367754Smsmith# $FreeBSD: head/etc/rc.d/cleanvar 136224 2004-10-07 13:55:26Z mtm $ 4100966Siwasaki# 567754Smsmith 667754Smsmith# PROVIDE: cleanvar 767754Smsmith# REQUIRE: mountcritlocal var 867754Smsmith 967754Smsmithpurgedir() 1067754Smsmith{ 1167754Smsmith local dir file 1291116Smsmith 1370243Smsmith if [ $# -eq 0 ]; then 1467754Smsmith purgedir . 1567754Smsmith else 1667754Smsmith for dir 1767754Smsmith do 1867754Smsmith ( 1967754Smsmith cd "$dir" && for file in .* * 2067754Smsmith do 2167754Smsmith [ ."$file" = .. -o ."$file" = ... ] && continue 2267754Smsmith if [ -d "$file" -a ! -L "$file" ] 2367754Smsmith then 2467754Smsmith purgedir "$file" 2567754Smsmith else 2667754Smsmith rm -f -- "$file" 2767754Smsmith fi 2867754Smsmith done 2967754Smsmith ) 3067754Smsmith done 3167754Smsmith fi 3267754Smsmith} 3367754Smsmith 3467754Smsmith# These files must be removed only the first time this script is run 3567754Smsmith# on boot. 3667754Smsmith# 3767754Smsmith[ "$1" != "reload" ] && rm -f /var/run/clean_var /var/spool/lock/clean_var 3867754Smsmith 3967754Smsmithif [ -d /var/run -a ! -f /var/run/clean_var ]; then 4067754Smsmith purgedir /var/run 4167754Smsmith # And an initial utmp file 4267754Smsmith (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) 4367754Smsmith >/var/run/clean_var 4467754Smsmithfi 4567754Smsmithif [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then 4667754Smsmith purgedir /var/spool/lock 4767754Smsmith >/var/spool/lock/clean_var 4867754Smsmithfi 4967754Smsmithrm -rf /var/spool/uucp/.Temp/* 5067754Smsmith 5167754Smsmith