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