Created
April 17, 2012 14:37
-
-
Save abackstrom/2406388 to your computer and use it in GitHub Desktop.
mounted-tmp.conf from Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# modified for use as a callable script | |
# | |
# USAGE | |
# | |
# cleanup.sh [path] [days] | |
# | |
# path is required. days defaults to 14. | |
# | |
MOUNTPOINT=$1 | |
TMPTIME=${2:-14} | |
if [ x$MOUNTPOINT = x ] ; then | |
exit 1 | |
fi | |
cd "${MOUNTPOINT}" || exit 1 | |
case "${TMPTIME}" in | |
-*|infinite|infinity) | |
exit 0 | |
;; | |
esac | |
if [ "${TMPTIME}" = "0" -o -z "${TMPTIME}" ] | |
then | |
TEXPR="" | |
DEXPR="" | |
else | |
TEXPR="-mtime +${TMPTIME} -ctime +${TMPTIME} -atime +${TMPTIME}" | |
DEXPR="-mtime +${TMPTIME} -ctime +${TMPTIME}" | |
fi | |
EXCEPT='! -name . | |
! ( -path ./lost+found -uid 0 ) | |
! ( -path ./quota.user -uid 0 ) | |
! ( -path ./aquota.user -uid 0 ) | |
! ( -path ./quota.group -uid 0 ) | |
! ( -path ./aquota.group -uid 0 ) | |
! ( -path ./.journal -uid 0 ) | |
! ( -path ./.clean -uid 0 ) | |
! ( -path "./...security*" -uid 0 )' | |
# Remove all old files, then all empty directories | |
find . -depth -xdev $TEXPR $EXCEPT ! -type d -delete | |
find . -depth -xdev $DEXPR $EXCEPT -type d -empty -delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment