diff --git a/dns_update.sh b/dns_update.sh index cc040e9..c739aa6 100755 --- a/dns_update.sh +++ b/dns_update.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -eux + # First argument is cloudflared config file # TODO - make this optional, and check standard locations if absent. # Not doing it now because that would require me to remember how to @@ -18,10 +20,11 @@ fi # Second argument is "root domain". # If set, only try to update DNS for names that are subdomains of this domain. # If not set, try to update all names +TUNNEL_NAME=$(yq ".tunnel" $CONFIG_FILE_LOCATION); if [ $# -gt 1 ]; then ROOT_DOMAIN=$2; - yq ".ingress[].hostname | select(. != null) | select (. == \"*$ROOT_DOMAIN\")" $CONFIG_FILE_LOCATION | xargs -I {} echo "Would process {}"; + yq ".ingress[].hostname | select(. != null) | select (. == \"*$ROOT_DOMAIN\")" $CONFIG_FILE_LOCATION | xargs -I {} cloudflared tunnel route dns $TUNNEL_NAME {}; else - yq '.ingress[].hostname | select(. != null)' $CONFIG_FILE_LOCATION | xargs -I {} echo "Would process {}"; + yq '.ingress[].hostname | select(. != null)' $CONFIG_FILE_LOCATION | xargs -I {} cloudflared tunnel route dns $TUNNEL_NAME {}; fi