Sync usage with man page.
[netbsd-mini2440.git] / etc / rc.d / cleartmp
blobd61d2784908d3cc7f8a766991f5e6be659994449
1 #!/bin/sh
3 # $NetBSD: cleartmp,v 1.9 2007/02/15 08:47:38 xtraeme Exp $
6 # PROVIDE: cleartmp
7 # REQUIRE: mountall
8 # BEFORE: DAEMON
10 $_rc_subr_loaded . /etc/rc.subr
12 name="cleartmp"
13 rcvar="clear_tmp"
14 start_cmd="cleartmp_start"
15 stop_cmd=":"
17 cleartmp_start()
19 echo "Clearing temporary files."
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).
25 if checkyesno per_user_tmp && [ -d ${per_user_tmp_dir} ]; then
26 tmp_dir=${per_user_tmp_dir}
27 else
28 tmp_dir="/tmp"
29 # Check if /tmp was created by the perusertmp rc.d
30 # script and recreate it if necessary.
31 if [ "$(/usr/bin/readlink /tmp)" = ${per_user_tmp_dir}/@ruid ]; then
32 /bin/rm -rf ${tmp_dir}
33 /bin/mkdir ${tmp_dir}
34 /usr/sbin/chown root:wheel ${tmp_dir}
35 /bin/chmod 1777 ${tmp_dir}
39 (cd ${tmp_dir} && rm -rf [a-km-pr-zA-Z]* &&
40 find -x . ! -name . ! -name lost+found ! -name quota.user \
41 ! -name quota.group -exec rm -rf -- {} \; -type d -prune)
44 load_rc_config $name
45 run_rc_command "$1"