🤞 Sync 2025-12-11 10:03:47
This commit is contained in:
80
ddnsto/Makefile
Normal file
80
ddnsto/Makefile
Normal file
@@ -0,0 +1,80 @@
|
||||
#
|
||||
# Copyright (C) 2015-2016 OpenWrt.org
|
||||
# Copyright (C) 2020 jjm2473@gmail.com
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_ARCH_DDNSTO:=$(ARCH)
|
||||
|
||||
PKG_NAME:=ddnsto
|
||||
# use PKG_SOURCE_DATE instead of PKG_VERSION for compitable
|
||||
PKG_SOURCE_DATE:=3.0.4
|
||||
PKG_RELEASE:=8
|
||||
ARCH_HEXCODE:=
|
||||
ifeq ($(ARCH),x86_64)
|
||||
ARCH_HEXCODE=8664
|
||||
else ifeq ($(ARCH),aarch64)
|
||||
ARCH_HEXCODE=aa64
|
||||
else ifeq ($(ARCH),arm)
|
||||
ARCH_HEXCODE=aa32
|
||||
else ifeq ($(ARCH),mipsel)
|
||||
ARCH_HEXCODE=1b0c
|
||||
endif
|
||||
PKG_SOURCE_VERSION:=$(ARCH_HEXCODE)
|
||||
PKG_SOURCE:=$(PKG_NAME)-binary-$(PKG_SOURCE_DATE).tar.gz
|
||||
PKG_SOURCE_URL:=https://dl.istoreos.com/binary/ddnsto/
|
||||
PKG_HASH:=486aa15a5e026b5a3aca72f1850746e127a7e86ef11db8a7c498dad29545eaf6
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-binary-$(PKG_SOURCE_DATE)
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=DDNS.to - the reverse proxy
|
||||
DEPENDS:=
|
||||
PKGARCH:=all
|
||||
URL:=https://www.ddnsto.com/
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
DDNS.to is a reverse proxy
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/ddnsto
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
[ -f /etc/uci-defaults/ddnsto ] && /etc/uci-defaults/ddnsto && rm -f /etc/uci-defaults/ddnsto
|
||||
exit 0
|
||||
fi
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ddnsto.$(PKG_ARCH_DDNSTO) $(1)/usr/sbin/ddnstod
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ddwebdav.$(PKG_ARCH_DDNSTO) $(1)/usr/sbin/ddwebdav
|
||||
$(INSTALL_CONF) ./files/ddnsto.config $(1)/etc/config/ddnsto
|
||||
$(INSTALL_BIN) ./files/ddnsto.init $(1)/etc/init.d/ddnsto
|
||||
$(INSTALL_BIN) ./files/ddnsto.uci-default $(1)/etc/uci-defaults/ddnsto
|
||||
$(LN) /usr/sbin/ddnstod $(1)/usr/sbin/ddnsto
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
49
ddnsto/files/ddnsto-monitor.sh
Normal file
49
ddnsto/files/ddnsto-monitor.sh
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
|
||||
DEVICE_IDX=0
|
||||
LOG_LEVEL=2
|
||||
while getopts u:x:l: flag
|
||||
do
|
||||
case "${flag}" in
|
||||
u) TOKEN=${OPTARG};;
|
||||
x) DEVICE_IDX=${OPTARG};;
|
||||
l) LOG_LEVEL=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "${TOKEN}" ]; then
|
||||
logger "ddnsto: the token is empty, get token from https://www.ddnsto.com/ "
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "ddnsto version device_id is is:"
|
||||
/usr/sbin/ddnsto -u ${TOKEN} -w
|
||||
|
||||
_term() {
|
||||
logger "ddnsto: SIGTERM"
|
||||
killall ddnsto 2>/dev/null
|
||||
killall ddwebdav 2>/dev/null
|
||||
|
||||
rm -f /tmp/.ddnsto.pid
|
||||
rm -f /tmp/.ddnsto.status
|
||||
rm -f /tmp/.ddnsto.up
|
||||
exit
|
||||
}
|
||||
|
||||
trap "_term;" SIGTERM
|
||||
|
||||
while true ; do
|
||||
if ! pidof "ddnsto" > /dev/null ; then
|
||||
logger "ddnsto try running"
|
||||
/usr/sbin/ddnsto -u ${TOKEN} -x ${DEVICE_IDX} &
|
||||
PID=$!
|
||||
wait $PID
|
||||
RET=$?
|
||||
logger "ddnsto EXIT CODE: ${RET}"
|
||||
if [ "${RET}" == "100" ]; then
|
||||
logger "ddnsto token error, please set a correct token from https://www.ddnsto.com/ "
|
||||
exit 100
|
||||
fi
|
||||
fi
|
||||
sleep 20
|
||||
done
|
||||
5
ddnsto/files/ddnsto.config
Normal file
5
ddnsto/files/ddnsto.config
Normal file
@@ -0,0 +1,5 @@
|
||||
config ddnsto
|
||||
option enabled '0'
|
||||
option feat_port '3033'
|
||||
option feat_enabled '0'
|
||||
option index '0'
|
||||
45
ddnsto/files/ddnsto.init
Executable file
45
ddnsto/files/ddnsto.init
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
get_config() {
|
||||
config_get_bool enabled $1 enabled 1
|
||||
config_get_bool logger $1 logger 0
|
||||
config_get token $1 token
|
||||
config_get index $1 index 0
|
||||
config_get_bool feat_enabled $1 feat_enabled 1
|
||||
}
|
||||
|
||||
ddnsto_prepare() {
|
||||
killall ddnstod 2>/dev/null
|
||||
killall ddwebdav 2>/dev/null
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
ddnsto_prepare
|
||||
}
|
||||
|
||||
start_service() {
|
||||
ddnsto_prepare
|
||||
config_load ddnsto
|
||||
config_foreach get_config ddnsto
|
||||
if [ $enabled != 1 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -z "$token" ]; then
|
||||
logger -t ddnsto -p warn "token not set"
|
||||
return 1
|
||||
fi
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command /usr/sbin/ddnstod -u "$token" -x $index -F
|
||||
[ "$logger" == 1 ] && procd_set_param stderr 1
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "ddnsto"
|
||||
}
|
||||
12
ddnsto/files/ddnsto.uci-default
Executable file
12
ddnsto/files/ddnsto.uci-default
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@ddnsto[-1]
|
||||
add ucitrack ddnsto
|
||||
set ucitrack.@ddnsto[-1].init=ddnsto
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
/etc/init.d/ddnsto enable
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user