diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2014-12-03 15:17:05 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-08 16:26:20 +0100 |
commit | 1bb4822dca6113f73e3bc89e2acf15935e6f8e92 (patch) | |
tree | 35e16f100466e4e00657199b38bb3d87d52bf73f /applications/luci-app-ddns/root | |
parent | 9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4 (diff) |
Rework LuCI build system
* Rename subdirectories to their repective OpenWrt package names
* Make each LuCI module its own standalone package
* Deploy a shared luci.mk which is used by each module Makefile
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'applications/luci-app-ddns/root')
-rwxr-xr-x | applications/luci-app-ddns/root/etc/uci-defaults/luci-ddns | 24 | ||||
-rwxr-xr-x | applications/luci-app-ddns/root/usr/lib/ddns/dynamic_dns_lucihelper.sh | 82 |
2 files changed, 106 insertions, 0 deletions
diff --git a/applications/luci-app-ddns/root/etc/uci-defaults/luci-ddns b/applications/luci-app-ddns/root/etc/uci-defaults/luci-ddns new file mode 100755 index 000000000..5d3f56f98 --- /dev/null +++ b/applications/luci-app-ddns/root/etc/uci-defaults/luci-ddns @@ -0,0 +1,24 @@ +#!/bin/sh + +# luci updates are not in sync with ddns-script updates !!! +# needed because luci update might delete helper script +# copy dynamic_dns_helper.tmp.sh from ddns-scripts +cp -f /usr/lib/ddns/dynamic_dns_lucihelper.tmp.sh /usr/lib/ddns/dynamic_dns_lucihelper.sh + +# no longer needed for "Save and Apply" to restart ddns +uci -q batch <<-EOF >/dev/null + delete ucitrack.@ddns[-1] + commit ucitrack +EOF + +# make helper script executable +chmod 755 /usr/lib/ddns/dynamic_dns_lucihelper.sh + +# update application section for luci-app-ddns +uci -q get ddns.global > /dev/null || uci -q set ddns.global='ddns' +uci -q get ddns.global.date_format > /dev/null || uci -q set ddns.global.date_format='%F %R' +uci -q get ddns.global.log_lines > /dev/null || uci -q set ddns.global.log_lines='250' +uci -q commit ddns + +rm -f /tmp/luci-indexcache +exit 0 diff --git a/applications/luci-app-ddns/root/usr/lib/ddns/dynamic_dns_lucihelper.sh b/applications/luci-app-ddns/root/usr/lib/ddns/dynamic_dns_lucihelper.sh new file mode 100755 index 000000000..1782d1f03 --- /dev/null +++ b/applications/luci-app-ddns/root/usr/lib/ddns/dynamic_dns_lucihelper.sh @@ -0,0 +1,82 @@ +#!/bin/sh +# /usr/lib/ddns/luci_dns_helper.sh +# +# Written by Christian Schoenebeck in August 2014 to support: +# this script is used by luci-app-ddns +# - getting registered IP +# - check if possible to get local IP +# - verifing given DNS- or Proxy-Server +# +# variables in small chars are read from /etc/config/ddns +# variables in big chars are defined inside these scripts as gloval vars +# variables in big chars beginning with "__" are local defined inside functions only +# set -vx #script debugger + +[ $# -lt 2 ] && exit 1 + +. /usr/lib/ddns/dynamic_dns_functions.sh # global vars are also defined here + +# set -vx #script debugger + +# preset some variables wrong or not set in dynamic_dns_functions.sh +SECTION_ID="dynamic_dns_lucihelper" +LOGFILE="$LOGDIR/$SECTION_ID.log" +LUCI_HELPER="ACTIV" # supress verbose and critical logging +# global variables normally set by reading DDNS UCI configuration +use_logfile=0 +use_syslog=0 + +case "$1" in + get_registered_ip) + local IP + domain=$2 # Hostname/Domain + use_ipv6=${3:-"0"} # Use IPv6 - default IPv4 + force_ipversion=${4:-"0"} # Force IP Version - default 0 - No + force_dnstcp=${5:-"0"} # Force TCP on DNS - default 0 - No + dns_server=${6:-""} # DNS server - default No DNS + get_registered_ip IP + [ $? -ne 0 ] && IP="" + echo -n "$IP" # suppress LF + ;; + verify_dns) + # $2 == dns-server to verify # no need for force_dnstcp because + # verify with nc (netcat) uses tcp anyway + use_ipv6=${3:-"0"} # Use IPv6 - default IPv4 + force_ipversion=${4:-"0"} # Force IP Version - default 0 - No + verify_dns "$2" + ;; + verify_proxy) + # $2 == proxy string to verify + use_ipv6=${3:-"0"} # Use IPv6 - default IPv4 + force_ipversion=${4:-"0"} # Force IP Version - default 0 - No + verify_proxy "$2" + ;; + get_local_ip) + local IP + use_ipv6="$2" # Use IPv6 + ip_source="$3" # IP source + ip_network="$4" # set if source = "network" otherwise "-" + ip_url="$5" # set if source = "web" otherwise "-" + ip_interface="$6" # set if source = "interface" itherwiase "-" + ip_script="$7" # set if source = "script" otherwise "-" + proxy="$8" # proxy if set + force_ipversion="0" # not needed but must be set + use_https="0" # not needed but must be set + [ -n "$proxy" -a "$ip_source" == "web" ] && { + # proxy defined, used for ip_source=web + export HTTP_PROXY="http://$proxy" + export HTTPS_PROXY="http://$proxy" + export http_proxy="http://$proxy" + export https_proxy="http://$proxy" + } + # don't need IP only the return code + [ "$ip_source" == "web" -o "$ip_source" == "script"] && { + # we wait only 3 seconds for an + # answer from "web" or "script" + __timeout 3 -- get_local_ip IP + } || get_local_ip IP + ;; + *) + return 1 + ;; +esac |