重构代码,统一项目入口为install.sh
This commit is contained in:
+10
-14
@@ -7,16 +7,16 @@ create_reality_config(){
|
||||
cp "$config_dir/template/reality_config.json" "$config_dir/config.json"
|
||||
|
||||
# 生成uui, 写入到config.json文件
|
||||
bash $script_dir/update_uuid.sh
|
||||
update_uuid
|
||||
|
||||
# 生成密钥对, 修改config.json中的密钥属性
|
||||
bash $script_dir/update_key.sh
|
||||
update_key
|
||||
|
||||
# 设置端口
|
||||
bash $script_dir/update_port.sh
|
||||
update_port
|
||||
|
||||
# 设置realty_dest目标域名
|
||||
bash $script_dir/update_reality_dest.sh
|
||||
update_reality_dest
|
||||
|
||||
green "成功创建配置"
|
||||
}
|
||||
@@ -28,27 +28,27 @@ create_xhttp_reality_config(){
|
||||
cp "$config_dir/template/xhttp_reality_config.json" "$config_dir/config.json"
|
||||
|
||||
# 生成uui, 写入到config.json文件
|
||||
bash $script_dir/update_uuid.sh
|
||||
update_uuid
|
||||
|
||||
# 生成密钥对, 修改config.json中的密钥属性
|
||||
bash $script_dir/update_key.sh
|
||||
update_key
|
||||
|
||||
# 生成xhttp_path, 写入到config.json文件
|
||||
bash $script_dir/update_xhttp_path.sh
|
||||
update_xhttp_path
|
||||
|
||||
# 设置realty_dest目标域名
|
||||
bash $script_dir/update_reality_dest.sh
|
||||
update_reality_dest
|
||||
|
||||
# 设置端口
|
||||
bash $script_dir/update_port.sh
|
||||
update_port
|
||||
|
||||
green "成功创建配置"
|
||||
}
|
||||
|
||||
|
||||
|
||||
create_config(){
|
||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件绝对路径
|
||||
source "$script_dir/utils/base.sh"
|
||||
# 检查jq是否安装
|
||||
check_jq
|
||||
|
||||
@@ -73,7 +73,3 @@ create_config(){
|
||||
*) echo "无效选择,退出" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
create_config
|
||||
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ print_share_link(){
|
||||
local config_dir=$(readlink -f "$script_dir/../conf") # xray配置文件绝对路径
|
||||
|
||||
# 检查 jq 是否安装
|
||||
source $script_dir/utils/base.sh
|
||||
check_jq
|
||||
|
||||
local xhttp_path=$(jq -r ".inbounds[0].streamSettings.xhttpSettings.path" $config_dir/config.json)
|
||||
@@ -81,5 +80,3 @@ print_share_link(){
|
||||
print_xhttp_reality_share_link
|
||||
fi
|
||||
}
|
||||
|
||||
print_share_link
|
||||
|
||||
@@ -12,6 +12,3 @@ run(){
|
||||
|
||||
docker-compose -f "$docker_compose_file" up -d # 启动容器
|
||||
}
|
||||
|
||||
|
||||
run
|
||||
|
||||
@@ -23,5 +23,3 @@ update_docker_images(){
|
||||
echo "正在启动容器.."
|
||||
docker-compose -f $docker_compose_file up -d
|
||||
}
|
||||
|
||||
update_docker_images
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
update_key(){
|
||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件绝对路径
|
||||
local config_dir="$script_dir/../conf"
|
||||
source $script_dir/utils/jq_util.sh
|
||||
|
||||
# 使用docker运行xray镜像生成密钥文件
|
||||
docker run --rm teddysun/xray:latest /usr/bin/xray x25519 > $config_dir/key.txt
|
||||
@@ -17,6 +16,3 @@ update_key(){
|
||||
echo "生成和设置密钥成功."
|
||||
|
||||
}
|
||||
|
||||
|
||||
update_key
|
||||
+1
-4
@@ -77,11 +77,8 @@ find_free_port() {
|
||||
update_port(){
|
||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹路径
|
||||
local config_file="$script_dir/../conf/config.json"
|
||||
source "$script_dir/utils/jq_util.sh"
|
||||
|
||||
|
||||
local port=$(find_free_port)
|
||||
modify_json_file "$config_file" ".inbounds[0].port" "$port"
|
||||
echo "设置端口成功"
|
||||
}
|
||||
|
||||
update_port
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
update_reality_dest(){
|
||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
local config_dir="$script_dir/../conf"
|
||||
source $script_dir/utils/jq_util.sh
|
||||
|
||||
# 获取当前dest值
|
||||
local old_dest=$(jq -r '.inbounds[0].streamSettings.realitySettings.dest' "$config_dir/config.json")
|
||||
@@ -33,5 +32,3 @@ update_reality_dest(){
|
||||
|
||||
echo "修改realty_dest成功"
|
||||
}
|
||||
|
||||
update_reality_dest
|
||||
|
||||
@@ -5,8 +5,6 @@ update_uuid(){
|
||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件绝对路径
|
||||
local config_dir="$script_dir/../conf"
|
||||
|
||||
source $script_dir/utils/jq_util.sh
|
||||
|
||||
# 生成 UUID
|
||||
local uuid=$(cat /proc/sys/kernel/random/uuid)
|
||||
|
||||
@@ -15,5 +13,3 @@ update_uuid(){
|
||||
|
||||
echo "设置UUID成功."
|
||||
}
|
||||
|
||||
update_uuid
|
||||
|
||||
@@ -4,7 +4,6 @@ update_xhttp_path(){
|
||||
|
||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件绝对路径
|
||||
local config_dir="$script_dir/../conf"
|
||||
source $script_dir/utils/jq_util.sh
|
||||
|
||||
local path_length="$(( RANDOM % 4 + 8 ))"
|
||||
local xhttp_path="/"$(docker run --rm teddysun/xray:latest xray uuid | tr -d '-' | cut -c 1-$path_length)
|
||||
@@ -14,5 +13,3 @@ update_xhttp_path(){
|
||||
|
||||
echo "设置xhttp_path成功"
|
||||
}
|
||||
|
||||
update_xhttp_path
|
||||
|
||||
+25
-1
@@ -109,4 +109,28 @@ check_config(){
|
||||
echo "配置文件不是有效的JSON格式, 请重新生成配置文件."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
restart_docker() {
|
||||
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../" # 脚本文件夹绝对路径
|
||||
|
||||
# 如果容器未运行,提示启动
|
||||
local running_count=$(docker-compose -f $script_dir/../docker-compose.yml ps -q | wc -l)
|
||||
if [ "$running_count" -eq 0 ]; then
|
||||
read -p "容器未启动,是否启动容器?(y/n): " choice
|
||||
case "$choice" in
|
||||
Y|y)
|
||||
docker-compose -f $script_dir/../docker-compose.yml up -d
|
||||
return
|
||||
;;
|
||||
*)
|
||||
echo "已取消启动"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "正在重启容器..."
|
||||
docker-compose -f $script_dir/../docker-compose.yml down
|
||||
docker-compose -f $script_dir/../docker-compose.yml up -d
|
||||
}
|
||||
Reference in New Issue
Block a user