diff options
| author | Ben Busby <contact@benbusby.com> | 2022-07-27 16:58:29 -0600 |
|---|---|---|
| committer | Ben Busby <contact@benbusby.com> | 2022-07-27 16:58:29 -0600 |
| commit | bf59789c452b2d8cd2fc8b16229c6f81e6bade6d (patch) | |
| tree | 46d0e68f6c0bb6c1287096eb4a9f004d5d85adce /tools | |
| parent | a526d03fa2b818aa28bbef2908317786f579613e (diff) | |
| download | farside-bf59789c452b2d8cd2fc8b16229c6f81e6bade6d.tar.gz | |
Add tools dir, include script for removing cf instances
This new dir will probably stay fairly empty, but this script could come
in handy for anyone seeking to add a new instance (for services that
aren't supported by the auto update workflow).
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/un-cloudflare.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/un-cloudflare.sh b/tools/un-cloudflare.sh new file mode 100755 index 0000000..690dd73 --- /dev/null +++ b/tools/un-cloudflare.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Remove cloudflare instances from services-full.json + +rm -f out.json +file="services-full.json" + +while read -r line; do + if [[ "$line" == "\"https://"* ]]; then + domain=$(echo "$line" | sed -e "s/^\"https:\/\///" -e "s/\",//" -e "s/\"//") + ns=$(dig ns "$domain") + if [[ "$ns" == *"cloudflare"* ]]; then + echo "\"$domain\" using cloudflare, skipping..." + else + echo "$line" >> out.json + fi + else + echo "$line" >> out.json + fi +done <$file + +# Remove any trailing commas from new instance lists +sed -i '' -e ':begin' -e '$!N' -e 's/,\n]/\n]/g' -e 'tbegin' -e 'P' -e 'D' out.json + +cat out.json | jq --indent 2 . > services.json +rm out.json + |
