cleartmp revision 153537
1#!/bin/sh
2#
3# $FreeBSD: head/etc/rc.d/cleartmp 153537 2005-12-19 10:57:00Z dougb $
4#
5
6# PROVIDE: cleartmp
7# REQUIRE: mountcritremote tmp
8# BEFORE: DAEMON
9
10. /etc/rc.subr
11
12name="cleartmp"
13rcvar=`set_rcvar clear_tmp`
14start_cmd="${name}_start"
15
16cleartmp_start()
17{
18
19	local x11_socket_dirs="/tmp/.X11-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/.XIM-unix"
20	echo "Clearing /tmp."
21	#
22	#	Prune quickly with one rm, then use find to clean up
23	#	/tmp/[lq]* (this is not needed with mfs /tmp, but
24	#	doesn't hurt anything).
25	#
26	(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
27	    find -x . ! -name . ! -name lost+found ! -name quota.user \
28		! -name quota.group -exec rm -rf -- {} \; -type d -prune)
29
30	# Remove X lock files, since they will prevent you from restarting X.
31	rm -f /tmp/.X[0-9]-lock
32
33	# Create socket directories with correct permissions to avoid
34	# security problem.
35	#
36	rm -fr ${x11_socket_dirs}
37	mkdir -m 1777 ${x11_socket_dirs}
38}
39
40load_rc_config $name
41run_rc_command "$1"
42