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# 6 7# PROVIDE: cleartmp 8# REQUIRE: SERVERS 9# BEFORE: DAEMON 10 11. /etc/rc.subr 12 13name="cleartmp" 14rcvar=`set_rcvar clear_tmp` 15start_cmd="cleartmp_start" 16stop_cmd=":" 17 18cleartmp_start() 19{ 20 echo "Clearing /tmp." 21 # 22 # Prune quickly with one rm, then use find to clean up 23 # the rest. Exceptions are lost+found/ (which is preserved 24 # but its contents are removed), quota.{group,user}, and 25 # snapshots/ (left untouched). This is not needed with mfs 26 # /tmp, but doesn't hurt anything. 27 # 28 (cd /tmp && rm -rf [a-km-prt-zA-Z]* && 29 find -x . ! -name . ! -name lost+found \ 30 ! -name snapshots ! -path "./snapshots/*" \ 31 ! -name quota.user ! -name quota.group \ 32 -exec rm -rf -- {} \; -type d -prune) 33 34 # Remove X lock files, since they will prevent you from restarting X. 35 rm -rf /tmp/.X*-lock /tmp/.X11-unix 36 mkdir -m 1777 /tmp/.X11-unix 37} 38 39load_rc_config $name 40run_rc_command "$1" 41