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