update
This commit is contained in:
@@ -9,7 +9,7 @@ create_acme_tls_config() {
|
||||
cp "$config_dir/template/tls_cert_config.json" "$config_file"
|
||||
|
||||
# 设置端口
|
||||
update_port
|
||||
update_port $(find_free_port)
|
||||
|
||||
# 设置密码
|
||||
update_password
|
||||
@@ -53,7 +53,7 @@ create_self_tls_config() {
|
||||
cp "$script_dir/../config/template/self_cert_config.json" "$script_dir/../config/config.json"
|
||||
|
||||
# 设置端口
|
||||
update_port
|
||||
update_port $(find_free_port)
|
||||
|
||||
# 设置密码
|
||||
update_password
|
||||
|
||||
+24
-1
@@ -161,9 +161,32 @@ update_port(){
|
||||
|
||||
local config_dir="$script_dir/../config"
|
||||
|
||||
local port=$(find_free_port)
|
||||
local port=$1
|
||||
# 如果没有提供端口参数,则自动查找一个随机空闲端口
|
||||
if [[ -z "$port" ]]; then
|
||||
port=$(find_free_port)
|
||||
fi
|
||||
|
||||
modify_json_file "$config_dir/config.json" ".inbounds[0].listen_port" "$port"
|
||||
port_manage allow "$port"
|
||||
echo "设置端口成功"
|
||||
}
|
||||
|
||||
# 通过交互方式更新端口
|
||||
ask_update_port(){
|
||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
local config_file="$script_dir/../config/config.json"
|
||||
|
||||
local current_port=$(get_listen_port)
|
||||
local new_port=$(ask_update "请输入新的端口号" "$current_port")
|
||||
update_port "$new_port"
|
||||
}
|
||||
|
||||
|
||||
get_listen_port(){
|
||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
local config_file="$script_dir/../config/config.json"
|
||||
|
||||
local port=$(jq -r ".inbounds[0].listen_port" "$config_file")
|
||||
echo $port
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user