函数里的变量, 改为局部变量

This commit is contained in:
Olia Lisa
2026-01-15 14:02:40 +08:00
parent 6ef7ad5744
commit f85766154c
5 changed files with 8 additions and 5 deletions
+4 -3
View File
@@ -75,7 +75,7 @@ install_package() {
fi
echo "安装 $package_name..."
package_manager=$(get_package_manager)
local package_manager=$(get_package_manager)
if [ "$package_manager" == "apt-get" ]; then
sudo apt-get update
sudo apt-get install -y "$package_name"
@@ -98,7 +98,7 @@ check_config(){
fi
# 如果配置未初始化
uuid=$(jq -r '.inbounds[0].settings.clients[0].id' "$config_file")
local uuid=$(jq -r '.inbounds[0].settings.clients[0].id' "$config_file")
if [ "$uuid" = "你的UUID" ] || [ -z "$uuid" ]; then
echo "请先'创建配置'"
exit 1
@@ -117,6 +117,7 @@ restart_docker() {
# 如果容器未运行,提示启动
local running_count=$(docker-compose -f $script_dir/../docker-compose.yml ps -q | wc -l)
if [ "$running_count" -eq 0 ]; then
local choice
read -p "容器未启动,是否启动容器?(y/n): " choice
case "$choice" in
Y|y)
@@ -133,4 +134,4 @@ restart_docker() {
echo "正在重启容器..."
docker-compose -f $script_dir/../docker-compose.yml down
docker-compose -f $script_dir/../docker-compose.yml up -d
}
}