🎨 Sync 2024-11-13 00:32

This commit is contained in:
github-actions[bot] 2024-11-13 00:32:06 +08:00
parent da69f13b81
commit 1894b1a4a9
6 changed files with 34 additions and 31 deletions

View File

@ -5,7 +5,6 @@
START=99 START=99
USE_PROCD=1 USE_PROCD=1
PROG=/usr/bin/alist PROG=/usr/bin/alist
LOG_FILE=/var/log/alist.log
get_config() { get_config() {
config_get_bool enabled $1 enabled 1 config_get_bool enabled $1 enabled 1
@ -25,6 +24,7 @@ get_config() {
# log # log
config_get log $1 log 1 config_get log $1 log 1
config_get log_path $1 log_path '/var/log/alist.log'
config_get log_max_size $1 log_max_size 10 config_get log_max_size $1 log_max_size 10
config_get log_max_backups $1 log_max_backups 5 config_get log_max_backups $1 log_max_backups 5
config_get log_max_age $1 log_max_age 28 config_get log_max_age $1 log_max_age 28
@ -67,14 +67,6 @@ get_config() {
config_get s3_port $1 s3_port 5246 config_get s3_port $1 s3_port 5246
config_get s3_ssl $1 s3_ssl 0 config_get s3_ssl $1 s3_ssl 0
config_load network
config_get lan_addr lan ipaddr "0.0.0.0"
if echo "${lan_addr}" | grep -Fq ' '; then
lan_addr="0.0.0.0"
else
lan_addr=${lan_addr%%/*}
fi
# init jwt_secret # init jwt_secret
[ -z "$jwt_secret" ] && jwt_secret=$(tr -cd "a-zA-Z0-9" < "/dev/urandom" | head -c16) [ -z "$jwt_secret" ] && jwt_secret=$(tr -cd "a-zA-Z0-9" < "/dev/urandom" | head -c16)
uci -q set alist.@alist[0].jwt_secret="$jwt_secret" uci -q set alist.@alist[0].jwt_secret="$jwt_secret"
@ -111,16 +103,11 @@ start_service() {
else else
delayed_start=$delayed_start delayed_start=$delayed_start
fi fi
if [ "$allow_wan" -eq "1" ]; then
listen_addr="0.0.0.0" [ "$allow_wan" -eq "1" ] && external_access="allow" || external_access="deny"
external_access="allow"
else
listen_addr=$lan_addr
external_access="deny"
fi
set_firewall set_firewall
> $LOG_FILE > "$log_path"
# init config # init config
json_init json_init
@ -153,7 +140,7 @@ start_service() {
# scheme # scheme
json_add_object "scheme" json_add_object "scheme"
json_add_string "address" "$listen_addr" json_add_string "address" "0.0.0.0"
json_add_int "http_port" "$http_port" json_add_int "http_port" "$http_port"
json_add_int "https_port" "$https_port" json_add_int "https_port" "$https_port"
json_add_boolean "force_https" "$force_https" json_add_boolean "force_https" "$force_https"
@ -170,7 +157,7 @@ start_service() {
# log # log
json_add_object "log" json_add_object "log"
json_add_boolean "enable" "$log" json_add_boolean "enable" "$log"
json_add_string "name" "$LOG_FILE" json_add_string "name" "$log_path"
json_add_int "max_size" "$log_max_size" json_add_int "max_size" "$log_max_size"
json_add_int "max_backups" "$log_max_backups" json_add_int "max_backups" "$log_max_backups"
json_add_int "max_age" "$log_max_age" json_add_int "max_age" "$log_max_age"

View File

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

View File

@ -113,7 +113,7 @@ return view.extend({
o.default = '0'; o.default = '0';
o.rmempty = false; o.rmempty = false;
o = s.option(form.Flag, 'allow_wan', _('Allow Access From Internet')); o = s.option(form.Flag, 'allow_wan', _('Open firewall port'));
o.rmempty = false; o.rmempty = false;
o = s.option(form.Button, '_newpassword', _('Reset Password'), o = s.option(form.Button, '_newpassword', _('Reset Password'),
@ -170,7 +170,12 @@ return view.extend({
o.default = 1; o.default = 1;
o.rmempty = false; o.rmempty = false;
o = s.option(form.Value, 'log_max_size', _('Max Size')); o = s.option(form.Value, 'log_path', _('Log path'));
o.default = '/var/log/alist.log';
o.rmempty = false;
o.depends('log', '1');
o = s.option(form.Value, 'log_max_size', _('Max Size (MB)'));
o.datatype = 'uinteger'; o.datatype = 'uinteger';
o.default = '10'; o.default = '10';
o.rmempty = false; o.rmempty = false;

View File

@ -2,15 +2,21 @@
'require dom'; 'require dom';
'require fs'; 'require fs';
'require poll'; 'require poll';
'require uci';
'require view'; 'require view';
var scrollPosition = 0; var scrollPosition = 0;
var userScrolled = false; var userScrolled = false;
var logTextarea; var logTextarea;
var log_path;
uci.load('alist').then(function() {
log_path = uci.get('alist', '@alist[0]', 'log_path') || '/var/log/alist.log';
});
function pollLog() { function pollLog() {
return Promise.all([ return Promise.all([
fs.read_direct('/var/log/alist.log', 'text').then(function (res) { fs.read_direct(log_path, 'text').then(function (res) {
return res.trim().split(/\n/).join('\n').replace(/\u001b\[33mWARN\u001b\[0m/g, '').replace(/\u001b\[36mINFO\u001b\[0m/g, '').replace(/\u001b\[31mERRO\u001b\[0m/g, ''); return res.trim().split(/\n/).join('\n').replace(/\u001b\[33mWARN\u001b\[0m/g, '').replace(/\u001b\[36mINFO\u001b\[0m/g, '').replace(/\u001b\[31mERRO\u001b\[0m/g, '');
}), }),
]).then(function (data) { ]).then(function (data) {
@ -26,7 +32,7 @@ function pollLog() {
return view.extend({ return view.extend({
handleCleanLogs: function () { handleCleanLogs: function () {
return fs.write('/var/log/alist.log', '') return fs.write(log_path, '')
.catch(function (e) { ui.addNotification(null, E('p', e.message)) }); .catch(function (e) { ui.addNotification(null, E('p', e.message)) });
}, },
@ -45,7 +51,9 @@ return view.extend({
var log_textarea_wrapper = E('div', { 'id': 'log_textarea' }, logTextarea); var log_textarea_wrapper = E('div', { 'id': 'log_textarea' }, logTextarea);
poll.add(pollLog); setTimeout(function () {
poll.add(pollLog);
}, 100);
var clear_logs_button = E('input', { 'class': 'btn cbi-button-action', 'type': 'button', 'style': 'margin-left: 10px; margin-top: 10px;', 'value': _('Clear logs') }); var clear_logs_button = E('input', { 'class': 'btn cbi-button-action', 'type': 'button', 'style': 'margin-left: 10px; margin-top: 10px;', 'value': _('Clear logs') });
clear_logs_button.addEventListener('click', this.handleCleanLogs.bind(this)); clear_logs_button.addEventListener('click', this.handleCleanLogs.bind(this));

View File

@ -74,14 +74,17 @@ msgstr "网络存储"
msgid "User Manual" msgid "User Manual"
msgstr "用户手册" msgstr "用户手册"
msgid "Allow Access From Internet" msgid "Open firewall port"
msgstr "允许从外网访问" msgstr "打开防火墙端口"
msgid "Enable Logs" msgid "Enable Logs"
msgstr "启用日志" msgstr "启用日志"
msgid "Max Size" msgid "Log path"
msgstr "日志文大小" msgstr "日志文件路径"
msgid "Max Size (MB)"
msgstr "日志文件大小MB"
msgid "Max backups" msgid "Max backups"
msgstr "日志备份数量" msgstr "日志备份数量"

View File

@ -4,7 +4,7 @@
"read": { "read": {
"file": { "file": {
"/usr/bin/alist": [ "exec" ], "/usr/bin/alist": [ "exec" ],
"/var/log/alist.log": [ "read" ] "/*": [ "read" ]
}, },
"ubus": { "ubus": {
"service": [ "list" ] "service": [ "list" ]
@ -13,7 +13,7 @@
}, },
"write": { "write": {
"file": { "file": {
"/var/log/alist.log": [ "write" ] "/*": [ "write" ]
}, },
"uci": [ "alist" ] "uci": [ "alist" ]
} }