62997038d48df5312317dfea8eeb87d1afacd1d0
[akkoma] / installation / apache-cache-purge.sh.example
1 #!/bin/sh
2
3 # A simple shell script to delete a media from Apache's mod_disk_cache.
4 # You will likely need to setup a sudo rule like the following:
5 #
6 # Cmnd_Alias HTCACHECLEAN = /usr/local/sbin/htcacheclean
7 # pleroma ALL=HTCACHECLEAN, NOPASSWD: HTCACHECLEAN
8
9 SCRIPTNAME=${0##*/}
10
11 # mod_disk_cache directory
12 CACHE_DIRECTORY="/tmp/pleroma-media-cache"
13
14 ## Removes an item via the htcacheclean utility
15 ## $1 - the filename, can be a pattern .
16 ## $2 - the cache directory.
17 purge_item() {
18 sudo htcacheclean -v -p "${2}" "${1}"
19 } # purge_item
20
21 purge() {
22 for url in $@
23 do
24 echo "$SCRIPTNAME delete \`$url\` from cache ($CACHE_DIRECTORY)"
25 purge_item "$url" $CACHE_DIRECTORY
26 done
27 }
28
29 purge $@