30 lines
483 B
Bash
Raw Normal View History

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