packages/net/ddns-scripts/samples/update_sample.sh

42 lines
1.8 KiB
Bash
Raw Normal View History

# sample script for sending user defined updates
# 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
ddns-scripts: Added support for custom update scripts Squashed commit of the following: commit 2701c8868e1ef4949db57e53b27958edba6abb59 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 11:01:57 2014 +0200 ddns-scripts: Added support for custom update scripts Sample script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit e07ecb90fa2c7404a97cf64024e89bd9d88aacd4 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 11:00:11 2014 +0200 ddns-scripts: Added support for custom update scripts Added support for custom update scripts with new option update_script. function get_service_url() renamed to get_service_data() and extended to detect scripts inside service / service_ipv6 for later use function send_update() modified to support custom update scripts. Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 39e41b2151a79a7ace71a9d40b87cd4d6ce09503 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:52:44 2014 +0200 ddns-scripts: Added support for custom update scripts Added support for custom update scripts with new option update_script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 33f264768e37d8a6fe564faaafa51a7b45a0ee19 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:48:21 2014 +0200 ddns-scripts: Insert description for NEW option update_script Insert description for NEW option update_script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 6f6a60244df53e0556f5c75845c69aa832f97e4c Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:43:52 2014 +0200 ddns-scripts: Update PKG_RELEASE Update_PKG_RELEASE to reflect changes Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
2014-10-06 06:39:59 +00:00
#
# activated inside /etc/config/ddns by setting
#
# option update_script '/usr/lib/ddns/update_sample.sh'
ddns-scripts: Added support for custom update scripts Squashed commit of the following: commit 2701c8868e1ef4949db57e53b27958edba6abb59 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 11:01:57 2014 +0200 ddns-scripts: Added support for custom update scripts Sample script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit e07ecb90fa2c7404a97cf64024e89bd9d88aacd4 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 11:00:11 2014 +0200 ddns-scripts: Added support for custom update scripts Added support for custom update scripts with new option update_script. function get_service_url() renamed to get_service_data() and extended to detect scripts inside service / service_ipv6 for later use function send_update() modified to support custom update scripts. Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 39e41b2151a79a7ace71a9d40b87cd4d6ce09503 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:52:44 2014 +0200 ddns-scripts: Added support for custom update scripts Added support for custom update scripts with new option update_script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 33f264768e37d8a6fe564faaafa51a7b45a0ee19 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:48:21 2014 +0200 ddns-scripts: Insert description for NEW option update_script Insert description for NEW option update_script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 6f6a60244df53e0556f5c75845c69aa832f97e4c Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:43:52 2014 +0200 ddns-scripts: Update PKG_RELEASE Update_PKG_RELEASE to reflect changes Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
2014-10-06 06:39:59 +00:00
#
# the script is parsed (not executed) inside send_update() function
# of /usr/lib/ddns/dynamic_dns_functions.sh
# so you can use all available functions and global variables inside this script
# already defined in dynamic_dns_updater.sh and dynamic_dns_functions.sh
#
# It make sence to define the update url ONLY inside this script
ddns-scripts: Added support for custom update scripts Squashed commit of the following: commit 2701c8868e1ef4949db57e53b27958edba6abb59 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 11:01:57 2014 +0200 ddns-scripts: Added support for custom update scripts Sample script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit e07ecb90fa2c7404a97cf64024e89bd9d88aacd4 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 11:00:11 2014 +0200 ddns-scripts: Added support for custom update scripts Added support for custom update scripts with new option update_script. function get_service_url() renamed to get_service_data() and extended to detect scripts inside service / service_ipv6 for later use function send_update() modified to support custom update scripts. Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 39e41b2151a79a7ace71a9d40b87cd4d6ce09503 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:52:44 2014 +0200 ddns-scripts: Added support for custom update scripts Added support for custom update scripts with new option update_script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 33f264768e37d8a6fe564faaafa51a7b45a0ee19 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:48:21 2014 +0200 ddns-scripts: Insert description for NEW option update_script Insert description for NEW option update_script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 6f6a60244df53e0556f5c75845c69aa832f97e4c Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:43:52 2014 +0200 ddns-scripts: Update PKG_RELEASE Update_PKG_RELEASE to reflect changes Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
2014-10-06 06:39:59 +00:00
# because it's anyway unique to the update script
# otherwise it should work with the default scripts
#
# the code here is the copy of the default used inside send_update()
#
# tested with spdns.de
local __URL="http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
# inside url we need domain, username and password
[ -z "$domain" ] && write_log 14 "Service section not configured correctly! Missing 'domain'"
[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
ddns-scripts: Added support for custom update scripts Squashed commit of the following: commit 2701c8868e1ef4949db57e53b27958edba6abb59 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 11:01:57 2014 +0200 ddns-scripts: Added support for custom update scripts Sample script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit e07ecb90fa2c7404a97cf64024e89bd9d88aacd4 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 11:00:11 2014 +0200 ddns-scripts: Added support for custom update scripts Added support for custom update scripts with new option update_script. function get_service_url() renamed to get_service_data() and extended to detect scripts inside service / service_ipv6 for later use function send_update() modified to support custom update scripts. Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 39e41b2151a79a7ace71a9d40b87cd4d6ce09503 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:52:44 2014 +0200 ddns-scripts: Added support for custom update scripts Added support for custom update scripts with new option update_script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 33f264768e37d8a6fe564faaafa51a7b45a0ee19 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:48:21 2014 +0200 ddns-scripts: Insert description for NEW option update_script Insert description for NEW option update_script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 6f6a60244df53e0556f5c75845c69aa832f97e4c Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:43:52 2014 +0200 ddns-scripts: Update PKG_RELEASE Update_PKG_RELEASE to reflect changes Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
2014-10-06 06:39:59 +00:00
# do replaces in URL
__URL=$(echo $__URL | | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
-e "s#\[PARAMENC\]#$URL_PENC#g" -e "s#\[PARAMOPT\]#$param_opt#g" \
-e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
ddns-scripts: Added support for custom update scripts Squashed commit of the following: commit 2701c8868e1ef4949db57e53b27958edba6abb59 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 11:01:57 2014 +0200 ddns-scripts: Added support for custom update scripts Sample script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit e07ecb90fa2c7404a97cf64024e89bd9d88aacd4 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 11:00:11 2014 +0200 ddns-scripts: Added support for custom update scripts Added support for custom update scripts with new option update_script. function get_service_url() renamed to get_service_data() and extended to detect scripts inside service / service_ipv6 for later use function send_update() modified to support custom update scripts. Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 39e41b2151a79a7ace71a9d40b87cd4d6ce09503 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:52:44 2014 +0200 ddns-scripts: Added support for custom update scripts Added support for custom update scripts with new option update_script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 33f264768e37d8a6fe564faaafa51a7b45a0ee19 Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:48:21 2014 +0200 ddns-scripts: Insert description for NEW option update_script Insert description for NEW option update_script Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com> commit 6f6a60244df53e0556f5c75845c69aa832f97e4c Author: Christian Schoenebeck <christian.schoenebeck@gmail.com> Date: Sun Oct 5 10:43:52 2014 +0200 ddns-scripts: Update PKG_RELEASE Update_PKG_RELEASE to reflect changes Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
2014-10-06 06:39:59 +00:00
[ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
do_transfer "$__URL" || return 1
write_log 7 "DDNS Provider answered:\n$(cat $DATFILE)"
# analyse provider answers
# "good [IP_ADR]" = successful
# "nochg [IP_ADR]" = no change but OK
grep -i -E "good|nochg" $DATFILE >/dev/null 2>&1
return $? # "0" if "good" or "nochg" found