From deeaee4eaef81b6b21c5cb40e26b1d160086e19c Mon Sep 17 00:00:00 2001 From: sbwml Date: Tue, 20 Jun 2023 19:36:19 +0800 Subject: [PATCH] luci-app-alist: add delayed start options --- luci-app-alist/Makefile | 2 +- luci-app-alist/luasrc/model/cbi/alist/basic.lua | 5 +++++ luci-app-alist/po/zh-cn/alist.po | 3 +++ luci-app-alist/root/etc/config/alist | 1 + luci-app-alist/root/etc/init.d/alist | 8 +++++++- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/luci-app-alist/Makefile b/luci-app-alist/Makefile index 8779d63..7196c13 100644 --- a/luci-app-alist/Makefile +++ b/luci-app-alist/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-alist -PKG_VERSION:=1.0.8 +PKG_VERSION:=1.0.9 PKG_RELEASE:=1 LUCI_TITLE:=LuCI support for alist diff --git a/luci-app-alist/luasrc/model/cbi/alist/basic.lua b/luci-app-alist/luasrc/model/cbi/alist/basic.lua index d9eea59..b550b42 100644 --- a/luci-app-alist/luasrc/model/cbi/alist/basic.lua +++ b/luci-app-alist/luasrc/model/cbi/alist/basic.lua @@ -47,6 +47,11 @@ o.datatype = "and(uinteger,min(1))" o.default = "48" o.rmempty = false +o = s:option(Value, "delayed_start", translate("Delayed Start (seconds)")) +o.datatype = "and(uinteger,min(0))" +o.default = "0" +o.rmempty = false + o = s:option(Value, "temp_dir", translate("Cache directory")) o.datatype = "string" o.default = "/tmp/alist" diff --git a/luci-app-alist/po/zh-cn/alist.po b/luci-app-alist/po/zh-cn/alist.po index 65e08df..beebf07 100644 --- a/luci-app-alist/po/zh-cn/alist.po +++ b/luci-app-alist/po/zh-cn/alist.po @@ -90,3 +90,6 @@ msgstr "站点 URL" msgid "When the web is reverse proxied to a subdirectory, this option must be filled out to ensure proper functioning of the web. Do not include '/' at the end of the URL" msgstr "Web 被反向代理到二级目录时,必须填写该选项以确保 Web 正常工作。URL 结尾请勿携带 '/'" + +msgid "Delayed Start (seconds)" +msgstr "开机延时启动(秒)" diff --git a/luci-app-alist/root/etc/config/alist b/luci-app-alist/root/etc/config/alist index 1b6e0ad..75aa0b3 100644 --- a/luci-app-alist/root/etc/config/alist +++ b/luci-app-alist/root/etc/config/alist @@ -6,3 +6,4 @@ config alist option 'token_expires_in' '48' option 'max_connections' '0' option 'site_url' '' + option 'delayed_start' '0' diff --git a/luci-app-alist/root/etc/init.d/alist b/luci-app-alist/root/etc/init.d/alist index 9ee7dd5..e9a5507 100755 --- a/luci-app-alist/root/etc/init.d/alist +++ b/luci-app-alist/root/etc/init.d/alist @@ -17,6 +17,7 @@ get_config() { config_get token_expires_in $1 token_expires_in 48 config_get allow_wan $1 allow_wan 0 config_get max_connections $1 max_connections 0 + config_get delayed_start $1 delayed_start 0 config_load network config_get lan_addr lan ipaddr "0.0.0.0" if echo "${lan_addr}" | grep -Fq ' '; then @@ -52,6 +53,11 @@ start_service() { mkdir -p $temp_dir [ "$ssl" -eq 1 ] && SSL=true || SSL=false [ "$log" -eq 1 ] && LOG=true || LOG=false + if [ -e /proc/uptime ]; then + [ $(awk -F. '{print $1}' /proc/uptime) -lt "120" ] && delayed_start=$delayed_start || delayed_start=0 + else + delayed_start=$delayed_start + fi if [ "$allow_wan" -eq "1" ]; then listen_addr="0.0.0.0" external_access="allow" @@ -62,7 +68,7 @@ start_service() { set_firewall cat /dev/null > $temp_dir/alist.log cat > $CONFIG_DIR/config.json <