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.

73 lines
2.4 KiB

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