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