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.

86 lines
2.3 KiB

  1. #!/usr/bin/env sh
  2. # This API is a wrapper for other API so that you
  3. # are able to put your TXT record to multiple providers.
  4. # The functionality is in the responsibility of the respective API
  5. # therefore please check if your used APIs work.
  6. # e.g. for using NS1 and AWS Route53, use:
  7. # OCTODNS_PROVIDERS=nsone_aws
  8. # --dns octodns
  9. #
  10. # Author: Josef Vogt
  11. #
  12. ######## Public functions #####################
  13. dns_octodns_add() {
  14. fulldomain=$1
  15. txtvalue=$2
  16. _info "Creating DNS entries via octoDNS"
  17. _debug fulldomain "$fulldomain"
  18. _debug txtvalue "$txtvalue"
  19. if [ -z "$OCTODNS_PROVIDERS" ]; then
  20. OCTODNS_PROVIDERS=""
  21. _err "You didn't specify OCTODNS_PROVIDERS yet."
  22. _err "Please specifiy your providers and try again."
  23. return 1
  24. fi
  25. #save the providers list to the account conf file.
  26. _saveaccountconf OCTODNS_PROVIDERS "$OCTODNS_PROVIDERS"
  27. return 1
  28. IFS='_' read -r -a used_providers <<< "$OCTODNS_PROVIDERS"
  29. for element in "${used_providers[@]}"
  30. do
  31. _debug element "$element"
  32. sourcecommand="$_SUB_FOLDER_DNSAPI/dns_${element}.sh"
  33. if ! . "$sourcecommand"; then
  34. _err "Load file $sourcecommand error. Please check your api file and try again."
  35. return 1
  36. fi
  37. addcommand="dns_${element}_add"
  38. _debug addcommand "$addcommand"
  39. $addcommand "$fulldomain" "$txtvalue"
  40. done
  41. _info "Finished adding records via octoDNS"
  42. return 0
  43. }
  44. #Remove the txt record after validation.
  45. dns_octodns_rm() {
  46. fulldomain=$1
  47. txtvalue=$2
  48. _info "Removing DNS entries via octoDNS"
  49. _debug fulldomain "$fulldomain"
  50. _debug txtvalue "$txtvalue"
  51. if [ -z "$OCTODNS_PROVIDERS" ]; then
  52. OCTODNS_PROVIDERS=""
  53. _err "You didn't specify OCTODNS_PROVIDERS yet."
  54. _err "Please specifiy your providers and try again."
  55. return 1
  56. fi
  57. IFS='_' read -r -a used_providers <<< "$OCTODNS_PROVIDERS"
  58. for element in "${used_providers[@]}"
  59. do
  60. _debug element "$element"
  61. sourcecommand="$_SUB_FOLDER_DNSAPI/dns_${element}.sh"
  62. if ! . "$sourcecommand"; then
  63. _err "Load file $sourcecommand error. Please check your api file and try again."
  64. return 1
  65. fi
  66. rmcommand="dns_${element}_rm"
  67. _debug rmcommand "$rmcommand"
  68. $rmcommand "$fulldomain" "$txtvalue"
  69. done
  70. _info "Finished deleting records via octoDNS"
  71. return 0
  72. }