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.

45 lines
1.6 KiB

  1. #
  2. #.Distributed under the terms of the GNU General Public License (GPL) version 2.0
  3. #
  4. # The script directly updates a PowerDNS (or maybe bind server) via nsupdate from bind-client package.
  5. #.based on github request #957 by Jan Riechers <de at r-jan dot de>
  6. #.2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
  7. #
  8. # This script is parsed by dynamic_dns_functions.sh inside send_update() function
  9. #
  10. # using following options from /etc/config/ddns
  11. # option username - keyname
  12. # option password - shared secret (base64 encoded)
  13. # option domain - full qualified domain to update
  14. # option dns_server - DNS server to update
  15. #
  16. # variable __IP already defined with the ip-address to use for update
  17. #
  18. local __TTL=600 #.preset DNS TTL (in seconds)
  19. local __RRTYPE __PW __TCP
  20. [ -x /usr/bin/nsupdate ] || write_log 14 "'nsupdate' not installed or not executable !"
  21. [ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
  22. [ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
  23. [ -z "$dns_server" ] && write_log 14 "Service section not configured correctly! Missing 'dns_server'"
  24. [ $use_ipv6 -ne 0 ] && __RRTYPE="AAAA" || __RRTYPE="A"
  25. [ $force_dnstcp -ne 0 ] && __TCP="-v" || __TCP=""
  26. # create command file
  27. cat >$DATFILE <<-EOF
  28. server $dns_server
  29. key $username $password
  30. update del $domain $__RRTYPE
  31. update add $domain $__TTL $__RRTYPE $__IP
  32. show
  33. send
  34. quit
  35. EOF
  36. /usr/bin/nsupdate -d $__TCP $DATFILE >$ERRFILE 2>&1
  37. # nsupdate always return success
  38. write_log 7 "nsupdate reports:\n$(cat $ERRFILE)"
  39. return 0