mtree: No longer create /usr/libdata/msdosfs.
[dragonfly.git] / etc / rc.d / cleanvar
CommitLineData
9c600e7d
MD
1#!/bin/sh
2#
3# $FreeBSD: src/etc/rc.d/cleanvar,v 1.5 2003/07/14 13:02:36 mtm Exp $
696a5717 4# $DragonFly: src/etc/rc.d/cleanvar,v 1.5 2005/11/19 21:47:32 swildner Exp $
9c600e7d
MD
5#
6
7# PROVIDE: cleanvar
8# REQUIRE: mountcritlocal
9c600e7d 9
0c823069
MD
10. /etc/rc.subr
11
12dummy_rc_command "$1"
13
de5b97b6
MD
14# use recursion and shell test, because /usr/bin/find is not yet mounted
15#
9c600e7d
MD
16purgedir()
17{
18 local dir file
19
20 if [ $# -eq 0 ]; then
21 purgedir .
22 else
23 for dir
24 do
25 (
26 cd "$dir" && for file in .* *
27 do
28 [ ."$file" = .. -o ."$file" = ... ] && continue
29 if [ -d "$file" -a ! -L "$file" ]
30 then
31 purgedir "$file"
32 else
33 rm -f -- "$file"
34 fi
35 done
36 )
37 done
38 fi
39}
40
41# These files must be removed only the first time this script is run
42# on boot.
43#
44[ "$1" != "reload" ] && rm -f /var/run/clean_var /var/spool/lock/clean_var
45
de5b97b6
MD
46# purge /var/run /var/spool/lock and /var/spool/uucp/.Temp/*
47#
9c600e7d
MD
48if [ -d /var/run -a ! -f /var/run/clean_var ]; then
49 purgedir /var/run
50 # And an initial utmp file
51 (cd /var/run && cp /dev/null utmp && chmod 644 utmp;)
52 >/var/run/clean_var
53fi
54if [ -d /var/spool/lock -a ! -f /var/spool/lock/clean_var ]; then
55 purgedir /var/spool/lock
56 >/var/spool/lock/clean_var
57fi
58rm -rf /var/spool/uucp/.Temp/*
59