summaryrefslogtreecommitdiff
path: root/installation/apache-cache-purge.sh.example
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2021-01-31 20:38:58 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2021-01-31 20:38:58 +0300
commit1b49b8efe57256b3f64b4b7e8a1de805ab030814 (patch)
tree2250cc1eb3d17b79c292b4ff4130172a6dea6c31 /installation/apache-cache-purge.sh.example
parent6fd4163ab60be07b1a20ac8911e105ddca8e2095 (diff)
parent7ac0a819811496fe512544e91b6f0ff3d15b8856 (diff)
downloadpleroma-1b49b8efe57256b3f64b4b7e8a1de805ab030814.tar.gz
pleroma-1b49b8efe57256b3f64b4b7e8a1de805ab030814.zip
Merge remote-tracking branch 'remotes/origin/develop' into feature/object-hashtags-rework
# Conflicts: # CHANGELOG.md
Diffstat (limited to 'installation/apache-cache-purge.sh.example')
-rwxr-xr-xinstallation/apache-cache-purge.sh.example36
1 files changed, 36 insertions, 0 deletions
diff --git a/installation/apache-cache-purge.sh.example b/installation/apache-cache-purge.sh.example
new file mode 100755
index 000000000..7b4262875
--- /dev/null
+++ b/installation/apache-cache-purge.sh.example
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# A simple shell script to delete a media from Apache's mod_disk_cache.
+# You will likely need to setup a sudo rule like the following:
+#
+# Cmnd_Alias HTCACHECLEAN = /usr/local/sbin/htcacheclean
+# pleroma ALL=HTCACHECLEAN, NOPASSWD: HTCACHECLEAN
+#
+# 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.
+#
+
+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() {
+ sudo htcacheclean -v -p "${2}" "${1}"
+} # purge_item
+
+purge() {
+ for url in $@
+ do
+ echo "$SCRIPTNAME delete \`$url\` from cache ($CACHE_DIRECTORY)"
+ purge_item "$url" $CACHE_DIRECTORY
+ done
+}
+
+purge $@