First
[anni] / docs / installation_1 / 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 # Please also ensure you have enabled:
10 #
11 # config :pleroma, Pleroma.Web.MediaProxy.Invalidation.Script, url_format: :htcacheclean
12 #
13 # which will correctly format the URLs passed to this script for the htcacheclean utility.
14 #
15
16 SCRIPTNAME=${0##*/}
17
18 # mod_disk_cache directory
19 CACHE_DIRECTORY="/tmp/pleroma-media-cache"
20
21 ## Removes an item via the htcacheclean utility
22 ## $1 - the filename, can be a pattern .
23 ## $2 - the cache directory.
24 purge_item() {
25     sudo htcacheclean -v -p "${2}" "${1}"
26 } # purge_item
27
28 purge() {
29   for url in $@
30   do
31     echo "$SCRIPTNAME delete \`$url\` from cache ($CACHE_DIRECTORY)"
32     purge_item "$url" $CACHE_DIRECTORY
33   done
34 }
35
36 purge $@