diff options
author | uvok cheetah | 2025-02-02 14:59:12 +0100 |
---|---|---|
committer | uvok cheetah | 2025-02-02 14:59:12 +0100 |
commit | 2b31cd58c12f8e6856435445cbfb61a130c37f7a (patch) | |
tree | 6e2d1d017bcddcf4efbbeea28c0217dc41f718f2 /other_scripts/desec.sh | |
parent | 6078935504c752afebefd8e570a6f29f6b05bcdb (diff) |
Various desec stuff
Diffstat (limited to 'other_scripts/desec.sh')
-rwxr-xr-x | other_scripts/desec.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/other_scripts/desec.sh b/other_scripts/desec.sh new file mode 100755 index 0000000..dccbdfe --- /dev/null +++ b/other_scripts/desec.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +domain="dyn.uvok.de" + +[[ -z ${1} ]] && { echo "Must provide arg" >&2 ; exit 1; } + +if type -p pass >/dev/null 2>&1; then + tokid=$(pass desec/dyndns/user) + toksec=$(pass desec/dyndns/pass) +else + read -r -p "Enter token ID: " tokid + read -r -s -p "Enter token secret: " toksec +fi + +url="https://desec.io/api/v1/auth/tokens/${tokid}/policies/domain/" +authhdr="Authorization: Token ${toksec}" +echo + +case "$1" in + create) + curl -X POST "$url" --header "$authhdr" --header "Content-Type: application/json" --data @- <<< '{"domain": null}' + echo + # fall-through + ;& + update) + curl -X POST "$url" --header "$authhdr" --header "Content-Type: application/json" --data @- <<< '{"domain": "'"$domain"'", "perm_dyndns": true}' + echo + ;; + check) + curl -X GET "$url" --header "$authhdr" + echo + ;; + *) + echo "Invalid parameter. Please enter one of 'create', 'update', 'check'." + ;; +esac + |