]>
Commit | Line | Data |
---|---|---|
4e05062d RB |
1 | #!/usr/bin/env sh |
2 | # | |
3 | # tele3.cz DNS API | |
4 | # | |
5 | # Author: Roman Blizik | |
6 | # Report Bugs here: https://github.com/par-pa/acme.sh | |
7 | # | |
8 | # -- | |
9 | # export TELE3_Key="MS2I4uPPaI..." | |
10 | # export TELE3_Secret="kjhOIHGJKHg" | |
11 | # -- | |
12 | ||
13 | TELE3_API="https://www.tele3.cz/acme/" | |
14 | ||
15 | ######## Public functions ##################### | |
16 | ||
17 | dns_tele3_add() { | |
18 | _info "Using TELE3 DNS" | |
19 | data="\"ope\":\"add\", \"domain\":\"$1\", \"value\":\"$2\"" | |
20 | if ! _tele3_call; then | |
21 | _err "Publish zone failed" | |
22 | return 1 | |
23 | fi | |
24 | ||
25 | _info "Zone published" | |
26 | } | |
27 | ||
28 | dns_tele3_rm() { | |
29 | _info "Using TELE3 DNS" | |
30 | data="\"ope\":\"rm\", \"domain\":\"$1\", \"value\":\"$2\"" | |
31 | if ! _tele3_call; then | |
32 | _err "delete TXT record failed" | |
33 | return 1 | |
34 | fi | |
35 | ||
36 | _info "TXT record successfully deleted" | |
37 | } | |
38 | ||
39 | #################### Private functions below ################################## | |
40 | ||
41 | _tele3_init() { | |
42 | TELE3_Key="${TELE3_Key:-$(_readaccountconf_mutable TELE3_Key)}" | |
43 | TELE3_Secret="${TELE3_Secret:-$(_readaccountconf_mutable TELE3_Secret)}" | |
44 | if [ -z "$TELE3_Key" ] || [ -z "$TELE3_Secret" ]; then | |
45 | TELE3_Key="" | |
46 | TELE3_Secret="" | |
47 | _err "You must export variables: TELE3_Key and TELE3_Secret" | |
48 | return 1 | |
49 | fi | |
50 | ||
51 | #save the config variables to the account conf file. | |
52 | _saveaccountconf_mutable TELE3_Key "$TELE3_Key" | |
53 | _saveaccountconf_mutable TELE3_Secret "$TELE3_Secret" | |
54 | } | |
55 | ||
56 | _tele3_call() { | |
57 | _tele3_init | |
58 | data="{\"key\":\"$TELE3_Key\", \"secret\":\"$TELE3_Secret\", $data}" | |
59 | ||
60 | _debug data "$data" | |
61 | ||
62 | response="$(_post "$data" "$TELE3_API" "" "POST")" | |
63 | _debug response "$response" | |
64 | ||
65 | if [ "$response" != "success" ]; then | |
66 | _err "$response" | |
67 | return 1 | |
68 | fi | |
69 | } |