update 2024-09-15 00:22:19

This commit is contained in:
kenzok8 2024-09-15 00:22:19 +08:00
parent a6cfb917e8
commit 124e7c9028
3 changed files with 112 additions and 59 deletions

View File

@ -1,9 +1,31 @@
config alist
option 'enabled' '0'
option 'port' '5244'
option 'temp_dir' '/tmp/alist'
option 'ssl' '0'
option 'token_expires_in' '48'
option 'max_connections' '0'
option 'site_url' ''
option 'delayed_start' '0'
option enabled '0'
option port '5244'
option delayed_start '0'
option allow_wan '0'
option force '1'
option token_expires_in '48'
option max_connections '0'
option tls_insecure_skip_verify '1'
option data_dir '/etc/alist'
option temp_dir '/tmp/alist'
option log '1'
option log_max_size '10'
option log_max_backups '5'
option log_max_age '28'
option log_compress '0'
option database_type 'sqlite3'
option ssl '0'
option download_workers '5'
option download_max_retry '1'
option transfer_workers '5'
option transfer_max_retry '2'
option upload_workers '5'
option upload_max_retry '0'
option copy_workers '5'
option copy_max_retry '2'
option cors_allow_origins '*'
option cors_allow_methods '*'
option cors_allow_headers '*'
option s3 '0'

View File

@ -10,21 +10,34 @@ LOG_FILE=/var/log/alist.log
get_config() {
config_get_bool enabled $1 enabled 1
config_get port $1 port 5244
config_get log $1 log 1
config_get site_url $1 site_url ""
config_get data_dir $1 data_dir "/etc/alist"
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 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
# mysql
config_get mysql $1 mysql 0
config_get mysql_type $1 mysql_type "mysql"
config_get force $1 force 1
config_get site_url $1 site_url ""
config_get cdn $1 cdn ""
config_get jwt_secret $1 jwt_secret ""
config_get data_dir $1 data_dir "/etc/alist"
config_get temp_dir $1 temp_dir "/tmp/alist"
config_get token_expires_in $1 token_expires_in 48
config_get max_connections $1 max_connections 0
config_get tls_insecure_skip_verify $1 tls_insecure_skip_verify 1
# log
config_get log $1 log 1
config_get log_max_size $1 log_max_size 10
config_get log_max_backups $1 log_max_backups 5
config_get log_max_age $1 log_max_age 28
config_get log_compress $1 log_compress 0
# scheme
config_get ssl $1 ssl 0
config_get force_https $1 force_https 0
config_get ssl_cert $1 ssl_cert ""
config_get ssl_key $1 ssl_key ""
# database
config_get database_type $1 database_type "sqlite3"
config_get mysql_host $1 mysql_host ""
config_get mysql_port $1 mysql_port "3306"
config_get mysql_username $1 mysql_username ""
@ -34,6 +47,26 @@ get_config() {
config_get mysql_ssl_mode $1 mysql_ssl_mode ""
config_get mysql_dsn $1 mysql_dsn ""
# tasks
config_get download_workers $1 download_workers 5
config_get download_max_retry $1 download_max_retry 1
config_get transfer_workers $1 transfer_workers 5
config_get transfer_max_retry $1 transfer_max_retry 2
config_get upload_workers $1 upload_workers 5
config_get upload_max_retry $1 upload_max_retry 0
config_get copy_workers $1 copy_workers 5
config_get copy_max_retry $1 copy_max_retry 2
# cors
config_get cors_allow_origins $1 cors_allow_origins '*'
config_get cors_allow_methods $1 cors_allow_methods '*'
config_get cors_allow_headers $1 cors_allow_headers '*'
# s3
config_get s3 $1 s3 0
config_get s3_port $1 s3_port 5246
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
@ -41,6 +74,11 @@ get_config() {
else
lan_addr=${lan_addr%%/*}
fi
# init jwt_secret
[ -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 commit alist
}
set_firewall() {
@ -66,7 +104,7 @@ start_service() {
config_load alist
config_foreach get_config alist
[ $enabled -ne 1 ] && return 1
mkdir -p $temp_dir $data_dir
mkdir -p "$temp_dir" "$data_dir"
[ "$ssl" -eq 1 ] && https_port=$port http_port="-1" || https_port="-1" http_port=$port
if [ -e /proc/uptime ]; then
[ $(awk -F. '{print $1}' /proc/uptime) -lt "120" ] && delayed_start=$delayed_start || delayed_start=0
@ -81,23 +119,20 @@ start_service() {
external_access="deny"
fi
# mysql
[ "$mysql" -eq 1 ] && database=$mysql_type || database=sqlite3
set_firewall
true > $LOG_FILE
> $LOG_FILE
# init config
json_init
json_add_boolean "force" "1"
json_add_boolean "force" "$force"
json_add_string "site_url" "$site_url"
json_add_string "cdn" ""
json_add_string "jwt_secret" ""
json_add_string "cdn" "$cdn"
json_add_string "jwt_secret" "$jwt_secret"
json_add_int "token_expires_in" "$token_expires_in"
# database
json_add_object 'database'
json_add_string "type" "$database"
json_add_string "type" "$database_type"
json_add_string "host" "$mysql_host"
json_add_int "port" "$mysql_port"
json_add_string "user" "$mysql_username"
@ -121,7 +156,7 @@ start_service() {
json_add_string "address" "$listen_addr"
json_add_int "http_port" "$http_port"
json_add_int "https_port" "$https_port"
json_add_boolean "force_https" "0"
json_add_boolean "force_https" "$force_https"
json_add_string "cert_file" "$ssl_cert"
json_add_string "key_file" "$ssl_key"
json_add_string "unix_file" ""
@ -136,61 +171,63 @@ start_service() {
json_add_object "log"
json_add_boolean "enable" "$log"
json_add_string "name" "$LOG_FILE"
json_add_int "max_size" "10"
json_add_int "max_backups" "5"
json_add_int "max_age" "28"
json_add_boolean "compress" "0"
json_add_int "max_size" "$log_max_size"
json_add_int "max_backups" "$log_max_backups"
json_add_int "max_age" "$log_max_age"
json_add_boolean "compress" "$log_compress"
json_close_object
json_add_int "delayed_start" "$delayed_start"
json_add_int "max_connections" "$max_connections"
json_add_boolean "tls_insecure_skip_verify" "1"
json_add_boolean "tls_insecure_skip_verify" "$tls_insecure_skip_verify"
# tasks
json_add_object "tasks"
json_add_object "download"
json_add_int "workers" "5"
json_add_int "max_retry" "1"
json_add_int "workers" "$download_workers"
json_add_int "max_retry" "$download_max_retry"
json_close_object
json_add_object "transfer"
json_add_int "workers" "5"
json_add_int "max_retry" "2"
json_add_int "workers" "$transfer_workers"
json_add_int "max_retry" "$transfer_max_retry"
json_close_object
json_add_object "upload"
json_add_int "workers" "5"
json_add_int "max_retry" "0"
json_add_int "workers" "$upload_workers"
json_add_int "max_retry" "$upload_max_retry"
json_close_object
json_add_object "copy"
json_add_int "workers" "5"
json_add_int "max_retry" "2"
json_add_int "workers" "$copy_workers"
json_add_int "max_retry" "$copy_max_retry"
json_close_object
json_close_object
# cors
json_add_object "cors"
json_add_array "allow_origins"
json_add_string "" "*"
json_add_string "" "$cors_allow_origins"
json_close_array
json_add_array "allow_methods"
json_add_string "" "*"
json_add_string "" "$cors_allow_methods"
json_close_array
json_add_array "allow_headers"
json_add_string "" "*"
json_add_string "" "$cors_allow_headers"
json_close_array
json_close_object
# s3
json_add_object "s3"
json_add_boolean "enable" "0"
json_add_int "port" "5246"
json_add_boolean "ssl" "0"
json_add_boolean "enable" "$s3"
json_add_int "port" "$s3_port"
json_add_boolean "ssl" "$s3_ssl"
json_close_object
json_dump > $data_dir/config.json
json_dump > "$data_dir/config.json"
procd_open_instance alist
procd_set_param command $PROG
procd_append_param command server --data $data_dir
procd_append_param command server
procd_append_param command --data "$data_dir"
procd_set_param file "$data_dir/config.json"
procd_set_param stdout 0
procd_set_param stderr 0
procd_set_param respawn
@ -199,12 +236,6 @@ start_service() {
procd_close_instance alist
}
reload_service() {
stop
sleep 3
start
}
service_triggers() {
procd_add_reload_trigger "alist"
}

View File

@ -21,13 +21,13 @@ define Download/geoip
HASH:=4ec83c46f84b3efb9856903e7c10d6c21f6515b9e656575c483dcf2a3d80f916
endef
GEOSITE_VER:=20240914040647
GEOSITE_VER:=20240914091803
GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
define Download/geosite
URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
URL_FILE:=dlc.dat
FILE:=$(GEOSITE_FILE)
HASH:=14bc0b427be0c6771fe868a9005cd32f56f7d1bd35b123b51e7669cd6c050f87
HASH:=c171f61d3ba8e0dcf31a9548e9fd928a9416e064ad9417664eadda8d25eb6ad9
endef
GEOSITE_IRAN_VER:=202409090033