]>
Commit | Line | Data |
---|---|---|
cc5cfc75 M |
1 | #!/usr/bin/env sh |
2 | # | |
3 | # Author: Marvin Edeler | |
4 | # Report Bugs here: https://github.com/Marvo2011/acme.sh/issues/1 | |
2982e994 | 5 | # Last Edit: 17.02.2022 |
cc5cfc75 M |
6 | |
7 | dns_selfhost_add() { | |
8 | domain=$1 | |
9 | txt=$2 | |
10 | _info "Calling acme-dns on selfhost" | |
11 | _debug fulldomain "$domain" | |
12 | _debug txtvalue "$txt" | |
13 | ||
14 | SELFHOSTDNS_UPDATE_URL="https://selfhost.de/cgi-bin/api.pl" | |
15 | SELFHOSTDNS_USERNAME="${SELFHOSTDNS_USERNAME:-$(_readaccountconf_mutable SELFHOSTDNS_USERNAME)}" | |
16 | SELFHOSTDNS_PASSWORD="${SELFHOSTDNS_PASSWORD:-$(_readaccountconf_mutable SELFHOSTDNS_PASSWORD)}" | |
2982e994 | 17 | SELFHOSTDNS_MAP="${SELFHOSTDNS_MAP:-$(_readaccountconf_mutable SELFHOSTDNS_MAP)}" |
cc5cfc75 M |
18 | SELFHOSTDNS_RID="${SELFHOSTDNS_RID:-$(_readaccountconf_mutable SELFHOSTDNS_RID)}" |
19 | SELFHOSTDNS_RID2="${SELFHOSTDNS_RID2:-$(_readaccountconf_mutable SELFHOSTDNS_RID2)}" | |
20 | SELFHOSTDNS_LAST_SLOT="$(_readaccountconf_mutable SELFHOSTDNS_LAST_SLOT)" | |
21 | ||
96d45cc3 A |
22 | if [ -z "${SELFHOSTDNS_USERNAME:-}" ] || [ -z "${SELFHOSTDNS_PASSWORD:-}" ]; then |
23 | _err "SELFHOSTDNS_USERNAME and SELFHOSTDNS_PASSWORD must be set" | |
24 | return 1 | |
25 | fi | |
26 | ||
cc5cfc75 M |
27 | if test -z "$SELFHOSTDNS_LAST_SLOT"; then |
28 | SELFHOSTDNS_LAST_SLOT=1 | |
29 | fi | |
30 | ||
31 | _saveaccountconf_mutable SELFHOSTDNS_USERNAME "$SELFHOSTDNS_USERNAME" | |
32 | _saveaccountconf_mutable SELFHOSTDNS_PASSWORD "$SELFHOSTDNS_PASSWORD" | |
2982e994 | 33 | _saveaccountconf_mutable SELFHOSTDNS_MAP "$SELFHOSTDNS_MAP" |
cc5cfc75 M |
34 | _saveaccountconf_mutable SELFHOSTDNS_RID "$SELFHOSTDNS_RID" |
35 | _saveaccountconf_mutable SELFHOSTDNS_RID2 "$SELFHOSTDNS_RID2" | |
36 | ||
ac0dd90c M |
37 | rid=$(echo "$SELFHOSTDNS_MAP" | grep -Eoi "$domain:(\d+)" | tr -d "$domain:") |
38 | ||
2982e994 M |
39 | if test -z "$rid"; then |
40 | if [ $SELFHOSTDNS_LAST_SLOT = "2" ]; then | |
41 | rid=$SELFHOSTDNS_RID | |
42 | SELFHOSTDNS_LAST_SLOT=1 | |
43 | else | |
44 | rid=$SELFHOSTDNS_RID2 | |
45 | SELFHOSTDNS_LAST_SLOT=2 | |
46 | fi | |
cc5cfc75 M |
47 | fi |
48 | ||
96d45cc3 A |
49 | if test -z "$rid"; then |
50 | _err "SELFHOSTDNS_RID and SELFHOSTDNS_RID2, or SELFHOSTDNS_MAP must be set" | |
51 | return 1 | |
52 | fi | |
53 | ||
cc5cfc75 M |
54 | _saveaccountconf_mutable SELFHOSTDNS_LAST_SLOT "$SELFHOSTDNS_LAST_SLOT" |
55 | ||
56 | _info "Trying to add $txt on selfhost for rid: $rid" | |
57 | ||
58 | data="?username=$SELFHOSTDNS_USERNAME&password=$SELFHOSTDNS_PASSWORD&rid=$rid&content=$txt" | |
59 | response="$(_get "$SELFHOSTDNS_UPDATE_URL$data")" | |
60 | ||
61 | if ! echo "$response" | grep "200 OK" >/dev/null; then | |
62 | _err "Invalid response of acme-dns for selfhost" | |
63 | return 1 | |
64 | fi | |
65 | } | |
66 | ||
d6c68f1a | 67 | dns_selfhost_rm() { |
cc5cfc75 M |
68 | domain=$1 |
69 | txt=$2 | |
70 | _debug fulldomain "$domain" | |
71 | _debug txtvalue "$txt" | |
d6c68f1a | 72 | _info "Creating and removing of records is not supported by selfhost API, will not delete anything." |
cc5cfc75 | 73 | } |