#!/bin/bash set +x URLs=$(export | grep URL) #if [[ -z "${URL}" ]] #then # echo "Please defind a URL" # exit 1 #fi if [[ -z "${BUNNYCDN_API}" ]] then echo "Please define API_TOKEN" exit 1 fi for f in ${URLs | cut -d'=' -f2-); do curl -s -X POST \ -H 'AccessKey: '"${BUNNYCDN_API}"'' \ -H 'Content-Length: 0' \ 'https://api.bunny.net/purge?url='"${f}" if [ $? -eq 0 ]; then echo "Cleared cache for ${f}" else echo "Cleared not completed" exit 1 fi done