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.

61 lines
2.0 KiB

  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 test -z "$SELFHOSTDNS_LAST_SLOT"; then
  20. SELFHOSTDNS_LAST_SLOT=1
  21. fi
  22. _saveaccountconf_mutable SELFHOSTDNS_USERNAME "$SELFHOSTDNS_USERNAME"
  23. _saveaccountconf_mutable SELFHOSTDNS_PASSWORD "$SELFHOSTDNS_PASSWORD"
  24. _saveaccountconf_mutable SELFHOSTDNS_MAP "$SELFHOSTDNS_MAP"
  25. _saveaccountconf_mutable SELFHOSTDNS_RID "$SELFHOSTDNS_RID"
  26. _saveaccountconf_mutable SELFHOSTDNS_RID2 "$SELFHOSTDNS_RID2"
  27. rid=$(echo "$SELFHOSTDNS_MAP" | grep -Eoi "$domain:(\d+)" | tr -d "$domain:")
  28. if test -z "$rid"; then
  29. if [ $SELFHOSTDNS_LAST_SLOT = "2" ]; then
  30. rid=$SELFHOSTDNS_RID
  31. SELFHOSTDNS_LAST_SLOT=1
  32. else
  33. rid=$SELFHOSTDNS_RID2
  34. SELFHOSTDNS_LAST_SLOT=2
  35. fi
  36. fi
  37. _saveaccountconf_mutable SELFHOSTDNS_LAST_SLOT "$SELFHOSTDNS_LAST_SLOT"
  38. _info "Trying to add $txt on selfhost for rid: $rid"
  39. data="?username=$SELFHOSTDNS_USERNAME&password=$SELFHOSTDNS_PASSWORD&rid=$rid&content=$txt"
  40. response="$(_get "$SELFHOSTDNS_UPDATE_URL$data")"
  41. if ! echo "$response" | grep "200 OK" >/dev/null; then
  42. _err "Invalid response of acme-dns for selfhost"
  43. return 1
  44. fi
  45. }
  46. dns_acmedns_rm() {
  47. domain=$1
  48. txt=$2
  49. _debug fulldomain "$domain"
  50. _debug txtvalue "$txt"
  51. }