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.

88 lines
3.1 KiB

  1. #!/usr/bin/env sh
  2. # shellcheck disable=SC2034
  3. dns_bookmyname_info='BookMyName.com
  4. Site: BookMyName.com
  5. Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_bookmyname
  6. Options:
  7. BOOKMYNAME_USERNAME Username
  8. BOOKMYNAME_PASSWORD Password
  9. Issues: github.com/acmesh-official/acme.sh/issues/3209
  10. Author: Neilpang
  11. '
  12. ######## Public functions #####################
  13. # BookMyName urls:
  14. # https://BOOKMYNAME_USERNAME:BOOKMYNAME_PASSWORD@www.bookmyname.com/dyndns/?hostname=_acme-challenge.domain.tld&type=txt&ttl=300&do=add&value="XXXXXXXX"'
  15. # https://BOOKMYNAME_USERNAME:BOOKMYNAME_PASSWORD@www.bookmyname.com/dyndns/?hostname=_acme-challenge.domain.tld&type=txt&ttl=300&do=remove&value="XXXXXXXX"'
  16. # Output:
  17. #good: update done, cid 123456, domain id 456789, type txt, ip XXXXXXXX
  18. #good: remove done 1, cid 123456, domain id 456789, ttl 300, type txt, ip XXXXXXXX
  19. # Be careful, BMN DNS servers can be slow to pick up changes; using dnssleep is thus advised.
  20. # Usage:
  21. # export BOOKMYNAME_USERNAME="ABCDE-FREE"
  22. # export BOOKMYNAME_PASSWORD="MyPassword"
  23. # /usr/local/ssl/acme.sh/acme.sh --dns dns_bookmyname --dnssleep 600 --issue -d domain.tld
  24. #Usage: dns_bookmyname_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
  25. dns_bookmyname_add() {
  26. fulldomain=$1
  27. txtvalue=$2
  28. _info "Using bookmyname"
  29. _debug fulldomain "$fulldomain"
  30. _debug txtvalue "$txtvalue"
  31. BOOKMYNAME_USERNAME="${BOOKMYNAME_USERNAME:-$(_readaccountconf_mutable BOOKMYNAME_USERNAME)}"
  32. BOOKMYNAME_PASSWORD="${BOOKMYNAME_PASSWORD:-$(_readaccountconf_mutable BOOKMYNAME_PASSWORD)}"
  33. if [ -z "$BOOKMYNAME_USERNAME" ] || [ -z "$BOOKMYNAME_PASSWORD" ]; then
  34. BOOKMYNAME_USERNAME=""
  35. BOOKMYNAME_PASSWORD=""
  36. _err "You didn't specify BookMyName username and password yet."
  37. _err "Please specify them and try again."
  38. return 1
  39. fi
  40. #save the credentials to the account conf file.
  41. _saveaccountconf_mutable BOOKMYNAME_USERNAME "$BOOKMYNAME_USERNAME"
  42. _saveaccountconf_mutable BOOKMYNAME_PASSWORD "$BOOKMYNAME_PASSWORD"
  43. uri="https://${BOOKMYNAME_USERNAME}:${BOOKMYNAME_PASSWORD}@www.bookmyname.com/dyndns/"
  44. data="?hostname=${fulldomain}&type=TXT&ttl=300&do=add&value=${txtvalue}"
  45. result="$(_get "${uri}${data}")"
  46. _debug "Result: $result"
  47. if ! _startswith "$result" 'good: update done, cid '; then
  48. _err "Can't add $fulldomain"
  49. return 1
  50. fi
  51. }
  52. #Usage: fulldomain txtvalue
  53. #Remove the txt record after validation.
  54. dns_bookmyname_rm() {
  55. fulldomain=$1
  56. txtvalue=$2
  57. _info "Using bookmyname"
  58. _debug fulldomain "$fulldomain"
  59. _debug txtvalue "$txtvalue"
  60. BOOKMYNAME_USERNAME="${BOOKMYNAME_USERNAME:-$(_readaccountconf_mutable BOOKMYNAME_USERNAME)}"
  61. BOOKMYNAME_PASSWORD="${BOOKMYNAME_PASSWORD:-$(_readaccountconf_mutable BOOKMYNAME_PASSWORD)}"
  62. uri="https://${BOOKMYNAME_USERNAME}:${BOOKMYNAME_PASSWORD}@www.bookmyname.com/dyndns/"
  63. data="?hostname=${fulldomain}&type=TXT&ttl=300&do=remove&value=${txtvalue}"
  64. result="$(_get "${uri}${data}")"
  65. _debug "Result: $result"
  66. if ! _startswith "$result" 'good: remove done 1, cid '; then
  67. _info "Can't remove $fulldomain"
  68. fi
  69. }
  70. #################### Private functions below ##################################