Add files via upload

This commit is contained in:
公明
2026-06-13 12:15:55 +08:00
committed by GitHub
parent b7c01f41c7
commit 9887589d99
+107 -107
View File
@@ -2,11 +2,11 @@
set -euo pipefail set -euo pipefail
# CyberStrikeAI 一键部署启动脚本 # CyberStrikeAI one-click deploy and start script
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)" ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT_DIR" cd "$ROOT_DIR"
# 颜色定义 # Color definitions
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
@@ -14,31 +14,31 @@ BLUE='\033[0;34m'
CYAN='\033[0;36m' CYAN='\033[0;36m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
# 打印带颜色的消息 # Print colored messages
info() { echo -e "${BLUE}ℹ️ $1${NC}"; } info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
success() { echo -e "${GREEN}✅ $1${NC}"; } success() { echo -e "${GREEN}✅ $1${NC}"; }
warning() { echo -e "${YELLOW}⚠️ $1${NC}"; } warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
error() { echo -e "${RED}❌ $1${NC}"; } error() { echo -e "${RED}❌ $1${NC}"; }
note() { echo -e "${CYAN}ℹ️ $1${NC}"; } note() { echo -e "${CYAN}ℹ️ $1${NC}"; }
# 临时源配置(仅在此脚本中生效) # Temporary mirror/proxy settings (only effective in this script)
PIP_INDEX_URL="${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple}" PIP_INDEX_URL="${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple}"
GOPROXY="${GOPROXY:-https://goproxy.cn,direct}" GOPROXY="${GOPROXY:-https://goproxy.cn,direct}"
# 保存原始环境变量(用于恢复) # Save original env vars (for restoration)
ORIGINAL_PIP_INDEX_URL="${PIP_INDEX_URL:-}" ORIGINAL_PIP_INDEX_URL="${PIP_INDEX_URL:-}"
ORIGINAL_GOPROXY="${GOPROXY:-}" ORIGINAL_GOPROXY="${GOPROXY:-}"
# 进度显示函数 # Progress display helper
show_progress() { show_progress() {
local pid=$1 local pid=$1
local message=$2 local message=$2
local i=0 local i=0
local dots="" local dots=""
# 检查进程是否存在 # Check if the process exists
if ! kill -0 "$pid" 2>/dev/null; then if ! kill -0 "$pid" 2>/dev/null; then
# 进程已经结束,立即返回 # Process already finished; return immediately
return 0 return 0
fi fi
@@ -53,7 +53,7 @@ show_progress() {
printf "\r${BLUE}⏳ %s%s${NC}" "$message" "$dots" printf "\r${BLUE}⏳ %s%s${NC}" "$message" "$dots"
sleep 0.5 sleep 0.5
# 再次检查进程是否还存在 # Re-check whether the process is still running
if ! kill -0 "$pid" 2>/dev/null; then if ! kill -0 "$pid" 2>/dev/null; then
break break
fi fi
@@ -63,21 +63,21 @@ show_progress() {
echo "" echo ""
echo "==========================================" echo "=========================================="
echo " CyberStrikeAI 一键部署启动脚本" echo " CyberStrikeAI Deploy & Start Script"
echo " (默认 HTTPS 自签证书;纯 HTTP 请用: $0 --http)" echo " (HTTPS with self-signed cert by default; plain HTTP: $0 --http)"
echo "==========================================" echo "=========================================="
echo "" echo ""
# 显示临时源配置信息 # Show temporary mirror/proxy info
echo "" echo ""
warning "⚠️ 注意:此脚本将使用临时镜像源加速下载" warning "Note: this script uses temporary mirrors to speed up downloads"
echo "" echo ""
info "Python pip 临时镜像源:" info "Python pip temporary mirror:"
echo " ${PIP_INDEX_URL}" echo " ${PIP_INDEX_URL}"
info "Go Proxy 临时镜像源:" info "Go temporary proxy:"
echo " ${GOPROXY}" echo " ${GOPROXY}"
echo "" echo ""
note "这些设置仅在脚本运行期间生效,不会修改系统配置" note "These settings apply only while this script runs and do not change system config"
echo "" echo ""
sleep 1 sleep 1
@@ -86,19 +86,19 @@ VENV_DIR="$ROOT_DIR/venv"
REQUIREMENTS_FILE="$ROOT_DIR/requirements.txt" REQUIREMENTS_FILE="$ROOT_DIR/requirements.txt"
BINARY_NAME="cyberstrike-ai" BINARY_NAME="cyberstrike-ai"
# 检查配置文件 # Check config file
if [ ! -f "$CONFIG_FILE" ]; then if [ ! -f "$CONFIG_FILE" ]; then
error "配置文件 config.yaml 不存在" error "Config file config.yaml not found"
info "请确保在项目根目录运行此脚本" info "Make sure you run this script from the project root"
exit 1 exit 1
fi fi
# 检查并安装 Python 环境 # Check Python environment
check_python() { check_python() {
if ! command -v python3 >/dev/null 2>&1; then if ! command -v python3 >/dev/null 2>&1; then
error "未找到 python3" error "python3 not found"
echo "" echo ""
info "请先安装 Python 3.10 或更高版本:" info "Install Python 3.10 or later first:"
echo " macOS: brew install python3" echo " macOS: brew install python3"
echo " Ubuntu: sudo apt-get install python3 python3-venv" echo " Ubuntu: sudo apt-get install python3 python3-venv"
echo " CentOS: sudo yum install python3 python3-pip" echo " CentOS: sudo yum install python3 python3-pip"
@@ -110,23 +110,23 @@ check_python() {
PYTHON_MINOR=$(echo "$PYTHON_VERSION" | cut -d. -f2) PYTHON_MINOR=$(echo "$PYTHON_VERSION" | cut -d. -f2)
if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 10 ]); then if [ "$PYTHON_MAJOR" -lt 3 ] || ([ "$PYTHON_MAJOR" -eq 3 ] && [ "$PYTHON_MINOR" -lt 10 ]); then
error "Python 版本过低: $PYTHON_VERSION (需要 3.10+)" error "Python version too old: $PYTHON_VERSION (requires 3.10+)"
exit 1 exit 1
fi fi
success "Python 环境检查通过: $PYTHON_VERSION" success "Python check passed: $PYTHON_VERSION"
} }
# 检查并安装 Go 环境 # Check Go environment
check_go() { check_go() {
if ! command -v go >/dev/null 2>&1; then if ! command -v go >/dev/null 2>&1; then
error "未找到 Go" error "Go not found"
echo "" echo ""
info "请先安装 Go 1.21 或更高版本:" info "Install Go 1.21 or later first:"
echo " macOS: brew install go" echo " macOS: brew install go"
echo " Ubuntu: sudo apt-get install golang-go" echo " Ubuntu: sudo apt-get install golang-go"
echo " CentOS: sudo yum install golang" echo " CentOS: sudo yum install golang"
echo " 或访问: https://go.dev/dl/" echo " Or visit: https://go.dev/dl/"
exit 1 exit 1
fi fi
@@ -135,63 +135,63 @@ check_go() {
GO_MINOR=$(echo "$GO_VERSION" | cut -d. -f2) GO_MINOR=$(echo "$GO_VERSION" | cut -d. -f2)
if [ "$GO_MAJOR" -lt 1 ] || ([ "$GO_MAJOR" -eq 1 ] && [ "$GO_MINOR" -lt 21 ]); then if [ "$GO_MAJOR" -lt 1 ] || ([ "$GO_MAJOR" -eq 1 ] && [ "$GO_MINOR" -lt 21 ]); then
error "Go 版本过低: $GO_VERSION (需要 1.21+)" error "Go version too old: $GO_VERSION (requires 1.21+)"
exit 1 exit 1
fi fi
success "Go 环境检查通过: $(go version)" success "Go check passed: $(go version)"
} }
# 设置 Python 虚拟环境 # Set up Python virtual environment
setup_python_env() { setup_python_env() {
if [ ! -d "$VENV_DIR" ]; then if [ ! -d "$VENV_DIR" ]; then
info "创建 Python 虚拟环境..." info "Creating Python virtual environment..."
python3 -m venv "$VENV_DIR" python3 -m venv "$VENV_DIR"
success "虚拟环境创建完成" success "Virtual environment created"
else else
info "Python 虚拟环境已存在" info "Python virtual environment already exists"
fi fi
info "激活虚拟环境..." info "Activating virtual environment..."
# shellcheck disable=SC1091 # shellcheck disable=SC1091
source "$VENV_DIR/bin/activate" source "$VENV_DIR/bin/activate"
if [ -f "$REQUIREMENTS_FILE" ]; then if [ -f "$REQUIREMENTS_FILE" ]; then
echo "" echo ""
note "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" note "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
note "⚠️ 使用临时 pip 镜像源(仅本次脚本运行有效)" note "Using temporary pip mirror (this script run only)"
note " 镜像地址: ${PIP_INDEX_URL}" note " Mirror URL: ${PIP_INDEX_URL}"
note " 如需永久配置,请设置环境变量 PIP_INDEX_URL" note " For a permanent setting, set the PIP_INDEX_URL env var"
note "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" note "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "" echo ""
info "升级 pip..." info "Upgrading pip..."
pip install --index-url "$PIP_INDEX_URL" --upgrade pip >/dev/null 2>&1 || true pip install --index-url "$PIP_INDEX_URL" --upgrade pip >/dev/null 2>&1 || true
info "安装 Python 依赖包..." info "Installing Python dependencies..."
echo "" echo ""
# 尝试安装依赖,捕获错误输出并显示进度 # Install deps in background; capture errors and show progress
PIP_LOG=$(mktemp) PIP_LOG=$(mktemp)
( (
set +e # 在子shell中禁用错误退出 set +e # disable errexit in subshell
pip install --index-url "$PIP_INDEX_URL" -r "$REQUIREMENTS_FILE" >"$PIP_LOG" 2>&1 pip install --index-url "$PIP_INDEX_URL" -r "$REQUIREMENTS_FILE" >"$PIP_LOG" 2>&1
echo $? > "${PIP_LOG}.exit" echo $? > "${PIP_LOG}.exit"
) & ) &
PIP_PID=$! PIP_PID=$!
# 等待一小段时间,确保进程启动 # Brief pause so the process can start
sleep 0.1 sleep 0.1
# 显示进度(如果进程还在运行) # Show progress while still running
if kill -0 "$PIP_PID" 2>/dev/null; then if kill -0 "$PIP_PID" 2>/dev/null; then
show_progress "$PIP_PID" "正在安装依赖包" show_progress "$PIP_PID" "Installing dependencies"
else else
# 进程已经结束,等待一下确保退出码文件已写入 # Process already finished; wait for exit code file
sleep 0.2 sleep 0.2
fi fi
# 等待进程完成,忽略 wait 的退出码 # Wait for completion; ignore wait exit code
wait "$PIP_PID" 2>/dev/null || true wait "$PIP_PID" 2>/dev/null || true
PIP_EXIT_CODE=0 PIP_EXIT_CODE=0
@@ -199,74 +199,74 @@ setup_python_env() {
PIP_EXIT_CODE=$(cat "${PIP_LOG}.exit" 2>/dev/null || echo "1") PIP_EXIT_CODE=$(cat "${PIP_LOG}.exit" 2>/dev/null || echo "1")
rm -f "${PIP_LOG}.exit" 2>/dev/null || true rm -f "${PIP_LOG}.exit" 2>/dev/null || true
else else
# 如果没有退出码文件,检查日志中是否有错误 # No exit code file; check log for errors
if [ -f "$PIP_LOG" ] && grep -q -i "error\|failed\|exception" "$PIP_LOG" 2>/dev/null; then if [ -f "$PIP_LOG" ] && grep -q -i "error\|failed\|exception" "$PIP_LOG" 2>/dev/null; then
PIP_EXIT_CODE=1 PIP_EXIT_CODE=1
fi fi
fi fi
if [ $PIP_EXIT_CODE -eq 0 ]; then if [ $PIP_EXIT_CODE -eq 0 ]; then
success "Python 依赖安装完成" success "Python dependencies installed"
else else
# 检查是否是 angr 安装失败(需要 Rust) # Check for angr install failure (needs Rust)
if grep -q "angr" "$PIP_LOG" && grep -q "Rust compiler\|can't find Rust" "$PIP_LOG"; then if grep -q "angr" "$PIP_LOG" && grep -q "Rust compiler\|can't find Rust" "$PIP_LOG"; then
warning "angr 安装失败(需要 Rust 编译器)" warning "angr install failed (Rust compiler required)"
echo "" echo ""
info "angr 是可选依赖,主要用于二进制分析工具" info "angr is optional and mainly used for binary analysis tools"
info "如果需要使用 angr,请先安装 Rust:" info "To use angr, install Rust first:"
echo " macOS: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh" echo " macOS: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
echo " Ubuntu: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh" echo " Ubuntu: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
echo " 或访问: https://rustup.rs/" echo " Or visit: https://rustup.rs/"
echo "" echo ""
info "其他依赖已安装,可以继续使用(部分工具可能不可用)" info "Other dependencies are installed; you can continue (some tools may be unavailable)"
else else
warning "部分 Python 依赖安装失败,但可以继续尝试运行" warning "Some Python dependencies failed to install, but continuing"
warning "如果遇到问题,请检查错误信息并手动安装缺失的依赖" warning "If you hit issues, check the errors and install missing packages manually"
# 显示最后几行错误信息 # Show last lines of error output
echo "" echo ""
info "错误详情(最后 10 行):" info "Error details (last 10 lines):"
tail -n 10 "$PIP_LOG" | sed 's/^/ /' tail -n 10 "$PIP_LOG" | sed 's/^/ /'
echo "" echo ""
fi fi
fi fi
rm -f "$PIP_LOG" rm -f "$PIP_LOG"
else else
warning "未找到 requirements.txt,跳过 Python 依赖安装" warning "requirements.txt not found; skipping Python dependency install"
fi fi
} }
# 构建 Go 项目 # Build Go project
build_go_project() { build_go_project() {
echo "" echo ""
note "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" note "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
note "⚠️ 使用临时 Go Proxy(仅本次脚本运行有效)" note "Using temporary Go proxy (this script run only)"
note " Proxy 地址: ${GOPROXY}" note " Proxy URL: ${GOPROXY}"
note " 如需永久配置,请设置环境变量 GOPROXY" note " For a permanent setting, set the GOPROXY env var"
note "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" note "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "" echo ""
info "下载 Go 依赖..." info "Downloading Go dependencies..."
GO_DOWNLOAD_LOG=$(mktemp) GO_DOWNLOAD_LOG=$(mktemp)
( (
set +e # 在子shell中禁用错误退出 set +e # disable errexit in subshell
export GOPROXY="$GOPROXY" export GOPROXY="$GOPROXY"
go mod download >"$GO_DOWNLOAD_LOG" 2>&1 go mod download >"$GO_DOWNLOAD_LOG" 2>&1
echo $? > "${GO_DOWNLOAD_LOG}.exit" echo $? > "${GO_DOWNLOAD_LOG}.exit"
) & ) &
GO_DOWNLOAD_PID=$! GO_DOWNLOAD_PID=$!
# 等待一小段时间,确保进程启动 # Brief pause so the process can start
sleep 0.1 sleep 0.1
# 显示进度(如果进程还在运行) # Show progress while still running
if kill -0 "$GO_DOWNLOAD_PID" 2>/dev/null; then if kill -0 "$GO_DOWNLOAD_PID" 2>/dev/null; then
show_progress "$GO_DOWNLOAD_PID" "正在下载 Go 依赖" show_progress "$GO_DOWNLOAD_PID" "Downloading Go dependencies"
else else
# 进程已经结束,等待一下确保退出码文件已写入 # Process already finished; wait for exit code file
sleep 0.2 sleep 0.2
fi fi
# 等待进程完成,忽略 wait 的退出码 # Wait for completion; ignore wait exit code
wait "$GO_DOWNLOAD_PID" 2>/dev/null || true wait "$GO_DOWNLOAD_PID" 2>/dev/null || true
GO_DOWNLOAD_EXIT_CODE=0 GO_DOWNLOAD_EXIT_CODE=0
@@ -274,7 +274,7 @@ build_go_project() {
GO_DOWNLOAD_EXIT_CODE=$(cat "${GO_DOWNLOAD_LOG}.exit" 2>/dev/null || echo "1") GO_DOWNLOAD_EXIT_CODE=$(cat "${GO_DOWNLOAD_LOG}.exit" 2>/dev/null || echo "1")
rm -f "${GO_DOWNLOAD_LOG}.exit" 2>/dev/null || true rm -f "${GO_DOWNLOAD_LOG}.exit" 2>/dev/null || true
else else
# 如果没有退出码文件,检查日志中是否有错误 # No exit code file; check log for errors
if [ -f "$GO_DOWNLOAD_LOG" ] && grep -q -i "error\|failed" "$GO_DOWNLOAD_LOG" 2>/dev/null; then if [ -f "$GO_DOWNLOAD_LOG" ] && grep -q -i "error\|failed" "$GO_DOWNLOAD_LOG" 2>/dev/null; then
GO_DOWNLOAD_EXIT_CODE=1 GO_DOWNLOAD_EXIT_CODE=1
fi fi
@@ -282,33 +282,33 @@ build_go_project() {
rm -f "$GO_DOWNLOAD_LOG" 2>/dev/null || true rm -f "$GO_DOWNLOAD_LOG" 2>/dev/null || true
if [ $GO_DOWNLOAD_EXIT_CODE -ne 0 ]; then if [ $GO_DOWNLOAD_EXIT_CODE -ne 0 ]; then
error "Go 依赖下载失败" error "Go dependency download failed"
exit 1 exit 1
fi fi
success "Go 依赖下载完成" success "Go dependencies downloaded"
info "构建项目..." info "Building project..."
GO_BUILD_LOG=$(mktemp) GO_BUILD_LOG=$(mktemp)
( (
set +e # 在子shell中禁用错误退出 set +e # disable errexit in subshell
export GOPROXY="$GOPROXY" export GOPROXY="$GOPROXY"
go build -o "$BINARY_NAME" cmd/server/main.go >"$GO_BUILD_LOG" 2>&1 go build -o "$BINARY_NAME" cmd/server/main.go >"$GO_BUILD_LOG" 2>&1
echo $? > "${GO_BUILD_LOG}.exit" echo $? > "${GO_BUILD_LOG}.exit"
) & ) &
GO_BUILD_PID=$! GO_BUILD_PID=$!
# 等待一小段时间,确保进程启动 # Brief pause so the process can start
sleep 0.1 sleep 0.1
# 显示进度(如果进程还在运行) # Show progress while still running
if kill -0 "$GO_BUILD_PID" 2>/dev/null; then if kill -0 "$GO_BUILD_PID" 2>/dev/null; then
show_progress "$GO_BUILD_PID" "正在构建项目" show_progress "$GO_BUILD_PID" "Building project"
else else
# 进程已经结束,等待一下确保退出码文件已写入 # Process already finished; wait for exit code file
sleep 0.2 sleep 0.2
fi fi
# 等待进程完成,忽略 wait 的退出码 # Wait for completion; ignore wait exit code
wait "$GO_BUILD_PID" 2>/dev/null || true wait "$GO_BUILD_PID" 2>/dev/null || true
GO_BUILD_EXIT_CODE=0 GO_BUILD_EXIT_CODE=0
@@ -316,20 +316,20 @@ build_go_project() {
GO_BUILD_EXIT_CODE=$(cat "${GO_BUILD_LOG}.exit" 2>/dev/null || echo "1") GO_BUILD_EXIT_CODE=$(cat "${GO_BUILD_LOG}.exit" 2>/dev/null || echo "1")
rm -f "${GO_BUILD_LOG}.exit" 2>/dev/null || true rm -f "${GO_BUILD_LOG}.exit" 2>/dev/null || true
else else
# 如果没有退出码文件,检查日志中是否有错误 # No exit code file; check log for errors
if [ -f "$GO_BUILD_LOG" ] && grep -q -i "error\|failed" "$GO_BUILD_LOG" 2>/dev/null; then if [ -f "$GO_BUILD_LOG" ] && grep -q -i "error\|failed" "$GO_BUILD_LOG" 2>/dev/null; then
GO_BUILD_EXIT_CODE=1 GO_BUILD_EXIT_CODE=1
fi fi
fi fi
if [ $GO_BUILD_EXIT_CODE -eq 0 ]; then if [ $GO_BUILD_EXIT_CODE -eq 0 ]; then
success "项目构建完成: $BINARY_NAME" success "Build complete: $BINARY_NAME"
rm -f "$GO_BUILD_LOG" rm -f "$GO_BUILD_LOG"
else else
error "项目构建失败" error "Build failed"
# 显示构建错误 # Show build errors
echo "" echo ""
info "构建错误详情:" info "Build error details:"
cat "$GO_BUILD_LOG" | sed 's/^/ /' cat "$GO_BUILD_LOG" | sed 's/^/ /'
echo "" echo ""
rm -f "$GO_BUILD_LOG" rm -f "$GO_BUILD_LOG"
@@ -337,24 +337,24 @@ build_go_project() {
fi fi
} }
# 检查是否需要重新构建 # Check whether a rebuild is needed
need_rebuild() { need_rebuild() {
if [ ! -f "$BINARY_NAME" ]; then if [ ! -f "$BINARY_NAME" ]; then
return 0 # 需要构建 return 0 # needs build
fi fi
# 检查源代码是否有更新 # Check if source changed since last build
if [ "$BINARY_NAME" -ot cmd/server/main.go ] || \ if [ "$BINARY_NAME" -ot cmd/server/main.go ] || \
[ "$BINARY_NAME" -ot go.mod ] || \ [ "$BINARY_NAME" -ot go.mod ] || \
find internal cmd -name "*.go" -newer "$BINARY_NAME" 2>/dev/null | grep -q .; then find internal cmd -name "*.go" -newer "$BINARY_NAME" 2>/dev/null | grep -q .; then
return 0 # 需要重新构建 return 0 # needs rebuild
fi fi
return 1 # 不需要构建 return 1 # no rebuild needed
} }
# 主流程 # Main flow
# 默认启动主站 HTTPS(--https 传给二进制);传 --http 则走明文 HTTP。 # Default: HTTPS (--https passed to binary); --http uses plain HTTP.
main() { main() {
USE_HTTPS=1 USE_HTTPS=1
FORWARD_ARGS=() FORWARD_ARGS=()
@@ -366,39 +366,39 @@ main() {
FORWARD_ARGS+=("$arg") FORWARD_ARGS+=("$arg")
done done
# 环境检查 # Environment checks
info "检查运行环境..." info "Checking runtime environment..."
check_python check_python
check_go check_go
echo "" echo ""
# 设置 Python 环境 # Python setup
info "设置 Python 环境..." info "Setting up Python environment..."
setup_python_env setup_python_env
echo "" echo ""
# 构建 Go 项目 # Go build
if need_rebuild; then if need_rebuild; then
info "准备构建项目..." info "Preparing to build project..."
build_go_project build_go_project
else else
success "可执行文件已是最新,跳过构建" success "Binary is up to date; skipping build"
fi fi
echo "" echo ""
# 启动服务器 # Start server
success "所有准备工作完成!" success "All setup complete!"
echo "" echo ""
if [ "$USE_HTTPS" -eq 1 ]; then if [ "$USE_HTTPS" -eq 1 ]; then
info "启动 CyberStrikeAI 服务器(HTTPS + HTTP/2,自签证书)..." info "Starting CyberStrikeAI server (HTTPS + HTTP/2, self-signed cert)..."
note "纯 HTTP 启动请使用: $0 --http" note "For plain HTTP, use: $0 --http"
else else
info "启动 CyberStrikeAI 服务器(HTTP)..." info "Starting CyberStrikeAI server (HTTP)..."
fi fi
echo "==========================================" echo "=========================================="
echo "" echo ""
# 始终传入项目根目录下的 config.yaml,避免 cwd 不在项目根时找不到配置;额外参数仍可追加(如再次 -config 覆盖,以 Go flag 后写为准)。 # Always pass config.yaml from project root so cwd does not matter; extra args still apply (e.g. -config override; last Go flag wins).
if [ "$USE_HTTPS" -eq 1 ]; then if [ "$USE_HTTPS" -eq 1 ]; then
if [ "${#FORWARD_ARGS[@]}" -gt 0 ]; then if [ "${#FORWARD_ARGS[@]}" -gt 0 ]; then
exec "./$BINARY_NAME" -config "$CONFIG_FILE" --https "${FORWARD_ARGS[@]}" exec "./$BINARY_NAME" -config "$CONFIG_FILE" --https "${FORWARD_ARGS[@]}"
@@ -414,5 +414,5 @@ main() {
fi fi
} }
# 执行主流程(支持参数,如: ./run.sh --http) # Run main (supports args, e.g. ./run.sh --http)
main "$@" main "$@"