Skip to content

Commit

Permalink
up luci-app-ddns-go 1.3.1 增加刷新间隔参数
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpdboy authored Jun 24, 2023
1 parent 87285f6 commit 0ffcfb5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 54 deletions.
45 changes: 6 additions & 39 deletions ddns-go/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (C) 2021-2023 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/luci-app-ddns-go
# Copyright (C) 2021-2023 sirpdboy <herboy2008@gmail.com>
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
Expand All @@ -21,17 +21,12 @@ PKG_LICENSE:=AGPL-3.0-only
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=herboy2008 <herboy2008@gmail.com>

PKG_CONFIG_DEPENDS:= \
CONFIG_DDNS-GO_COMPRESS_GOPROXY \
CONFIG_DDNS-GO_COMPRESS_UPX

PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
PKG_BUILD_FLAGS:=no-mips16

GO_PKG:=github.com/jeessy2/ddns-go/v5
GO_PKG_LDFLAGS:=-s -w
GO_PKG_LDFLAGS_X:=m.version=$(PKG_VERSION)
GO_PKG_LDFLAGS_X:=main.version=$(PKG_VERSION)

include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
Expand All @@ -43,51 +38,23 @@ define Package/ddns-go
SUBMENU:=Web Servers/Proxies
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
URL:=https://github.com/jeessy2/ddns-go
USERID:=ddns-go:ddns-go
endef

define Package/$(PKG_NAME)/description
ddns-go is a automatically obtain your public IPv4 or IPv6 address and resolve it to the corresponding domain name service,
support Alidns Dnspod Cloudflare Hicloud Callback Baiducloud porkbun GoDaddy Google Domains.
endef

define Package/$(PKG_NAME)/config
config DDNS-GO_COMPRESS_GOPROXY
bool "Compiling with GOPROXY proxy"
default n

config DDNS-GO_COMPRESS_UPX
bool "Compress executable files with UPX"
depends on !mips64
default n
endef

ifeq ($(CONFIG_DDNS-GO_COMPRESS_GOPROXY),y)
export GO111MODULE=on
export GOPROXY=https://goproxy.baidu.com
endif

define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
[ -f /etc/uci-defaults/luci-ddns-go ] && /etc/uci-defaults/luci-ddns-go && rm -f /etc/uci-defaults/luci-ddns-go
fi
endef

define Build/Compile
$(call GoPackage/Build/Compile)
ifneq ($(CONFIG_DDNS-GO_COMPRESS_UPX),)
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/ddns-go
endif
endef

define Package/$(PKG_NAME)/install
$(call GoPackage/Package/Install/Bin,$(1))

$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./file/ddns-go.init $(1)/etc/init.d/ddns-go
$(INSTALL_BIN) $(CURDIR)/file/ddns-go.init $(1)/etc/init.d/ddns-go

$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./file/luci-ddns-go.uci-default $(1)/etc/uci-defaults/luci-ddns-go
$(INSTALL_BIN) $(CURDIR)/file/luci-ddns-go.uci-default $(1)/etc/uci-defaults/luci-ddns-go
endef

$(eval $(call GoBinPackage,ddns-go))
Expand Down
16 changes: 4 additions & 12 deletions ddns-go/file/ddns-go.init
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2021-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/luci-app-ddns-go
# Copyright (C) 2021-2023 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/luci-app-ddns-go
#
# This file is part of ddns-go .
#
Expand All @@ -13,37 +13,29 @@ USE_PROCD=1

PROG=/usr/bin/ddns-go
CONFDIR=/etc/ddns-go
CONF=/etc/ddns-go/ddns-go-config.yaml
CONF=$CONFDIR/ddns-go-config.yaml

get_config() {
config_get_bool enabled $1 enabled 1
config_get_bool logger $1 logger 1
config_get port $1 port 9876
}
prepare() {
pgrep -f /usr/bin/ddns-go | xargs kill -9 >/dev/null 2>&1
logger -t ddns-go -p warn "ddns-go is stop."
config_get time $1 time 300
}

init_yaml(){
[ -d $CONFDIR ] || mkdir -p $CONFDIR 2>/dev/null
cat /usr/share/ddns-go/ddns-go-default.yaml > $CONF
}

stop_service() {
prepare
}

start_service() {
prepare
config_load ddns-go
config_foreach get_config basic
[ x$enabled == x1 ] || return 1
[ -s ${CONF} ] || init_yaml
logger -t ddns-go -p warn "ddns-go is start."
echo "ddns-go is start."
procd_open_instance
procd_set_param command $PROG -l :$port -f 300 -c "$CONF"
procd_set_param command $PROG -l :$port -f $time -c "$CONF"
[ "x$logger" == x1 ] && procd_set_param stderr 1
procd_set_param respawn
procd_close_instance
Expand Down
4 changes: 2 additions & 2 deletions luci-app-ddns-go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-ddns-go
PKG_VERSION:=1.3.0
PKG_RELEASE:=9
PKG_VERSION:=1.3.1
PKG_RELEASE:=10

LUCI_TITLE:=LuCI Support for Dynamic ddns-go Client
LUCI_DEPENDS:=+ddns-go
Expand Down
3 changes: 3 additions & 0 deletions luci-app-ddns-go/luasrc/model/cbi/ddns-go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ o = s:option(Value, "port",translate("Set the DDNS-TO access port"))
o.datatype = "uinteger"
o.default=9876

o = s:option(Value, "time",translate("update interval"))
o.default=300

m.apply_on_parse = true
m.on_after_apply = function(self,map)
luci.sys.exec("/etc/init.d/ddns-go restart")
Expand Down
4 changes: 4 additions & 0 deletions luci-app-ddns-go/po/zh-cn/ddns-go.po
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ msgstr "</br>具体使用方法参见:"
msgid "Collecting data..."
msgstr "收集数据..."

msgid "update interval"
msgstr "更新间隔"


3 changes: 2 additions & 1 deletion luci-app-ddns-go/root/etc/config/ddns-go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
config basic
option enabled '0'
option logger '1'
option port 9876
option port 9876
option time 300

0 comments on commit 0ffcfb5

Please sign in to comment.