mirror of
https://github.com/benbusby/farside.git
synced 2025-04-25 13:10:02 +00:00
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).
This commit is contained in:
parent
a526d03fa2
commit
bf59789c45
1 changed files with 26 additions and 0 deletions
26
tools/un-cloudflare.sh
Executable file
26
tools/un-cloudflare.sh
Executable file
|
@ -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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue