diff --git a/scripts/firewall-manager.sh b/scripts/firewall-manager.sh index 92c73de..770c8d8 100644 --- a/scripts/firewall-manager.sh +++ b/scripts/firewall-manager.sh @@ -15,12 +15,14 @@ else exit 1 fi -# 防火墙类型常量 -readonly FW_UNKNOWN=0 -readonly FW_IPTABLES=1 -readonly FW_FIREWALLD=2 -readonly FW_UFW=3 -readonly FW_NFTABLES=4 +# 防火墙类型常量 (防止重复定义) +if [[ -z "${FW_UNKNOWN:-}" ]]; then + readonly FW_UNKNOWN=0 + readonly FW_IPTABLES=1 + readonly FW_FIREWALLD=2 + readonly FW_UFW=3 + readonly FW_NFTABLES=4 +fi # 全局变量 DETECTED_FIREWALL=$FW_UNKNOWN diff --git a/scripts/outbound-manager.sh b/scripts/outbound-manager.sh index ce1b60d..5a0213a 100644 --- a/scripts/outbound-manager.sh +++ b/scripts/outbound-manager.sh @@ -15,10 +15,16 @@ else exit 1 fi -# 配置路径 -readonly HYSTERIA_CONFIG="/etc/hysteria/config.yaml" -readonly OUTBOUND_TEMPLATES_DIR="$SCRIPT_DIR/outbound-templates" -readonly BACKUP_DIR="/var/backups/s-hy2/outbound" +# 配置路径 (防止重复定义) +if [[ -z "${HYSTERIA_CONFIG:-}" ]]; then + readonly HYSTERIA_CONFIG="/etc/hysteria/config.yaml" +fi +if [[ -z "${OUTBOUND_TEMPLATES_DIR:-}" ]]; then + readonly OUTBOUND_TEMPLATES_DIR="$SCRIPT_DIR/outbound-templates" +fi +if [[ -z "${BACKUP_DIR:-}" ]]; then + readonly BACKUP_DIR="/var/backups/s-hy2/outbound" +fi # 初始化出站管理 init_outbound_manager() { diff --git a/scripts/post-deploy-check.sh b/scripts/post-deploy-check.sh index dc6f4a0..4b43fe9 100644 --- a/scripts/post-deploy-check.sh +++ b/scripts/post-deploy-check.sh @@ -20,10 +20,16 @@ if [[ -f "$SCRIPT_DIR/firewall-manager.sh" ]]; then source "$SCRIPT_DIR/firewall-manager.sh" fi -# 配置路径 -readonly HYSTERIA_CONFIG="/etc/hysteria/config.yaml" -readonly HYSTERIA_SERVICE="hysteria-server" -readonly CHECK_TIMEOUT=10 +# 配置路径 (防止重复定义) +if [[ -z "${HYSTERIA_CONFIG:-}" ]]; then + readonly HYSTERIA_CONFIG="/etc/hysteria/config.yaml" +fi +if [[ -z "${HYSTERIA_SERVICE:-}" ]]; then + readonly HYSTERIA_SERVICE="hysteria-server" +fi +if [[ -z "${CHECK_TIMEOUT:-}" ]]; then + readonly CHECK_TIMEOUT=10 +fi # 全面部署检查 comprehensive_deploy_check() { diff --git a/scripts/secure-download.sh b/scripts/secure-download.sh index 9b2c563..c36ca9d 100644 --- a/scripts/secure-download.sh +++ b/scripts/secure-download.sh @@ -6,14 +6,18 @@ # 严格错误处理 set -euo pipefail -# 安全下载配置 -readonly DOWNLOAD_TIMEOUT=30 -readonly MAX_FILE_SIZE=$((10 * 1024 * 1024)) # 10MB -readonly ALLOWED_PROTOCOLS=("https") -readonly USER_AGENT="s-hy2-secure-downloader/1.0" +# 安全下载配置 (防止重复定义) +if [[ -z "${DOWNLOAD_TIMEOUT:-}" ]]; then + readonly DOWNLOAD_TIMEOUT=30 + readonly MAX_FILE_SIZE=$((10 * 1024 * 1024)) # 10MB + readonly ALLOWED_PROTOCOLS=("https") + readonly USER_AGENT="s-hy2-secure-downloader/1.0" +fi # 临时目录 -readonly SECURE_TEMP_DIR="/tmp/s-hy2-secure-$$" +if [[ -z "${SECURE_TEMP_DIR:-}" ]]; then + readonly SECURE_TEMP_DIR="/tmp/s-hy2-secure-$$" +fi # 清理函数 cleanup_temp_files() {