update
This commit is contained in:
parent
bfa08217b7
commit
3dbc6f8e5b
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
config/config.json
|
||||||
117
bin/create_config.sh
Normal file
117
bin/create_config.sh
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# todo
|
||||||
|
create_config_with_tls_cert() {
|
||||||
|
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
|
||||||
|
cp "$script_dir/../config_template/tls_cert_config.json" "$script_dir/../config.json"
|
||||||
|
|
||||||
|
# 设置端口
|
||||||
|
bash "$script_dir/update_port.sh"
|
||||||
|
|
||||||
|
# 设置密码
|
||||||
|
bash "$script_dir/update_password.sh"
|
||||||
|
|
||||||
|
# 设置混淆密码
|
||||||
|
bash "$script_dir/update_obfs_password.sh"
|
||||||
|
|
||||||
|
# 获取邮箱
|
||||||
|
read -p "请输入你的邮箱: " user_email
|
||||||
|
while [[ -z "$user_email" ]]; do
|
||||||
|
echo "[错误] 邮箱不能为空"
|
||||||
|
read -p "请输入你的邮箱: " user_email
|
||||||
|
done
|
||||||
|
|
||||||
|
# 获取域名
|
||||||
|
read -p "请输入你的域名 (例如: example.com): " user_domain
|
||||||
|
while [[ -z "$user_domain" ]]; do
|
||||||
|
echo "[错误] 域名不能为空"
|
||||||
|
read -p "请输入你的域名: " user_domain
|
||||||
|
done
|
||||||
|
|
||||||
|
# 获取 Cloudflare API Token
|
||||||
|
read -p "请输入你的 Cloudflare API Token: " cloudflare_token
|
||||||
|
while [[ -z "$cloudflare_token" ]]; do
|
||||||
|
echo "[错误] Cloudflare API Token 不能为空"
|
||||||
|
read -p "请输入你的 Cloudflare API Token: " cloudflare_token
|
||||||
|
done
|
||||||
|
|
||||||
|
# 替换配置文件中的占位符
|
||||||
|
local config_file="$script_dir/../config.json"
|
||||||
|
|
||||||
|
# 使用 sed 替换邮箱
|
||||||
|
sed -i "s/你的邮箱/$user_email/g" "$config_file"
|
||||||
|
|
||||||
|
# 替换域名 (在 domains 数组和 masquerade url 中)
|
||||||
|
sed -i "s/你的域名/$user_domain/g" "$config_file"
|
||||||
|
|
||||||
|
# 替换 Cloudflare API Token
|
||||||
|
sed -i "s/你的cloudflare_api_token/$cloudflare_token/g" "$config_file"
|
||||||
|
|
||||||
|
echo "初始化设置完成"
|
||||||
|
}
|
||||||
|
|
||||||
|
create_self_tls_config() {
|
||||||
|
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
|
||||||
|
cp "$script_dir/../config_template/self_cert_config.json" "$script_dir/../config.json"
|
||||||
|
|
||||||
|
# 设置端口
|
||||||
|
bash "$script_dir/update_port.sh"
|
||||||
|
|
||||||
|
# 设置密码
|
||||||
|
bash "$script_dir/update_password.sh"
|
||||||
|
|
||||||
|
# 设置混淆密码
|
||||||
|
bash "$script_dir/update_obfs_password.sh"
|
||||||
|
|
||||||
|
# 生成自签名证书和设置域名
|
||||||
|
bash "$script_dir/gen_self_tls.sh" "bing.com"
|
||||||
|
|
||||||
|
echo "初始化设置完成"
|
||||||
|
}
|
||||||
|
|
||||||
|
create_config(){
|
||||||
|
local script_dir=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
|
||||||
|
local config_file = "$script_dir/../config/config.json"
|
||||||
|
|
||||||
|
# 如果配置文件不存在, 创建空白配置文件
|
||||||
|
if [ ! -e "$config_file" ]; then
|
||||||
|
touch "$config_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local config_password=$(jq -r '.inbounds[0].users[0].password' "$config_file")
|
||||||
|
if [ -s "$config_file" ] && [ "$config_password" != "你的密码" ]; then
|
||||||
|
local regenerate
|
||||||
|
read -p "检测到配置已存在,是否重新生成配置?(y/n): " regenerate
|
||||||
|
if [ "$regenerate" != "y" ] && [ "$regenerate" != "Y" ]; then
|
||||||
|
echo "取消重新生成配置."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "请选择配置类型:"
|
||||||
|
echo "1. 自签名证书配置"
|
||||||
|
echo "2. tls证书配置"
|
||||||
|
local choice
|
||||||
|
read -p "输入您的选择: " choice
|
||||||
|
case $choice in
|
||||||
|
1)
|
||||||
|
echo "重置为自签名证书配置..."
|
||||||
|
create_self_tls_config
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
echo "重置为tls证书配置..."
|
||||||
|
create_config_with_tls_cert
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "无效的选择, 请重新选择."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
create_config
|
||||||
|
|
||||||
|
|
||||||
53
config/template/tls_cert_config.json
Normal file
53
config/template/tls_cert_config.json
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"log": {
|
||||||
|
"level": "info",
|
||||||
|
"timestamp": true
|
||||||
|
},
|
||||||
|
"inbounds": [
|
||||||
|
{
|
||||||
|
"type": "tuic",
|
||||||
|
"tag": "tuic-in",
|
||||||
|
"listen": "::",
|
||||||
|
"listen_port": 8443,
|
||||||
|
"users": [
|
||||||
|
{
|
||||||
|
"name": "user1",
|
||||||
|
"uuid": "你的UUID",
|
||||||
|
"password": "你的密码"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"congestion_control": "bbr",
|
||||||
|
"auth_timeout": "3s",
|
||||||
|
"zero_rtt_handshake": false,
|
||||||
|
"heartbeat": "10s",
|
||||||
|
"tls": {
|
||||||
|
"enabled": true,
|
||||||
|
"server_name": "bing.com",
|
||||||
|
"alpn": [
|
||||||
|
"h3"
|
||||||
|
],
|
||||||
|
"key_path": "/etc/sing-box/tls/server.key",
|
||||||
|
"certificate_path": "/etc/sing-box/tls/server.crt"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outbounds": [
|
||||||
|
{
|
||||||
|
"type": "direct",
|
||||||
|
"tag": "direct"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "block",
|
||||||
|
"tag": "block"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"route": {
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"ip_is_private": true,
|
||||||
|
"outbound": "block"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"final": "direct"
|
||||||
|
}
|
||||||
|
}
|
||||||
86
install.sh
Normal file
86
install.sh
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
script_dir="$(cd "$(dirname "$0")"; pwd)/bin" # 脚本所在目录
|
||||||
|
source "${script_dir}/utils/base.sh"
|
||||||
|
|
||||||
|
# 检查bash环境是否安装
|
||||||
|
check_bash_installed
|
||||||
|
|
||||||
|
install(){
|
||||||
|
if ! command -v curl >/dev/null 2>&1; then
|
||||||
|
install_package curl
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v wget >/dev/null 2>&1; then
|
||||||
|
install_package wget
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v jq >/dev/null 2>&1; then
|
||||||
|
echo 安装jq...
|
||||||
|
install_package jq
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v docker >/dev/null 2>&1; then
|
||||||
|
echo 安装docker...
|
||||||
|
curl -fsSL https://get.docker.com | bash -s docker
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v docker-compose >/dev/null 2>&1; then
|
||||||
|
echo 安装docker-compose...
|
||||||
|
wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/v2.29.0/docker-compose-linux-x86_64
|
||||||
|
chmod +x /usr/local/bin/docker-compose
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 显示菜单
|
||||||
|
echo "请选择一个操作:"
|
||||||
|
echo "1. 安装并启动"
|
||||||
|
echo "2. 生成配置 / 重置配置"
|
||||||
|
echo "3. 启动容器"
|
||||||
|
echo "4. 查看分享链接"
|
||||||
|
echo "5. 停止容器"
|
||||||
|
echo "6. 更新镜像"
|
||||||
|
echo "7. 更新端口"
|
||||||
|
|
||||||
|
# 读取用户选择
|
||||||
|
read -p "输入您的选择: " choice
|
||||||
|
|
||||||
|
# 根据用户选择执行相应的操作
|
||||||
|
case $choice in
|
||||||
|
1)
|
||||||
|
# 安装并启动
|
||||||
|
install
|
||||||
|
bash ./bin/run.sh
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
# 生成配置
|
||||||
|
echo "重新生成配置.."
|
||||||
|
bash ./bin/create_config.sh
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
# 启动容器
|
||||||
|
echo "启动容器.."
|
||||||
|
bash ./bin/run.sh
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
# 查看分享链接
|
||||||
|
echo "查看分享链接.."
|
||||||
|
bash ./bin/print_share_link.sh
|
||||||
|
;;
|
||||||
|
5)
|
||||||
|
# 停止容器
|
||||||
|
echo "正在停止容器.."
|
||||||
|
docker-compose -f ./docker-compose.yml down
|
||||||
|
;;
|
||||||
|
6)
|
||||||
|
# 更新镜像
|
||||||
|
bash ./bin/update_docker_images.sh
|
||||||
|
;;
|
||||||
|
7)
|
||||||
|
# 更新端口
|
||||||
|
bash ./bin/update_port.sh
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "无效的选择, 请重新选择."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
Loading…
Reference in New Issue
Block a user