xref: /dragonfly/etc/rc.d/cleartmp (revision c9f721c2)
1#!/bin/sh
2#
3# $NetBSD: cleartmp,v 1.4 2002/03/22 04:33:58 thorpej Exp $
4# $FreeBSD: src/etc/rc.d/cleartmp,v 1.4 2002/10/12 10:31:31 schweikh Exp $
5# $DragonFly: src/etc/rc.d/cleartmp,v 1.3 2004/01/26 17:21:15 rob Exp $
6#
7
8# PROVIDE: cleartmp
9# REQUIRE: mountall
10# BEFORE: DAEMON
11# KEYWORD: DragonFly
12
13. /etc/rc.subr
14
15name="cleartmp"
16rcvar=`set_rcvar clear_tmp`
17start_cmd="cleartmp_start"
18stop_cmd=":"
19
20cleartmp_start()
21{
22	echo "Clearing /tmp."
23	#
24	#	Prune quickly with one rm, then use find to clean up
25	#	/tmp/[lq]* (this is not needed with mfs /tmp, but
26	#	doesn't hurt anything).
27	#
28	(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
29	    find -x . ! -name . ! -name lost+found ! -name quota.user \
30		! -name quota.group -exec rm -rf -- {} \; -type d -prune)
31
32		# Remove X lock files, since they will prevent you from
33		# restarting X
34		#
35		rm -f /tmp/.X*-lock
36		rm -fr /tmp/.X11-unix
37		mkdir -m 1777 /tmp/.X11-unix
38}
39
40load_rc_config $name
41run_rc_command "$1"
42