xray_docker/install.sh
2025-11-23 14:07:28 +08:00

94 lines
2.3 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
restart_docker(){
echo "正在重启容器..."
docker-compose -f ./docker-compose.yml down
docker-compose -f ./docker-compose.yml up -d
}
change_reality_dest(){
local config_dir="./conf"
if [ ! -e "$config_dir/config.json" ] || [ ! -s "$config_dir/config.json" ];then
echo "请先'创建配置'"
exit 0
fi
source ./bin/utils/jq_util.sh
# 输入dest值
local old_dest=$(jq -r '.inbounds[0].streamSettings.realitySettings.dest' "$config_dir/config.json")
local dest
read -p "请输入新的dest地址[当前地址: $old_dest]: " dest
local domain=$(echo "$dest" | awk -F ':' '{print $1}')
sed -i "s/你的reality_dest/$domain/g" "$config_dir/config.json"
echo "配置文件修改realty_dest成功"
echo "新的dest地址为: $dest"
echo "新的serverNames数组为: [\"$domain\"]"
}
main(){
# 显示菜单
echo "请选择一个操作:"
echo "0. 创建配置 / 重置配置"
echo "1. 启动容器"
echo "2. 查看分享链接"
echo "3. 停止容器"
echo "4. 更新镜像"
echo "5. 修改端口"
echo "6. 修改Reality目标域名"
echo "0. 退出"
# 读取用户选择
read -p "输入您的选择: " choice
# 根据用户选择执行相应的操作
case $choice in
0)
# 创建配置 / 重置配置
bash ./bin/create_config.sh
;;
1)
# 启动容器
echo "启动容器.."
bash ./bin/run.sh
;;
2)
# 查看分享链接
echo "查看分享链接.."
bash ./bin/print_share_link.sh
;;
3)
# 停止容器
echo "正在停止容器.."
docker-compose -f ./docker-compose.yml down
;;
4)
# 更新镜像
bash ./bin/update_docker_images.sh
;;
5)
# 修改端口
bash ./bin/update_port.sh
restart_docker
;;
6)
# 修改Reality目标域名
change_reality_dest
restart_docker
;;
0)
# 退出
echo "退出程序."
;;
*)
echo "无效的选择, 请重新选择."
;;
esac
}
main