7 # REQUIRE: mountcritremote tmp
13 desc="Purge /tmp directory"
14 # Disguise rcvar for the start method to run irrespective of its setting.
15 rcvar1="clear_tmp_enable"
16 start_cmd="${name}_start"
21 # Make /tmp location variable for easier debugging.
24 # X related directories to create in /tmp.
25 local x11_socket_dirs="${tmp}/.X11-unix ${tmp}/.XIM-unix \
26 ${tmp}/.ICE-unix ${tmp}/.font-unix"
28 if checkyesno ${rcvar1}; then
29 check_startmsgs && echo "Clearing ${tmp}."
31 # This is not needed for mfs, but doesn't hurt anything.
33 # + The dot in ${tmp}/. is important.
34 # + Put -prune before -exec so find never descends
35 # into a directory that was already passed to rm -rf.
36 # + "--" in rm arguments isn't strictly necessary, but
37 # it can prevent foot-shooting in future.
38 # + /tmp/lost+found is preserved, but its contents are removed.
39 # + lost+found and quota.* in subdirectories are removed.
40 # + .sujournal and .snap are preserved.
41 find -x ${tmp}/. ! -name . \
42 ! \( -name .sujournal -type f -user root \) \
43 ! \( -name .snap -type d -user root \) \
44 ! \( -name lost+found -type d -user root \) \
45 ! \( \( -name quota.user -or -name quota.group \) \
46 -type f -user root \) \
47 -prune -exec rm -rf -- {} +
48 elif checkyesno clear_tmp_X; then
49 # Remove X lock files, since they will prevent you from
50 # restarting X. Remove other X related directories.
51 check_startmsgs && echo "Clearing ${tmp} (X related)."
52 rm -rf ${tmp}/.X[0-9]-lock ${x11_socket_dirs}
54 if checkyesno clear_tmp_X; then
55 # Create X related directories with proper permissions.
56 mkdir -m 1777 ${x11_socket_dirs}