This commit is contained in:
sbwml 2022-09-16 00:51:34 +08:00
commit c62b63ad0f
17 changed files with 240 additions and 155 deletions

View File

@ -7,13 +7,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=alist
PKG_VERSION:=2.6.4
PKG_WEB_VERSION:=2.6.4
PKG_VERSION:=3.0.0-rc.0
PKG_WEB_VERSION:=3.0.0-rc.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/alist-org/alist/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=3860f5cec5d809159c55498874c472386cd6142a932a5e7bbfb3b0f569e3e12b
PKG_HASH:=659ddabc87ceca834a09320c6dd87ab24b16247b992d297b12d9ea4771bed9bf
PKG_LICENSE:=GPL-3.0
PKG_LICENSE_FILE:=LICENSE
@ -22,8 +22,8 @@ PKG_MAINTAINER:=sbwml <admin@cooluc.com>
define Download/$(PKG_NAME)-web
FILE:=$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz
URL_FILE:=dist.tar.gz
URL:=https://github.com/alist-org/web-v2/releases/download/$(PKG_WEB_VERSION)/
HASH:=4189ce3c523e6b8f6bba55faefabc926f6ef793c8755c5c2a2d3f75532fb2243
URL:=https://github.com/alist-org/alist-web/releases/download/$(PKG_WEB_VERSION)/
HASH:=55ad8bf4e39e48ff1a0a503783c4e6922e102810cae6dcdf99cec91263c79414
endef
PKG_CONFIG_DEPENDS:=CONFIG_ALIST_COMPRESS_UPX
@ -32,10 +32,12 @@ PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
GO_PKG:=github.com/Xhofe/alist
ALIST_PKG:=github.com/Xhofe/alist/conf
PKG_ALIST:=github.com/alist-org/alist/v3/internal/conf
GO_PKG:=github.com/alist-org/alist
GO_PKG_LDFLAGS:=-w -s
GO_PKG_LDFLAGS_X:=$(ALIST_PKG).GitTag=v$(PKG_VERSION)-$(ARCH)
GO_PKG_LDFLAGS_X:= \
$(PKG_ALIST).Version=v$(PKG_VERSION)-$(ARCH) \
$(PKG_ALIST).WebVersion=$(PKG_WEB_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
@ -66,8 +68,8 @@ endef
define Build/Prepare
$(call Build/Prepare/Default)
$(eval $(call Download,$(PKG_NAME)-web))
$(TAR) --strip-components=1 -C $(PKG_BUILD_DIR)/public -xzf $(DL_DIR)/$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz
$(CP) ./files/assets/. $(PKG_BUILD_DIR)/public/assets/
$(TAR) --strip-components=1 -C $(PKG_BUILD_DIR)/public/dist -xzf $(DL_DIR)/$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz
$(CP) ./files/assets/. $(PKG_BUILD_DIR)/public/dist/assets/
endef
define Build/Compile

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="640pt" height="640pt" viewBox="0 0 640 640" version="1.1" xmlns="http://www.w3.org/2000/svg">
<g id="#75c4beff">
<path fill="#75c4be" opacity="1.00" d=" M 326.33 53.46 C 332.73 52.13 339.80 52.94 345.24 56.78 C 351.10 60.95 355.42 66.87 359.18 72.91 C 413.13 162.45 466.15 252.54 519.63 342.37 C 533.77 366.22 548.04 389.99 561.98 413.97 C 565.57 420.47 569.65 426.80 572.11 433.85 C 574.71 442.80 575.26 452.42 573.40 461.58 C 571.16 471.91 563.67 480.51 554.58 485.59 C 547.15 489.94 538.61 492.34 529.99 492.34 C 471.66 492.39 413.33 492.32 355.00 492.38 C 347.28 492.31 339.07 491.06 332.84 486.14 C 328.67 482.79 324.78 478.42 323.87 472.98 C 322.65 465.12 324.45 457.05 328.13 450.06 C 332.44 441.85 337.43 434.01 341.95 425.92 C 350.12 411.30 359.31 397.29 367.87 382.90 C 373.02 374.40 381.07 366.99 391.06 365.01 C 405.38 363.19 421.45 374.82 420.76 390.02 C 420.53 403.34 411.28 413.77 406.46 425.58 C 405.37 428.57 403.57 432.32 405.76 435.24 C 409.97 437.89 415.19 437.95 420.00 438.17 C 444.00 438.20 467.99 438.13 491.99 438.21 C 496.40 438.12 501.06 438.21 505.15 436.27 C 506.87 435.57 507.96 433.81 507.89 431.96 C 507.85 428.01 505.68 424.52 503.79 421.19 C 495.41 407.20 487.36 393.02 479.03 379.00 C 435.55 304.25 391.71 229.71 347.81 155.20 C 344.09 149.60 341.53 143.14 336.78 138.28 C 334.65 135.85 330.80 136.63 329.07 139.11 C 324.76 144.59 321.32 150.70 317.65 156.62 C 258.22 256.83 198.68 356.97 139.09 457.08 C 134.67 465.40 129.90 473.61 124.01 480.99 C 118.33 487.59 110.05 492.53 101.18 492.56 C 92.76 491.73 84.50 487.48 79.39 480.65 C 75.14 474.46 74.64 466.37 76.43 459.25 C 78.16 451.11 82.97 444.19 87.22 437.20 C 128.26 367.34 169.88 297.83 211.19 228.13 C 234.01 189.69 256.88 151.28 279.84 112.92 C 287.23 99.22 295.72 86.17 303.81 72.89 C 309.02 64.44 316.29 55.89 326.33 53.46 Z" />
</g>
<g id="#2c9fd6ff">
<path fill="#2c9fd6" opacity="1.00" d=" M 329.35 261.14 C 337.95 260.38 347.26 263.39 353.07 269.98 C 357.77 275.75 360.69 283.43 358.96 290.91 C 357.79 299.89 351.32 306.64 347.61 314.57 C 342.19 323.76 336.45 332.76 331.05 341.96 C 324.62 354.04 316.79 365.31 310.38 377.39 C 305.41 384.56 301.54 392.40 296.78 399.71 C 290.29 410.33 284.30 421.24 277.99 431.97 C 267.62 447.21 259.73 463.97 249.08 479.02 C 244.35 485.33 237.50 490.71 229.49 491.80 C 223.07 492.98 216.60 490.64 210.88 487.89 C 205.68 484.07 200.75 478.79 200.12 472.05 C 199.38 464.91 199.56 456.96 203.97 450.94 C 209.04 444.01 211.63 435.67 216.66 428.72 C 221.89 421.34 225.45 412.96 230.56 405.50 C 236.11 397.24 240.85 388.50 245.75 379.85 C 257.24 361.25 268.04 342.23 279.39 323.55 C 283.37 315.67 288.11 308.22 292.72 300.71 C 299.71 290.30 305.20 278.88 313.07 269.07 C 316.98 264.08 323.33 262.12 329.35 261.14 Z" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -1,10 +0,0 @@
<svg width="722" height="722" xmlns="http://www.w3.org/2000/svg" version="1.1">
<g>
<g id="#70c6beff">
<path id="svg_2" d="m372.33,100.27c8.44,-1.08 16.61,3.14 22.53,8.87c6.71,6.94 11.39,15.47 16.32,23.68c62.43,104.06 124.07,208.59 186.17,312.85c14.6,24.75 29.53,49.31 43.56,74.4c6.59,11.45 9.1,25.23 6.54,38.23c-1.67,11.63 -8.97,22.12 -18.86,28.31c-7.78,4.86 -16.58,8.22 -25.73,9.17c-4.61,0.42 -9.24,0.19 -13.86,0.22c-63.67,0 -127.35,-0.01 -191.02,0c-8.07,-0.1 -16.22,-2.41 -22.78,-7.2c-7.16,-4.99 -11.59,-14.05 -10.32,-22.79c0.89,-9.17 4.85,-17.68 9.63,-25.44c10.82,-18.77 21.65,-37.53 33.15,-55.9c5.16,-8.03 9.38,-16.95 16.59,-23.43c4.87,-4.16 10.6,-7.63 16.96,-8.82c9.04,-1.12 18.19,2.51 24.97,8.39c6.95,6.16 9.53,16.17 7.88,25.14c-2.58,14.52 -13.13,25.82 -17.34,39.74c-0.92,2.35 -0.44,5.39 2.07,6.53c4.99,2.51 10.75,2.65 16.22,2.79c27.67,-0.02 55.34,-0.02 83.02,0.01c5.04,-0.14 10.92,-0.42 14.59,-4.38c1.7,-5.94 -2.55,-11.22 -5.1,-16.2c-59.46,-101.8 -118.86,-203.63 -178.93,-305.08c-2.61,-4.29 -4.77,-8.97 -8.31,-12.62c-2.33,-2.69 -7,-2.37 -8.92,0.63c-5.67,7.2 -10.1,15.27 -14.86,23.07c-65.86,110.83 -131.72,221.65 -197.58,332.48c-6.29,10.31 -11.48,21.4 -19.35,30.66c-6.28,7.48 -15.75,12.4 -25.6,12.35c-5.38,0.01 -10.4,-2.27 -15.04,-4.77c-6.95,-3.74 -12.3,-10.62 -13.5,-18.5c-1.49,-9.66 1.55,-19.46 6.41,-27.75c56.45,-95.79 113.47,-191.24 170.19,-286.88c21.72,-36.61 43.75,-73.05 65.19,-109.84c5.5,-9.12 11.24,-18.1 16.77,-27.21c6.13,-10.19 16.01,-19.5 28.34,-20.71z" fill="#70c6be"/>
</g>
<g id="#1ba0d8ff">
<path id="svg_3" d="m368.33,335.39c9.54,-1.82 19.84,0.73 27.41,6.83c5.57,5 9.37,12.21 9.55,19.78c0.61,9.39 -3.76,18.08 -8.42,25.92c-36.12,60.55 -72.06,121.21 -108.18,181.76c-5.34,8.95 -11.1,18.53 -21,23.02c-15,8.41 -36.64,-0.5 -41.29,-17.06c-1.72,-7.86 -1.04,-16.4 2.63,-23.63c7.02,-14.54 15.98,-28.02 23.94,-42.05c31.09,-52.53 62.14,-105.09 93.63,-157.38c4.97,-7.94 12.06,-15.57 21.73,-17.19z" fill="#1ba0d8"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,38 +0,0 @@
From fdcb81f6ba8b8d7546a6742e9566487e12815499 Mon Sep 17 00:00:00 2001
From: sbwml <admin@cooluc.com>
Date: Thu, 28 Apr 2022 11:10:53 +0800
Subject: [PATCH] Revert "feat: clear temp file while start"
This reverts commit 24d031d57875d3c6a9624fa7334c6eac1c9111fb.
---
bootstrap/conf.go | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/bootstrap/conf.go b/bootstrap/conf.go
index 5c9a1b3..f4d87d4 100644
--- a/bootstrap/conf.go
+++ b/bootstrap/conf.go
@@ -7,7 +7,6 @@ import (
log "github.com/sirupsen/logrus"
"io/ioutil"
"os"
- "path/filepath"
)
// InitConf init config
@@ -47,11 +46,7 @@ func InitConf() {
if !conf.Conf.Force {
confFromEnv()
}
- err := os.RemoveAll(filepath.Join(conf.Conf.TempDir))
- if err != nil {
- log.Errorln("failed delete temp file:", err)
- }
- err = os.MkdirAll(conf.Conf.TempDir, 0700)
+ err := os.MkdirAll(conf.Conf.TempDir, 0700)
if err != nil {
log.Fatalf("create temp dir error: %s", err.Error())
}
--
2.34.1

View File

@ -0,0 +1,15 @@
--- a/internal/bootstrap/config.go
+++ b/internal/bootstrap/config.go
@@ -55,11 +55,7 @@ func InitConfig() {
}
conf.Conf.TempDir = absPath
}
- err := os.RemoveAll(filepath.Join(conf.Conf.TempDir))
- if err != nil {
- log.Errorln("failed delete temp file:", err)
- }
- err = os.MkdirAll(conf.Conf.TempDir, 0700)
+ err := os.MkdirAll(conf.Conf.TempDir, 0700)
if err != nil {
log.Fatalf("create temp dir error: %+v", err)
}

View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-alist
PKG_VERSION:=1.0.4
PKG_VERSION:=1.0.5
PKG_RELEASE:=1
LUCI_TITLE:=LuCI support for alist

View File

@ -5,9 +5,17 @@ function index()
return
end
local page = entry({"admin", "nas", "alist"}, alias("admin", "nas", "alist", "basic"), _("Alist"), 20)
page.dependent = true
page.acl_depends = { "luci-app-alist" }
entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false
entry({"admin", "nas", "alist"}, cbi("alist"), _("Alist"), 20).dependent = true
entry({"admin", "nas", "alist_status"}, call("alist_status"))
entry({"admin", "nas", "alist", "basic"}, cbi("alist/basic"), _("Basic Setting"), 1).leaf = true
entry({"admin", "nas", "alist", "log"}, cbi("alist/log"), _("Logs"), 2).leaf = true
entry({"admin", "nas", "alist", "alist_status"}, call("alist_status")).leaf = true
entry({"admin", "nas", "alist", "get_log"}, call("get_log")).leaf = true
entry({"admin", "nas", "alist", "clear_log"}, call("clear_log")).leaf = true
entry({"admin", "nas", "alist", "admin_info"}, call("admin_info")).leaf = true
end
function alist_status()
@ -23,3 +31,19 @@ function alist_status()
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end
function get_log()
luci.http.write(luci.sys.exec("cat $(uci -q get alist.@alist[0].temp_dir)/alist.log"))
end
function clear_log()
luci.sys.call("cat /dev/null > $(uci -q get alist.@alist[0].temp_dir)/alist.log")
end
function admin_info()
local username = luci.sys.exec("/usr/bin/alist --conf /etc/alist/config.json password 2>&1 | tail -2 | awk 'NR==1 {print $2}'")
local password = luci.sys.exec("/usr/bin/alist --conf /etc/alist/config.json password 2>&1 | tail -2 | awk 'NR==2 {print $2}'")
luci.http.prepare_content("application/json")
luci.http.write_json({username = username, password = password})
end

View File

@ -1,53 +0,0 @@
local m, s
local sys = require "luci.sys"
if sys.call("pidof alist >/dev/null") == 0 then
local password = sys.exec("/usr/bin/alist --conf /etc/alist/config.json -password | awk '{print $3}'")
m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. " " .. translate("manage password:") .. "<font color=\"green\">" .. password .. "</font>" .. "<br/>" .. [[<a href="https://alist-doc.nn.ci/docs/driver/native" target="_blank">]] .. translate("User Manual") .. [[</a>]])
else
m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. "<br/>" .. [[<a href="https://alist-doc.nn.ci/docs/driver/native" target="_blank">]] .. translate("User Manual") .. [[</a>]])
end
m:section(SimpleSection).template = "alist_status"
s = m:section(TypedSection, "alist", translate("Global settings"))
s.addremove = false
s.anonymous = true
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o = s:option(Value, "port", translate("Port"))
o.datatype = "and(port,min(1))"
o.rmempty = false
o = s:option(Flag, "ssl", translate("Enable SSL"))
o.rmempty=false
o = s:option(Value,"ssl_cert", translate("SSL cert"), translate("SSL certificate file path"))
o:depends("ssl", "1")
o.datatype = "string"
o.rmempty = true
o = s:option(Value,"ssl_key", translate("SSL key"), translate("SSL key file path"))
o:depends("ssl", "1")
o.datatype = "string"
o.rmempty = true
s = m:section(TypedSection, "alist", translate("Cache settings"))
s.addremove = false
s.anonymous = true
o = s:option(Value, "expiration", translate("Cache invalidation time (unit: minutes)"))
o.datatype = "and(uinteger,min(1))"
o.rmempty = false
o = s:option(Value, "cleanup_interval", translate("Clear the invalidation cache interval (unit: minutes)"))
o.datatype = "and(uinteger,min(1))"
o.rmempty = false
o = s:option(Value, "temp_dir", translate("Cache directory"))
o.datatype = "string"
o.rmempty = false
return m

View File

@ -0,0 +1,45 @@
local m, s
m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. "<br/>" .. [[<a href="https://alist.nn.ci/zh/guide/drivers/local.html" target="_blank">]] .. translate("User Manual") .. [[</a>]])
m:section(SimpleSection).template = "alist/alist_status"
s = m:section(TypedSection, "alist")
s.addremove = false
s.anonymous = true
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o = s:option(Value, "port", translate("Port"))
o.datatype = "and(port,min(1))"
o.rmempty = false
o = s:option(Flag, "log", translate("Enable Logs"))
o.default = 1
o.rmempty = false
o = s:option(Flag, "ssl", translate("Enable SSL"))
o.rmempty=false
o = s:option(Value,"ssl_cert", translate("SSL cert"), translate("SSL certificate file path"))
o.datatype = "file"
o:depends("ssl", "1")
o = s:option(Value,"ssl_key", translate("SSL key"), translate("SSL key file path"))
o.datatype = "file"
o:depends("ssl", "1")
o = s:option(Flag, "allow_wan", translate("Allow Access From Internet"))
o.rmempty = false
o = s:option(Value, "temp_dir", translate("Cache directory"))
o.datatype = "string"
o.default = "/tmp/alist"
o.rmempty = false
o = s:option(Button, "admin_info", translate("View Password"))
o.rawhtml = true
o.template = "alist/admin_info"
return m

View File

@ -0,0 +1,5 @@
m = Map("alist")
m:append(Template("alist/alist_log"))
return m

View File

@ -0,0 +1,26 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function admin_info(btn)
{
btn.disabled = true;
btn.value = '<%:Reading...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "nas", "alist", "admin_info")%>',
null,
function(x,rv)
{
var tb = document.getElementById('<%=self.option%>-status');
if (tb)
{
tb.innerHTML = "<%:Username:%>" + "<font color='green'>" + rv.username + "</font>";
tb.innerHTML += "<%:Password:%>" + "<font color='green'>" + rv.password + "</font>";
}
btn.disabled = false;
btn.value = '<%:Read%>';
}
);
return false;
}
//]]></script>
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Read%>" onclick="return admin_info(this)" />
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,29 @@
<script type="text/javascript">
//<![CDATA[
function clear_log(btn) {
XHR.get('<%=url([[admin]], [[nas]], [[alist]], [[clear_log]])%>', null,
function(x, data) {
if(x && x.status == 200) {
var log_textarea = document.getElementById('log_textarea');
log_textarea.innerHTML = "";
log_textarea.scrollTop = log_textarea.scrollHeight;
}
location.reload();
}
);
}
XHR.poll(2, '<%=url([[admin]], [[nas]], [[alist]], [[get_log]])%>', null,
function(x, data) {
if(x && x.status == 200) {
var log_textarea = document.getElementById('log_textarea');
log_textarea.innerHTML = x.responseText;
log_textarea.scrollTop = log_textarea.scrollHeight;
}
}
);
//]]>
</script>
<fieldset class="cbi-section" id="_log_fieldset">
<input class="cbi-button cbi-input-remove" type="button" onclick="clear_log()" value="<%:Clear logs%>" style="margin-left: 10px; margin-top: 10px;">
<textarea id="log_textarea" class="cbi-input-textarea" style="width: calc(100% - 20px); height: 500px; margin: 10px;" data-update="change" rows="5" wrap="off" readonly="readonly"></textarea>
</fieldset>

View File

@ -9,7 +9,7 @@
%>
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url("admin/nas/alist_status")%>', null,
XHR.poll(5, '<%=url("admin/nas/alist/alist_status")%>', null,
function(x, st)
{
var tb = document.getElementById('alist_status');
@ -17,11 +17,11 @@
{
if (st.running)
{
tb.innerHTML = '<em style=\"color:green\"><b><%:The Alist service is running.%></b></em>' + "<input class=\"cbi-button-reload mar-10\" type=\"button\" value=\" <%:Click to open Alist%> \" onclick=\"window.open('<%=protocol%>" + window.location.hostname + ":" + st.port + "/')\"/>";
tb.innerHTML = '<em style=\"color:green\"><b>Alist <%:RUNNING%></b></em>' + "<input class=\"cbi-button-reload mar-10\" type=\"button\" value=\" <%:Open Web Interface%> \" onclick=\"window.open('<%=protocol%>" + window.location.hostname + ":" + st.port + "/')\"/>";
}
else
{
tb.innerHTML = '<em style=\"color:red\"><b><%:The Alist service is not running.%></b></em>';
tb.innerHTML = '<em style=\"color:red\"><b>Alist <%:NOT RUNNING%></b></em>';
}
}
}

View File

@ -4,17 +4,14 @@ msgstr "Alist 文件列表"
msgid "Running state"
msgstr "运行状态"
msgid "Click to open Alist"
msgstr "点击打开 Alist"
msgid "Open Web Interface"
msgstr "打开 Web 界面"
msgid "A file list program that supports multiple storage."
msgstr "一款支持多种存储的目录文件列表程序。"
msgid "manage password:"
msgstr "管理密码:"
msgid "Global settings"
msgstr "全局设置"
msgid "Basic Setting"
msgstr "基本设置"
msgid "Port"
msgstr "端口"
@ -34,23 +31,14 @@ msgstr "SSL 密钥"
msgid "SSL key file path"
msgstr "SSL 密钥文件路径"
msgid "Cache settings"
msgstr "缓存设置"
msgid "Cache invalidation time (unit: minutes)"
msgstr "缓存失效时间(分钟)"
msgid "Clear the invalidation cache interval (unit: minutes)"
msgstr "清理失效缓存间隔(分钟)"
msgid "Cache directory"
msgstr "缓存目录"
msgid "The Alist service is running."
msgstr "Alist 服务已启动"
msgid "RUNNING"
msgstr "运行中"
msgid "The Alist service is not running."
msgstr "Alist 服务未启动"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "Collecting data..."
msgstr "收集数据..."
@ -60,3 +48,27 @@ msgstr "网络存储"
msgid "User Manual"
msgstr "用户手册"
msgid "Allow Access From Internet"
msgstr "允许从外网访问"
msgid "Enable Logs"
msgstr "启用日志"
msgid "Clear logs"
msgstr "清空日志"
msgid "View Password"
msgstr "查看密码"
msgid "Username:"
msgstr "用户名:"
msgid "Password:"
msgstr "密码:"
msgid "Reading..."
msgstr "读取中..."
msgid "Read"
msgstr "读取"

View File

@ -1,7 +1,5 @@
config alist
option 'enabled' '0'
option 'port' '5244'
option 'expiration' '60'
option 'cleanup_interval' '120'
option 'temp_dir' '/tmp'
option 'temp_dir' '/tmp/alist'
option 'ssl' '0'

View File

@ -8,12 +8,33 @@ CONFIG=/etc/alist/config.json
get_config() {
config_get_bool enabled $1 enabled 1
config_get port $1 port 5244
config_get expiration $1 expiration 60
config_get cleanup_interval $1 cleanup_interval 120
config_get temp_dir $1 temp_dir "/tmp"
config_get log $1 log 1
config_get temp_dir $1 temp_dir "/tmp/alist"
config_get ssl $1 ssl 0
config_get ssl_cert $1 ssl_cert ""
config_get ssl_key $1 ssl_key ""
config_get allow_wan $1 allow_wan 0
config_load network
config_get lan_addr lan ipaddr "0.0.0.0"
}
set_firewall() {
if [ "$external_access" = "allow" ]; then
uci -q delete firewall.alist
uci set firewall.alist=rule
uci set firewall.alist.name="alist"
uci set firewall.alist.target="ACCEPT"
uci set firewall.alist.src="wan"
uci set firewall.alist.proto="tcp"
uci set firewall.alist.dest_port="$port"
uci set firewall.alist.enabled="1"
uci commit firewall
/etc/init.d/firewall reload >/dev/null 2>&1
elif [ "$external_access" = "deny" ]; then
uci -q delete firewall.alist
uci commit firewall
/etc/init.d/firewall reload >/dev/null 2>&1
fi
}
start_service() {
@ -26,12 +47,26 @@ start_service() {
else
SSL=false
fi
if [ "$log" -eq 1 ];then
LOG=true
else
LOG=false
fi
if [ "$allow_wan" -eq "1" ]; then
listen_addr="0.0.0.0"
external_access="allow"
else
listen_addr=$lan_addr
external_access="deny"
fi
set_firewall
cat /dev/null > $temp_dir/alist.log
cat > $CONFIG <<EOF
{"address":"0.0.0.0","port":$port,"assets":"/","database":{"type":"sqlite3","user":"","password":"","host":"","port":0,"name":"","table_prefix":"x_","db_file":"/etc/alist/data.db","ssl_mode":"disable"},"scheme":{"https":$SSL,"cert_file":"$ssl_cert","key_file":"$ssl_key"},"cache":{"expiration":$expiration,"cleanup_interval":$cleanup_interval},"temp_dir":"$temp_dir"}
{"force":false,"address":"$listen_addr","port":$port,"jwt_secret":"","cdn":"","database":{"type":"sqlite3","host":"","port":0,"user":"","password":"","name":"","db_file":"/etc/alist/data.db","table_prefix":"x_","ssl_mode":""},"scheme":{"https":$SSL,"cert_file":"$ssl_cert","key_file":"$ssl_key"},"temp_dir":"$temp_dir","log":{"enable":$LOG,"name":"$temp_dir/alist.log","max_size":10,"max_backups":5,"max_age":28,"compress":false}}
EOF
procd_open_instance alist
procd_set_param command $PROG
procd_append_param command --conf $CONFIG
procd_append_param command server --conf $CONFIG
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param respawn
@ -42,6 +77,11 @@ service_triggers() {
procd_add_reload_trigger "alist"
}
stop_service() {
external_access="deny"
set_firewall
}
reload_service() {
stop
start