cleartmp revision 1.8
1#!/bin/sh 2# 3# $NetBSD: cleartmp,v 1.8 2007/02/04 08:19:26 elad Exp $ 4# 5 6# PROVIDE: cleartmp 7# REQUIRE: mountall 8# BEFORE: DAEMON 9 10$_rc_subr_loaded . /etc/rc.subr 11 12name="cleartmp" 13rcvar="clear_tmp" 14start_cmd="cleartmp_start" 15stop_cmd=":" 16 17cleartmp_start() 18{ 19 echo "Clearing temporary files." 20 # 21 # Prune quickly with one rm, then use find to clean up 22 # /tmp/[lq]* (this is not needed with mfs /tmp, but 23 # doesn't hurt anything). 24 # 25 if [ \( X"${per_user_tmp}" = X"YES" \) -a \( -d ${per_user_tmp_dir} \) ]; then 26 tmp_dir=${per_user_tmp_dir} 27 else 28 tmp_dir="/tmp" 29 fi 30 31 (cd ${tmp_dir} && rm -rf [a-km-pr-zA-Z]* && 32 find -x . ! -name . ! -name lost+found ! -name quota.user \ 33 ! -name quota.group -exec rm -rf -- {} \; -type d -prune) 34} 35 36load_rc_config $name 37run_rc_command "$1" 38