blob: dccbdfe59bca0058935f0413f39dc1cec9c3dd32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
|