Added null protection

This commit is contained in:
Brian Zalewski 2024-05-18 05:13:13 +00:00
parent 7ff2368b7b
commit 1ae90725d6

View file

@ -56,8 +56,10 @@ if command -v cloudflared > /dev/null; then
# Must be deleted manually if no longer used # Must be deleted manually if no longer used
logg info 'Setting up DNS records for CloudFlare Argo tunnels' logg info 'Setting up DNS records for CloudFlare Argo tunnels'
while read DOMAIN; do while read DOMAIN; do
logg info "Setting up $DOMAIN for access through cloudflared" if [ "$DOMAIN" != 'null' ]; then
sudo cloudflared tunnel route dns -f "$TUNNEL_ID" "$DOMAIN" && logg success "Successfully routed $DOMAIN to this machine's cloudflared Argo tunnel" logg info "Setting up $DOMAIN for access through cloudflared"
sudo cloudflared tunnel route dns -f "$TUNNEL_ID" "$DOMAIN" && logg success "Successfully routed $DOMAIN to this machine's cloudflared Argo tunnel"
fi
done< <(yq '.ingress[].hostname' /usr/local/etc/config.yml) done< <(yq '.ingress[].hostname' /usr/local/etc/config.yml)
### Update config.yml ### Update config.yml
@ -79,6 +81,7 @@ if command -v cloudflared > /dev/null; then
logg info 'Unloading previous com.cloudflare.cloudflared configuration' logg info 'Unloading previous com.cloudflare.cloudflared configuration'
sudo launchctl unload /Library/LaunchDaemons/com.cloudflare.cloudflared.plist sudo launchctl unload /Library/LaunchDaemons/com.cloudflare.cloudflared.plist
fi fi
logg info 'Starting up com.cloudflare.cloudflared configuration'
sudo launchctl load -w /Library/LaunchDaemons/com.cloudflare.cloudflared.plist sudo launchctl load -w /Library/LaunchDaemons/com.cloudflare.cloudflared.plist
elif [ -f /etc/os-release ]; then elif [ -f /etc/os-release ]; then
### Linux ### Linux