diff options
author | Mike Frysinger <vapier@gentoo.org> | 2007-09-09 15:52:05 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2007-09-09 15:52:05 +0000 |
commit | 06ae2e5593fe6b3dac1b2d18e244a08b54da14e1 (patch) | |
tree | be71bc26567052f12c1f575dbcc0684f58dc883d | |
parent | ba4b5d5b7fab28557e0dda9b5a2191d110118857 (diff) |
Allow people to specify a list of temp dirs to clean in bootmisc #191807.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | conf.d/bootmisc | 4 | ||||
-rwxr-xr-x | init.d/bootmisc | 91 |
3 files changed, 59 insertions, 40 deletions
@@ -1,6 +1,10 @@ # ChangeLog for Gentoo System Intialization ("rc") scripts # Copyright 1999-2007 Gentoo Foundation; Distributed under the GPLv2 + 09 Sep 2007; Mike Frysinger <vapier@gentoo.org>: + + Allow people to specify a list of temp dirs to clean in bootmisc #191807. + 04 Sep 2007; Roy Marples <uberlord@gentoo.org>: start-stop-daemon now works with userids correctly when a pidfile diff --git a/conf.d/bootmisc b/conf.d/bootmisc index 147f9d03..5bf7ecf5 100644 --- a/conf.d/bootmisc +++ b/conf.d/bootmisc @@ -4,5 +4,9 @@ # system startup is complete DELAYLOGIN="no" +# List of /tmp directories we should clean up +WIPE_TMP_DIRS="/tmp" + +# Should we wipe the tmp paths completely or just selectively remove known # locks / files / etc... ? WIPE_TMP="yes" diff --git a/init.d/bootmisc b/init.d/bootmisc index 73456c8d..2d354196 100755 --- a/init.d/bootmisc +++ b/init.d/bootmisc @@ -9,6 +9,52 @@ depend() { after clock sysctl } +cleanup_tmp_dir() { + local dir=$1 + + mkdir -p ${dir} + cd ${dir} + if [ "${WIPE_TMP}" = "yes" ] ; then + ebegin "Wiping ${dir} directory" + local startopts="-x . -depth" + [ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth" + + # Faster than find + rm -rf [b-ikm-pr-zA-Z]* + + find ${startopts} ! -name . \ + ! -path ./lost+found \ + ! -path "./lost+found/*" \ + ! -path ./quota.user \ + ! -path "./quota.user/*" \ + ! -path ./aquota.user \ + ! -path "./aquota.user/*" \ + ! -path ./quota.group \ + ! -path "./quota.group/*" \ + ! -path ./aquota.group \ + ! -path "./aquota.group/*" \ + ! -path ./journal \ + ! -path "./journal/*" \ + -delete + eend 0 + else + ebegin "Cleaning ${dir} directory" + rm -rf ${dir}/.X*-lock ${dir}/esrv* ${dir}/kio* ${dir}/jpsock.* \ + ${dir}/.fam* ${dir}/.esd* ${dir}/orbit-* ${dir}/ssh-* \ + ${dir}/ksocket-* ${dir}/.*-unix + eend 0 + fi + chmod +t ${dir} + + # Make sure our X11 stuff have the correct permissions + # Omit the chown as bootmisc is run before network is up + # and users may be using lame LDAP auth #139411 + rm -rf ${dir}/.ICE-unix ${dir}/.X11-unix + mkdir -p ${dir}/.ICE-unix ${dir}/.X11-unix + chmod 1777 ${dir}/.ICE-unix ${dir}/.X11-unix + [ -x /sbin/restorecon ] && restorecon ${dir}/.ICE-unix ${dir}/.X11-unix +} + start() { # Put a nologin file in /etc to prevent people from logging # in before system startup is complete. @@ -85,46 +131,11 @@ start() { printf "" >/var/lock/.keep eend 0 - # Clean up /tmp directory - cd /tmp - if [ "${WIPE_TMP}" = "yes" ] ; then - ebegin "Wiping /tmp directory" - local startopts="-x . -depth" - [ "${RC_UNAME}" = "Linux" ] && startopts=". -xdev -depth" - - # Faster than find - rm -rf [b-ikm-pr-zA-Z]* - - find ${startopts} ! -name . \ - ! -path ./lost+found \ - ! -path "./lost+found/*" \ - ! -path ./quota.user \ - ! -path "./quota.user/*" \ - ! -path ./aquota.user \ - ! -path "./aquota.user/*" \ - ! -path ./quota.group \ - ! -path "./quota.group/*" \ - ! -path ./aquota.group \ - ! -path "./aquota.group/*" \ - ! -path ./journal \ - ! -path "./journal/*" \ - -delete - eend 0 - else - ebegin "Cleaning /tmp directory" - rm -rf /tmp/.X*-lock /tmp/esrv* /tmp/kio* /tmp/jpsock.* \ - /tmp/.fam* /tmp/.esd* /tmp/orbit-* /tmp/ssh-* \ - /tmp/ksocket-* /tmp/.*-unix - eend 0 - fi - - # Make sure our X11 stuff have the correct permissions - # Omit the chown as bootmisc is run before network is up - # and users may be using lame LDAP auth #139411 - rm -rf /tmp/.ICE-unix /tmp/.X11-unix - mkdir -p /tmp/.ICE-unix /tmp/.X11-unix - chmod 1777 /tmp/.ICE-unix /tmp/.X11-unix - [ -x /sbin/restorecon ] && restorecon /tmp/.ICE-unix /tmp/.X11-unix + # Clean up /tmp directories + local tmp + for tmp in ${WIPE_TMP_DIRS-/tmp} ; do + cleanup_tmp_dir ${tmp} + done # Create an 'after-boot' dmesg log if [ "${RC_SYS}" != "VPS" ] ; then |