2021-01-21 21:20:13 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# A simple shell script to delete a media from Apache's mod_disk_cache.
|
2021-01-26 01:15:04 +01:00
|
|
|
# You will likely need to setup a sudo rule like the following:
|
|
|
|
#
|
|
|
|
# Cmnd_Alias HTCACHECLEAN = /usr/local/sbin/htcacheclean
|
2022-07-06 20:50:01 +02:00
|
|
|
# akkoma ALL=HTCACHECLEAN, NOPASSWD: HTCACHECLEAN
|
2021-01-26 01:20:07 +01:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2021-01-21 21:20:13 +01:00
|
|
|
|
|
|
|
SCRIPTNAME=${0##*/}
|
|
|
|
|
|
|
|
# mod_disk_cache directory
|
2022-07-06 20:50:01 +02:00
|
|
|
CACHE_DIRECTORY="/tmp/akkoma-media-cache"
|
2021-01-21 21:20:13 +01:00
|
|
|
|
|
|
|
## Removes an item via the htcacheclean utility
|
|
|
|
## $1 - the filename, can be a pattern .
|
|
|
|
## $2 - the cache directory.
|
|
|
|
purge_item() {
|
2021-01-26 01:15:04 +01:00
|
|
|
sudo htcacheclean -v -p "${2}" "${1}"
|
2021-01-21 21:20:13 +01:00
|
|
|
} # purge_item
|
|
|
|
|
|
|
|
purge() {
|
2021-01-26 01:15:04 +01:00
|
|
|
for url in $@
|
2021-01-21 21:20:13 +01:00
|
|
|
do
|
|
|
|
echo "$SCRIPTNAME delete \`$url\` from cache ($CACHE_DIRECTORY)"
|
|
|
|
purge_item "$url" $CACHE_DIRECTORY
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2021-01-26 01:15:04 +01:00
|
|
|
purge $@
|