packages/net/ddns-scripts/files/usr/lib/ddns/getlocalip_sample.sh
Christian Schoenebeck ab2b229ad6 ddns-scripts: new Version 2.1.0-2
- moved /usr/lib/ddns/dynamic_dns_lucihelper.sh from luci-app-ddns into this package
	(Github openwrt/luci issue 251)
	(OpenWrt Trac tickets 18326 18347)
- fix: dynamic_dns_update.sh did not loop
	(OpenWrt Trac ticket 18336)
- add provider cloudflare.com IPv4 and IPv6 (Thanks to Paul for support and testing)
	(OpenWrt Trac ticket 12500)
- modified detection, if dynamic_dns_fuctions are used by dynamic_dns_lucihelper.sh
- redirect stdout of wget,curl,host,nslookup,nc etc to /tmp/ddns_$$.dat and *.err instead of variables
- extended error detection in get_local_ip function
- modified verify of option ip_script to allow parameters, when calling
- add provider selfhost.de IPv4
- add provider no-ip.pl (nothing to do with no-ip.com)
	(Github openwrt/packages issue #542)
	IPv4 (tested) and also added for
	IPv6 (NOT tested) because client IP is autodetected be provider
- add getlocalip_sample.sh as sample script for usage of
	option ip_source 'script'  together with
	option ip_script '/usr/lib/ddns/getlocalip.sh -4'
- cleanup whitespaces at line ends

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
2014-11-15 21:28:01 +01:00

30 lines
869 B
Bash
Executable file

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