重构代码, 统一项目入口为install.sh

This commit is contained in:
Olia Lisa 2026-01-15 13:21:40 +08:00
parent 8d96dab146
commit 771abcf074
10 changed files with 27 additions and 56 deletions

View File

@ -1,5 +1,4 @@
#!/bin/bash
source "$(dirname "$0")/utils/base.sh"
create_config_with_tls_cert() {
@ -10,13 +9,13 @@ create_config_with_tls_cert() {
cp "$config_dir/template/tls_cert_config.json" "$config_file"
# 设置端口
bash "$script_dir/update_port.sh"
change_port
# 设置密码
bash "$script_dir/update_password.sh"
update_password
# 设置混淆密码
bash "$script_dir/update_obfs_password.sh"
update_obfs_password
# 获取邮箱
read -p "请输入你的邮箱(可留空): " user_email
@ -57,16 +56,16 @@ create_self_tls_config() {
cp "$config_dir/template/self_cert_config.json" "$config_dir/config.json"
# 设置端口
bash "$script_dir/update_port.sh"
change_port
# 设置密码
bash "$script_dir/update_password.sh"
update_password
# 设置混淆密码
bash "$script_dir/update_obfs_password.sh"
update_obfs_password
# 生成自签名证书和设置域名
bash "$script_dir/gen_self_tls.sh" "bing.com"
gen_self_tls "bing.com"
green "创建配置成功"
}
@ -109,6 +108,3 @@ create_config(){
;;
esac
}
create_config

View File

@ -1,5 +1,4 @@
#!/bin/bash
source "$(dirname "$0")/utils/jq_util.sh"
# 生成自签名证书
@ -20,6 +19,3 @@ gen_self_tls() {
local config_file="$script_dir/../config/config.json"
modify_json_file "$config_file" "masquerade.proxy.url" "https://$domain"
}
# 调用函数,传入第一个参数作为域名
gen_self_tls "${1:-bing.com}"

View File

@ -1,5 +1,4 @@
#!/bin/bash
source "$(dirname "$0")/utils/base.sh"
print_share_link() {
@ -55,5 +54,3 @@ print_share_link() {
echo "分享链接: $share_link"
echo -e "\033[0m"
}
print_share_link # 输出分享链接

View File

@ -14,5 +14,3 @@ run() {
docker-compose -f "$compose_file" up -d
}
run # 启动容器

View File

@ -23,6 +23,3 @@ update_docker_images() {
echo "正在启动容器.."
docker-compose -f "$docker_compose_file" up -d
}
# 调用函数
update_docker_images

View File

@ -1,6 +1,4 @@
#!/bin/bash
source "$(dirname "$0")/utils/base.sh"
source "$(dirname "$0")/utils/jq_util.sh"
# 修改域名
@ -31,6 +29,3 @@ update_domain(){
echo "修改域名成功"
}
update_domain

View File

@ -1,6 +1,4 @@
#!/bin/bash
source "$(dirname "$0")/utils/base.sh"
source "$(dirname "$0")/utils/jq_util.sh"
# 更新密码的函数
update_obfs_password() {
@ -18,6 +16,3 @@ update_obfs_password() {
echo "更新混淆密码成功"
}
# 调用函数
update_obfs_password

View File

@ -1,6 +1,4 @@
#!/bin/bash
source "$(dirname "$0")/utils/base.sh"
source "$(dirname "$0")/utils/jq_util.sh"
# 更新密码的函数
update_password() {
@ -18,6 +16,3 @@ update_password() {
echo "设置密码成功"
}
# 调用函数
update_password

View File

@ -1,6 +1,4 @@
#!/bin/bash
source "$(dirname "$0")/utils/base.sh"
source "$(dirname "$0")/utils/jq_util.sh"
# 查找随机空闲端口
# 用途:
@ -84,5 +82,3 @@ change_port(){
modify_json_file "$config_file" ".listen" ":$port"
echo "已分配新的空闲端口, 设置端口成功"
}
change_port

View File

@ -1,7 +1,13 @@
#!/bin/bash
source ./bin/utils/base.sh
source ./bin/utils/jq_util.sh
# 导入依赖脚本文件
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
for f in "$BASE_DIR"/bin/utils/*.sh; do
[ -f "$f" ] && source "$f"
done
for f in "$BASE_DIR"/bin/*.sh; do
[ -f "$f" ] && source "$f"
done
install(){
if ! command -v curl >/dev/null 2>&1; then
@ -48,23 +54,23 @@ main(){
1)
# 一键部署
install
bash ./bin/create_config.sh
bash ./bin/run.sh
bash ./bin/print_share_link.sh
create_config
run
print_share_link
;;
2)
# 生成配置
bash ./bin/create_config.sh
create_config
;;
3)
# 查看分享链接
check_config_file
bash ./bin/print_share_link.sh
print_share_link
;;
4)
# 启动容器
bash ./bin/run.sh
bash ./bin/print_share_link.sh
run
print_share_link
;;
5)
# 停止容器
@ -72,18 +78,18 @@ main(){
;;
6)
# 更新镜像
bash ./bin/update_docker_images.sh
update_docker_images
;;
7)
# 修改域名
check_config_file
bash ./bin/update_domain.sh
update_domain
restart_docker
;;
8)
# 修改端口
check_config_file
bash ./bin/update_port.sh
change_port
restart_docker
;;
*)