X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=installation%2Fapache%2Fapache-cache-purge.sh.example;fp=installation%2Fapache%2Fapache-cache-purge.sh.example;h=65df9cc1132c2c1c59dda5f4d572f1cdf135eded;hb=c0e6f30e4d17bd69b7ddd26aa0c0f1433184128a;hp=0000000000000000000000000000000000000000;hpb=3d9dabd9147d2ba001d64de0ea5527bc5727dda6;p=akkoma diff --git a/installation/apache/apache-cache-purge.sh.example b/installation/apache/apache-cache-purge.sh.example new file mode 100755 index 000000000..65df9cc11 --- /dev/null +++ b/installation/apache/apache-cache-purge.sh.example @@ -0,0 +1,36 @@ +#!/bin/sh + +# A simple shell script to delete a media from Apache's mod_disk_cache. +# You will likely need to setup a sudo rule like the following: +# +# Cmnd_Alias HTCACHECLEAN = /usr/local/sbin/htcacheclean +# akkoma ALL=HTCACHECLEAN, NOPASSWD: HTCACHECLEAN +# +# Please also ensure you have enabled: +# +# config :pleroma, Pleroma.Web.MediaProxy.Invalidation.Script, url_format: :htcacheclean +# +# which will correctly format the URLs passed to this script for the htcacheclean utility. +# + +SCRIPTNAME=${0##*/} + +# mod_disk_cache directory +CACHE_DIRECTORY="/tmp/akkoma-media-cache" + +## Removes an item via the htcacheclean utility +## $1 - the filename, can be a pattern . +## $2 - the cache directory. +purge_item() { + sudo htcacheclean -v -p "${2}" "${1}" +} # purge_item + +purge() { + for url in $@ + do + echo "$SCRIPTNAME delete \`$url\` from cache ($CACHE_DIRECTORY)" + purge_item "$url" $CACHE_DIRECTORY + done +} + +purge $@