22 lines
630 B
Bash
22 lines
630 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
AUTH_FILE="creds/joker_com_dyndns_creds.txt"
|
|
if [[ ! -f "$AUTH_FILE" ]]; then
|
|
echo "Joker DYNDNS credentials missing at $AUTH_FILE" >&2
|
|
exit 1
|
|
fi
|
|
|
|
JOKER_AUTH="$(cat "$AUTH_FILE")"
|
|
TARGET_IP="${TARGET_IP:-157.180.66.64}"
|
|
LOGS_HOST="${LOGS_HOST:-logs.lomavuokraus.fi}"
|
|
|
|
echo "Updating $LOGS_HOST -> $TARGET_IP"
|
|
resp="$(curl -sS -u "$JOKER_AUTH" "https://svc.joker.com/nic/update?hostname=${LOGS_HOST}&myip=${TARGET_IP}")"
|
|
echo "$resp"
|
|
if [[ "$resp" != good* && "$resp" != nochg* ]]; then
|
|
echo "DNS update failed for $LOGS_HOST (response: $resp)" >&2
|
|
exit 1
|
|
fi
|