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.

30 lines
869 B

  1. #!/bin/sh
  2. #
  3. # sample script for detecting local IP
  4. # 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
  5. #
  6. # activated inside /etc/config/ddns by setting
  7. #
  8. # option ip_source 'script'
  9. # option ip_script '/usr/lib/ddns/getlocalip_sample.sh -6' !!! parameters ALLOWED
  10. #
  11. # the script is executed (not parsed) inside get_local_ip() function
  12. # of /usr/lib/ddns/dynamic_dns_functions.sh
  13. #
  14. # This script should
  15. # - return the IP address via stdout echo -n "...." !!! without line feed
  16. # - report errors via stderr echo "...." >&2
  17. # - return an error code ('0' for success) exit 123
  18. case $1 in
  19. -4) echo -n "8.8.8.8" # never append linefeed or simular
  20. exit 0
  21. ;; # IP's of Googles public DNS
  22. -6) echo -n "2001:4860:4860::8888"
  23. exit 0
  24. ;;
  25. *) echo "$0 - Invalid or missing parameter" >&2
  26. exit 1
  27. esac
  28. echo "Should never come here" >&2
  29. exit 2