luci-app-alist: add login validity setting item

This commit is contained in:
sbwml 2022-11-12 00:04:32 +08:00
parent 7ea57fa8df
commit eca2b61783
5 changed files with 14 additions and 12 deletions

View File

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

View File

@ -33,6 +33,11 @@ o:depends("ssl", "1")
o = s:option(Flag, "allow_wan", translate("Allow Access From Internet"))
o.rmempty = false
o = s:option(Value, "token_expires_in", translate("Login Validity Period (hours)"))
o.datatype = "and(uinteger,min(0))"
o.default = "48"
o.rmempty = false
o = s:option(Value, "temp_dir", translate("Cache directory"))
o.datatype = "string"
o.default = "/tmp/alist"

View File

@ -72,3 +72,6 @@ msgstr "读取中..."
msgid "Read"
msgstr "读取"
msgid "Login Validity Period (hours)"
msgstr "登录有效期(小时)"

View File

@ -3,3 +3,4 @@ config alist
option 'port' '5244'
option 'temp_dir' '/tmp/alist'
option 'ssl' '0'
option 'token_expires_in' '48'

View File

@ -13,6 +13,7 @@ get_config() {
config_get ssl $1 ssl 0
config_get ssl_cert $1 ssl_cert ""
config_get ssl_key $1 ssl_key ""
config_get token_expires_in $1 token_expires_in 48
config_get allow_wan $1 allow_wan 0
config_load network
config_get lan_addr lan ipaddr "0.0.0.0"
@ -42,16 +43,8 @@ start_service() {
config_foreach get_config alist
[ $enabled != 1 ] && return 1
mkdir -p $temp_dir
if [ "$ssl" -eq 1 ];then
SSL=true
else
SSL=false
fi
if [ "$log" -eq 1 ];then
LOG=true
else
LOG=false
fi
[ "$ssl" -eq 1 ] && SSL=true || SSL=false
[ "$log" -eq 1 ] && LOG=true || LOG=false
if [ "$allow_wan" -eq "1" ]; then
listen_addr="0.0.0.0"
external_access="allow"
@ -62,7 +55,7 @@ start_service() {
set_firewall
cat /dev/null > $temp_dir/alist.log
cat > $CONFIG_DIR/config.json <<EOF
{"force":false,"address":"$listen_addr","port":$port,"cdn":"","jwt_secret":"","token_expires_in":48,"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}}
{"force":false,"address":"$listen_addr","port":$port,"cdn":"","jwt_secret":"","token_expires_in":$token_expires_in,"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