update
This commit is contained in:
parent
66dd349643
commit
0004e13e1a
@ -3,6 +3,9 @@
|
|||||||
init() {
|
init() {
|
||||||
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
|
||||||
|
# 设置端口
|
||||||
|
bash "$script_dir/update_port.sh"
|
||||||
|
|
||||||
# 更新密码
|
# 更新密码
|
||||||
bash "$script_dir/update_password.sh"
|
bash "$script_dir/update_password.sh"
|
||||||
|
|
||||||
|
|||||||
@ -44,29 +44,14 @@ find_free_port() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# 修改端口的函数
|
|
||||||
change_port(){
|
change_port(){
|
||||||
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
||||||
local config_dir=$(readlink -f "$script_dir/../")
|
local config_dir=$(readlink -f "$script_dir/../")
|
||||||
source "$script_dir/utils/jq_util.sh"
|
source "$script_dir/utils/jq_util.sh"
|
||||||
|
|
||||||
local old_port=$(jq -r '.listen' "$config_dir/config.json" | awk -F : '{print $2}')
|
local port=$(find_free_port)
|
||||||
local port
|
|
||||||
read -p "请输入新的端口[当前端口: $old_port]: " port
|
|
||||||
|
|
||||||
# 如果输入端口为空, 查找空闲端口
|
|
||||||
if [[ -z "$port" ]]; then
|
|
||||||
port=$(find_free_port)
|
|
||||||
if [[ -z "$port" ]]; then
|
|
||||||
echo "未能找到可用端口!" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
echo "未输入端口,自动分配可用端口: $port"
|
|
||||||
fi
|
|
||||||
|
|
||||||
modify_json_file "$config_dir/config.json" ".listen" ":$port"
|
modify_json_file "$config_dir/config.json" ".listen" ":$port"
|
||||||
|
echo "设置端口成功"
|
||||||
echo "端口修改成功!新端口为: $port"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
change_port
|
change_port
|
||||||
Loading…
Reference in New Issue
Block a user