* Added tabs instead of spaces for readability and consistency with NetBSD
[dragonfly.git] / etc / rc.d / cleartmp
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.2 2003/11/19 10:32:45 eirikn Exp $
6 #
7
8 # PROVIDE: cleartmp
9 # REQUIRE: mountall
10 # BEFORE: DAEMON
11 # KEYWORD: DragonFly FreeBSD NetBSD
12
13 . /etc/rc.subr
14
15 name="cleartmp"
16 rcvar=`set_rcvar clear_tmp`
17 start_cmd="cleartmp_start"
18 stop_cmd=":"
19
20 cleartmp_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         case ${OSTYPE} in
33         DragonFly)
34                 # Remove X lock files, since they will prevent you from
35                 # restarting X
36                 #
37                 rm -f /tmp/.X*-lock
38                 rm -fr /tmp/.X11-unix
39                 mkdir -m 1777 /tmp/.X11-unix
40                 ;;
41
42         FreeBSD)
43                 # Remove X lock files, since they will prevent you from
44                 # restarting X
45                 #
46                 rm -f /tmp/.X*-lock
47                 rm -fr /tmp/.X11-unix
48                 mkdir -m 1777 /tmp/.X11-unix
49                 ;;
50         NetBSD)
51                 ;;
52         esac
53 }
54
55 load_rc_config $name
56 run_rc_command "$1"