Automatically purge old cache content on launch (closes #8.)

This commit is contained in:
Nolan Darilek 2017-03-14 14:26:26 -05:00
parent 98ddc5ee12
commit 3a42041dac
3 changed files with 31 additions and 1 deletions

View File

@ -1,6 +1,11 @@
# 2016-06-26a-sandstorm5 (2016-11-17)
# 2016-06-26a-sandstorm6 (2017-03-14)
* Now cleans up cached content older than 30 days, as well as removing stale locks and other useless data
# 2016-06-26a-sandstorm5 (2017-03-14)
* Create default @user ACL rule
* Fix issue where recursive symlinks broke previous grains
# V2016-06-26a-sandstorm4 (2016-10-14)

View File

@ -49,5 +49,29 @@ grep -Ev '^($|#)' /opt/app/dokuwiki/data.orig/deleted.files | xargs -n 1 rm -vrf
cp /opt/app/acl.auth.php /var/lib/dokuwiki/conf
function cleanup()
{
local data_path="$1" # full path to data directory of wiki
local retention_days="$2" # number of days after which old files are to be removed
# purge files older than ${retention_days} days from attic and media_attic (old revisions)
find "${data_path}"/{media_,}attic/ -type f -mtime +${retention_days} -delete
# remove stale lock files (files which are 1-2 days old)
find "${data_path}"/locks/ -name '*.lock' -type f -mtime +1 -delete
# remove empty directories
find "${data_path}"/{attic,cache,index,locks,media,media_attic,media_meta,meta,pages,tmp}/ \
-mindepth 1 -type d -empty -delete
# remove files older than ${retention_days} days from the cache
if [ -e "${data_path}"/cache/?/ ]
then
find "${data_path}"/cache/?/ -type f -mtime +${retention_days} -delete
fi
}
cleanup /var/lib/dokuwiki/data 30
# Start nginx.
/usr/sbin/nginx -c /opt/app/.sandstorm/service-config/nginx.conf -g "daemon off;"

View File

@ -5284,6 +5284,7 @@ sandstorm-http-bridge
sandstorm-http-bridge-config
sandstorm-manifest
usr/bin/file
usr/bin/find
usr/bin/id
usr/bin/rsync
usr/bin/touch