mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-02 15:33:56 +08:00
✨ Sync 2026-08-13 22:19:05
This commit is contained in:
1 parent
b3d043e5e5
commit
839d09ae31
110 files changed
+87700
-7
No files matched your search
@@ -0,0 +1,109 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
changed=0
|
||||
init_section=
|
||||
package=frpc
|
||||
|
||||
find_init_section() {
|
||||
[ -z "$init_section" ] && init_section="$1"
|
||||
return 0
|
||||
}
|
||||
|
||||
set_if_empty() {
|
||||
local section="$1"
|
||||
local option="$2"
|
||||
local value="$3"
|
||||
local cur
|
||||
|
||||
config_get cur "$section" "$option"
|
||||
|
||||
if [ -z "$cur" ]; then
|
||||
uci_set "$package" "$section" "$option" "$value"
|
||||
changed=1
|
||||
fi
|
||||
}
|
||||
|
||||
copy_if_empty() {
|
||||
local section="$1"
|
||||
local old_option="$2"
|
||||
local new_option="$3"
|
||||
local value
|
||||
|
||||
config_get value "$section" "$old_option"
|
||||
[ -n "$value" ] || return 0
|
||||
|
||||
set_if_empty "$section" "$new_option" "$value"
|
||||
}
|
||||
|
||||
upgrade_common() {
|
||||
local section="$1"
|
||||
local dashboard_tls_mode
|
||||
|
||||
[ "$section" = "common" ] || return 0
|
||||
|
||||
set_if_empty "$section" server_addr 127.0.0.1
|
||||
set_if_empty "$section" server_port 7000
|
||||
set_if_empty "$section" authentication_method token
|
||||
set_if_empty "$section" login_fail_exit true
|
||||
set_if_empty "$section" protocol tcp
|
||||
set_if_empty "$section" wire_protocol v1
|
||||
set_if_empty "$section" tcp_mux true
|
||||
set_if_empty "$section" tls_enable true
|
||||
set_if_empty "$section" disable_custom_tls_first_byte true
|
||||
|
||||
config_get dashboard_tls_mode "$section" dashboard_tls_mode
|
||||
if [ -n "$dashboard_tls_mode" ]; then
|
||||
set_if_empty "$section" admin_tls_enable "$dashboard_tls_mode"
|
||||
else
|
||||
set_if_empty "$section" admin_tls_enable false
|
||||
fi
|
||||
|
||||
copy_if_empty "$section" dashboard_addr admin_addr
|
||||
copy_if_empty "$section" dashboard_port admin_port
|
||||
copy_if_empty "$section" dashboard_user admin_user
|
||||
copy_if_empty "$section" dashboard_pwd admin_pwd
|
||||
copy_if_empty "$section" dashboard_tls_cert_file admin_tls_cert_file
|
||||
copy_if_empty "$section" dashboard_tls_key_file admin_tls_key_file
|
||||
|
||||
set_if_empty "$section" pprof_enable false
|
||||
set_if_empty "$section" log_file console
|
||||
set_if_empty "$section" log_level info
|
||||
set_if_empty "$section" log_max_days 3
|
||||
}
|
||||
|
||||
upgrade_init() {
|
||||
if [ -z "$init_section" ]; then
|
||||
init_section="$(uci add "$package" init)" || return 0
|
||||
changed=1
|
||||
fi
|
||||
|
||||
set_if_empty "$init_section" stdout 1
|
||||
set_if_empty "$init_section" stderr 1
|
||||
set_if_empty "$init_section" respawn 1
|
||||
}
|
||||
|
||||
upgrade_proxy_name() {
|
||||
local section="$1"
|
||||
local name
|
||||
|
||||
[ "$section" != "common" ] || return 0
|
||||
|
||||
config_get name "$section" name
|
||||
|
||||
if [ -z "$name" ]; then
|
||||
uci_set "$package" "$section" name "$section"
|
||||
changed=1
|
||||
fi
|
||||
}
|
||||
|
||||
config_load "$package"
|
||||
config_foreach find_init_section init
|
||||
upgrade_init
|
||||
config_foreach upgrade_common conf
|
||||
config_foreach upgrade_proxy_name conf
|
||||
|
||||
[ "$changed" -eq 1 ] && uci_commit "$package"
|
||||
|
||||
exit 0
|
||||
Reference in new issue
Block a user