From f2a41436c916b7763057e848b66a0158c6846ff5 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Tue, 21 Mar 2023 02:41:58 -0700 Subject: use encrypted token in systemd service --- hetzner-ddns.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'hetzner-ddns.sh') diff --git a/hetzner-ddns.sh b/hetzner-ddns.sh index 7ad8e28..5e6de74 100755 --- a/hetzner-ddns.sh +++ b/hetzner-ddns.sh @@ -3,6 +3,8 @@ # Copyright 2022 David Vazgenovich Shakaryan # # HETZNER_TOKEN= hetzner-ddns.sh +# HETZNER_TOKEN_FILE=/path/to/token hetzner-ddns.sh +# systemctl enable --now "hetzner-ddns@$(systemd-escape ).timer" IP_RESOLVER='https://ifconfig.co' TARGET="${1}" @@ -20,6 +22,13 @@ hetzcurl() { "${@:2}" } +if [[ -z "${HETZNER_TOKEN}" ]] && [[ -n "${HETZNER_TOKEN_FILE}" ]]; then + [[ -f "${HETZNER_TOKEN_FILE}" ]] || die 'Specified token file' \ + "(${HETZNER_TOKEN_FILE}) does not exist" + HETZNER_TOKEN="$(<"${HETZNER_TOKEN_FILE}")" +fi +[[ -n "${HETZNER_TOKEN}" ]] || die 'Missing token' + ip="$(curl -sf4 "${IP_RESOLVER}")" || die 'IP lookup failed' zone_re="${TARGET}" -- cgit v1.2.3-70-g09d2