Last active
February 7, 2021 08:26
-
-
Save marutiprasad/764ac69815ee43714201068388269897 to your computer and use it in GitHub Desktop.
Akamai purge in the event of dispatcher / local cache purge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Before running this script, plese ensure the following tools are installed. | |
# 1. inotifywait (yum install inotify-tools) | |
# 2. akamai-purge (script https://github.com/akamai/cli-purge) | |
# 3. Keep the CCU API credentials in the .edgerc file in the user home dir. | |
ROOTDIR='/data/www/htdocs/publish/content/site1' | |
HOST_URL='https://www.myhost.com' | |
inotifywait -m -r -e delete $ROOTDIR | | |
while read dir ev file; do | |
if [ "$ev" = "DELETE" ]; then | |
FILEPATH=${dir}${file} | |
URI=${FILEPATH#$ROOTDIR} | |
echo "$(date) - This file is deleted:$URI" >> purge.log | |
WEB_URL=$HOST_URL$URI | |
# you can add "--staging" in case of staging request. | |
# change the akamai-purge path as per your installation. | |
./akamai-purge "invalidate" "$WEB_URL" >> purge.log | |
echo "$(date) - purge request has been raised for:$WEB_URL" >> purge.log | |
else | |
echo "Observed event: $ev on file: $file" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment