You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.6 KiB

  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. TELE3_API="https://www.tele3.cz/acme/"
  13. ######## Public functions #####################
  14. dns_tele3_add() {
  15. _info "Using TELE3 DNS"
  16. data="\"ope\":\"add\", \"domain\":\"$1\", \"value\":\"$2\""
  17. if ! _tele3_call; then
  18. _err "Publish zone failed"
  19. return 1
  20. fi
  21. _info "Zone published"
  22. }
  23. dns_tele3_rm() {
  24. _info "Using TELE3 DNS"
  25. data="\"ope\":\"rm\", \"domain\":\"$1\", \"value\":\"$2\""
  26. if ! _tele3_call; then
  27. _err "delete TXT record failed"
  28. return 1
  29. fi
  30. _info "TXT record successfully deleted"
  31. }
  32. #################### Private functions below ##################################
  33. _tele3_init() {
  34. TELE3_Key="${TELE3_Key:-$(_readaccountconf_mutable TELE3_Key)}"
  35. TELE3_Secret="${TELE3_Secret:-$(_readaccountconf_mutable TELE3_Secret)}"
  36. if [ -z "$TELE3_Key" ] || [ -z "$TELE3_Secret" ]; then
  37. TELE3_Key=""
  38. TELE3_Secret=""
  39. _err "You must export variables: TELE3_Key and TELE3_Secret"
  40. return 1
  41. fi
  42. #save the config variables to the account conf file.
  43. _saveaccountconf_mutable TELE3_Key "$TELE3_Key"
  44. _saveaccountconf_mutable TELE3_Secret "$TELE3_Secret"
  45. }
  46. _tele3_call() {
  47. _tele3_init
  48. data="{\"key\":\"$TELE3_Key\", \"secret\":\"$TELE3_Secret\", $data}"
  49. _debug data "$data"
  50. response="$(_post "$data" "$TELE3_API" "" "POST")"
  51. _debug response "$response"
  52. if [ "$response" != "success" ]; then
  53. _err "$response"
  54. return 1
  55. fi
  56. }