10696600cSBjoern A. Zeeb#!/bin/sh 20696600cSBjoern A. Zeeb# 30696600cSBjoern A. Zeeb# 40696600cSBjoern A. Zeeb 50696600cSBjoern A. Zeeb# PROVIDE: cleartmp 60696600cSBjoern A. Zeeb# REQUIRE: mountcritremote tmp 70696600cSBjoern A. Zeeb# BEFORE: DAEMON 80696600cSBjoern A. Zeeb 90696600cSBjoern A. Zeeb. /etc/rc.subr 100696600cSBjoern A. Zeeb 110696600cSBjoern A. Zeebname="cleartmp" 120696600cSBjoern A. Zeebdesc="Purge /tmp directory" 130696600cSBjoern A. Zeeb# Disguise rcvar for the start method to run irrespective of its setting. 140696600cSBjoern A. Zeebrcvar1="clear_tmp_enable" 150696600cSBjoern A. Zeebstart_cmd="${name}_start" 160696600cSBjoern A. Zeebstop_cmd=":" 170696600cSBjoern A. Zeeb 180696600cSBjoern A. Zeebcleartmp_start() 190696600cSBjoern A. Zeeb{ 200696600cSBjoern A. Zeeb # Make /tmp location variable for easier debugging. 210696600cSBjoern A. Zeeb local tmp="/tmp" 220696600cSBjoern A. Zeeb 230696600cSBjoern A. Zeeb # X related directories to create in /tmp. 240696600cSBjoern A. Zeeb local x11_socket_dirs="${tmp}/.X11-unix ${tmp}/.XIM-unix \ 250696600cSBjoern A. Zeeb ${tmp}/.ICE-unix ${tmp}/.font-unix" 260696600cSBjoern A. Zeeb 270696600cSBjoern A. Zeeb if checkyesno ${rcvar1}; then 28325ebf37SJose Luis Duran startmsg "Clearing ${tmp}." 290696600cSBjoern A. Zeeb 300696600cSBjoern A. Zeeb # This is not needed for mfs, but doesn't hurt anything. 310696600cSBjoern A. Zeeb # Things to note: 320696600cSBjoern A. Zeeb # + The dot in ${tmp}/. is important. 330696600cSBjoern A. Zeeb # + Put -prune before -exec so find never descends 340696600cSBjoern A. Zeeb # into a directory that was already passed to rm -rf. 350696600cSBjoern A. Zeeb # + "--" in rm arguments isn't strictly necessary, but 360696600cSBjoern A. Zeeb # it can prevent foot-shooting in future. 370696600cSBjoern A. Zeeb # + /tmp/lost+found is preserved, but its contents are removed. 380696600cSBjoern A. Zeeb # + lost+found and quota.* in subdirectories are removed. 390696600cSBjoern A. Zeeb # + .sujournal and .snap are preserved. 400696600cSBjoern A. Zeeb find -x ${tmp}/. ! -name . \ 410696600cSBjoern A. Zeeb ! \( -name .sujournal -type f -user root \) \ 420696600cSBjoern A. Zeeb ! \( -name .snap -type d -user root \) \ 430696600cSBjoern A. Zeeb ! \( -name lost+found -type d -user root \) \ 440696600cSBjoern A. Zeeb ! \( \( -name quota.user -or -name quota.group \) \ 450696600cSBjoern A. Zeeb -type f -user root \) \ 460696600cSBjoern A. Zeeb -prune -exec rm -rf -- {} + 470696600cSBjoern A. Zeeb elif checkyesno clear_tmp_X; then 480696600cSBjoern A. Zeeb # Remove X lock files, since they will prevent you from 490696600cSBjoern A. Zeeb # restarting X. Remove other X related directories. 50325ebf37SJose Luis Duran startmsg "Clearing ${tmp} (X related)." 510696600cSBjoern A. Zeeb rm -rf ${tmp}/.X[0-9]-lock ${x11_socket_dirs} 520696600cSBjoern A. Zeeb fi 530696600cSBjoern A. Zeeb if checkyesno clear_tmp_X; then 540696600cSBjoern A. Zeeb # Create X related directories with proper permissions. 550696600cSBjoern A. Zeeb mkdir -m 1777 ${x11_socket_dirs} 560696600cSBjoern A. Zeeb fi 570696600cSBjoern A. Zeeb} 580696600cSBjoern A. Zeeb 590696600cSBjoern A. Zeebload_rc_config $name 60*f99f0ee1SAlexander Leidinger 61*f99f0ee1SAlexander Leidinger# doesn't make sense to run in a svcj 62*f99f0ee1SAlexander Leidingercleartmp_svcj="NO" 63*f99f0ee1SAlexander Leidinger 640696600cSBjoern A. Zeebrun_rc_command "$1" 65