mirror of
https://github.com/hotyue/IP-Sentinel.git
synced 2026-05-11 23:39:45 +08:00
chore: 战略撤退,代码全量回滚至 9a38fb6 (PR 引入前的纯净状态)
This commit is contained in:
@@ -5,15 +5,6 @@
|
||||
# 核心功能: 部署/卸载调度中枢、SQLite 资产管理、平滑热更新引擎
|
||||
# ==========================================================
|
||||
|
||||
# ==========================================================
|
||||
# 🛑 核心权限防线: 检查是否以 root 权限运行
|
||||
# ==========================================================
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "\033[31m❌ 权限被拒绝: 部署 IP-Sentinel 需要最高系统权限。\033[0m"
|
||||
echo -e "💡 请使用 \033[36msudo bash -c \"\$(curl -fsSL ...)\"\033[0m 或切换到 root 执行。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 你的 GitHub 仓库 Raw 数据直链前缀
|
||||
REPO_RAW_URL="https://raw.githubusercontent.com/hotyue/IP-Sentinel/main"
|
||||
# 临时改为开发地址用于测试
|
||||
@@ -265,47 +256,18 @@ chmod 600 "$DB_FILE"
|
||||
|
||||
# 4. 拉取核心调度代码并运行
|
||||
echo -e "\n[4/4] 部署 TG 调度守护进程..."
|
||||
# [修改] 剥离了写死的网址,改用顶部的 ${REPO_RAW_URL} 变量,确保与卸载脚本的数据源同源
|
||||
curl -sL "${REPO_RAW_URL}/master/tg_master.sh" -o "${MASTER_DIR}/tg_master.sh"
|
||||
chmod +x "${MASTER_DIR}/tg_master.sh"
|
||||
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
echo "💡 检测到 Systemd 环境,正在部署原生守护服务..."
|
||||
cat > /etc/systemd/system/ip-sentinel-master.service << EOF
|
||||
[Unit]
|
||||
Description=IP-Sentinel Master Command Center Service
|
||||
After=network.target
|
||||
# 写入看门狗 Cron (容错版)
|
||||
crontab -l 2>/dev/null | grep -v "tg_master.sh" > /tmp/cron_master || true
|
||||
echo "* * * * * pgrep -f tg_master.sh >/dev/null || nohup bash ${MASTER_DIR}/tg_master.sh >/dev/null 2>&1 &" >> /tmp/cron_master
|
||||
[ -f /tmp/cron_master ] && crontab /tmp/cron_master 2>/dev/null
|
||||
rm -f /tmp/cron_master
|
||||
|
||||
[Service]
|
||||
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
SyslogIdentifier=ip-sentinel
|
||||
Type=simple
|
||||
ExecStart=/bin/bash ${MASTER_DIR}/tg_master.sh
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
User=root
|
||||
WorkingDirectory=${MASTER_DIR}
|
||||
CPUSchedulingPolicy=idle
|
||||
IOSchedulingClass=idle
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now ip-sentinel-master.service
|
||||
systemctl restart ip-sentinel-master.service
|
||||
|
||||
# 清理遗留的 Cron
|
||||
crontab -l 2>/dev/null | grep -v "tg_master.sh" > /tmp/cron_master || true
|
||||
[ -f /tmp/cron_master ] && crontab /tmp/cron_master 2>/dev/null
|
||||
rm -f /tmp/cron_master
|
||||
else
|
||||
echo "💡 未检测到 Systemd,回退到 Cron 看门狗调度模式..."
|
||||
crontab -l 2>/dev/null | grep -v "tg_master.sh" > /tmp/cron_master || true
|
||||
echo "* * * * * pgrep -f tg_master.sh >/dev/null || nohup bash ${MASTER_DIR}/tg_master.sh >/dev/null 2>&1 &" >> /tmp/cron_master
|
||||
[ -f /tmp/cron_master ] && crontab /tmp/cron_master 2>/dev/null
|
||||
rm -f /tmp/cron_master
|
||||
pgrep -f tg_master.sh >/dev/null || { nohup bash "${MASTER_DIR}/tg_master.sh" >/dev/null 2>&1 & disown 2>/dev/null; }
|
||||
fi
|
||||
# 立刻启动 (追加 disown 彻底脱离终端管控,实现绝对静默)
|
||||
pgrep -f tg_master.sh >/dev/null || { nohup bash "${MASTER_DIR}/tg_master.sh" >/dev/null 2>&1 & disown 2>/dev/null; }
|
||||
|
||||
# ================== [v3.2.2 优化 & v3.6.1 OTA捷报: 战报文案分流] ==================
|
||||
echo "========================================================"
|
||||
|
||||
@@ -267,13 +267,7 @@ while true; do
|
||||
# 抛出幽灵进程进行脱壳升级,传递静默变量与回执 ID
|
||||
export SILENT_MASTER_OTA="true"
|
||||
export OTA_CHAT_ID="$CHAT_ID"
|
||||
|
||||
# [修复] 逃逸 Systemd Cgroup,防止被同归于尽机制误杀
|
||||
if command -v systemd-run >/dev/null 2>&1; then
|
||||
systemd-run --quiet --no-block /bin/bash /tmp/install_master.sh
|
||||
else
|
||||
nohup bash /tmp/install_master.sh >/dev/null 2>&1 & disown
|
||||
fi
|
||||
nohup bash /tmp/install_master.sh >/dev/null 2>&1 & disown
|
||||
|
||||
# 当前旧进程休眠并等待被幽灵进程处决
|
||||
sleep 10
|
||||
|
||||
@@ -1,22 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# ==========================================================
|
||||
# 脚本名称: uninstall_master.sh (IP-Sentinel Master 一键卸载脚本)
|
||||
# 脚本名称: uninstall_master.sh (IP-Sentinel Master 一键卸载脚本 - 动态锚点版)
|
||||
# 核心功能: 终止调度进程、清理看门狗定时任务、抹除数据库与配置
|
||||
# ==========================================================
|
||||
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "\033[31m❌ 权限被拒绝: 卸载 IP-Sentinel 需要最高系统权限。\033[0m"
|
||||
echo -e "💡 请使用 \033[36msudo bash -c \"\$(curl -fsSL ...)\"\033[0m 执行。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MASTER_DIR="/opt/ip_sentinel_master"
|
||||
CONF_FILE="${MASTER_DIR}/master.conf"
|
||||
|
||||
echo "========================================================"
|
||||
echo " 🗑️ 准备卸载 IP-Sentinel Master (控制中枢)"
|
||||
|
||||
# [v3.4.0 优化] 卸载前读取并播报中枢版本号
|
||||
if [ -f "$CONF_FILE" ]; then
|
||||
MASTER_VER=$(grep "^MASTER_VERSION=" "$CONF_FILE" | cut -d'"' -f2)
|
||||
[ -n "$MASTER_VER" ] && echo " 📍 目标版本: v${MASTER_VER}"
|
||||
@@ -30,21 +25,18 @@ if [[ ! "$CONFIRM_DEL" =~ ^[Yy]$ ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "[1/3] 正在终止后台中枢 Systemd 调度进程..."
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl disable --now ip-sentinel-master.service >/dev/null 2>&1
|
||||
rm -f /etc/systemd/system/ip-sentinel-master.service
|
||||
systemctl daemon-reload
|
||||
systemctl reset-failed
|
||||
fi
|
||||
|
||||
# 1. 停止运行中的 Master 守护进程
|
||||
echo "[1/3] 正在终止后台中枢调度进程..."
|
||||
# [优化] 使用 pkill 替代 pgrep | xargs,指令更短、容错率更高
|
||||
pkill -9 -f "tg_master.sh" >/dev/null 2>&1 || true
|
||||
|
||||
echo "[2/3] 正在清理看门狗定时任务 (Cron)..."
|
||||
# 2. 清除看门狗定时任务 (Cron)
|
||||
echo "[2/3] 正在清理系统定时任务 (Cron)..."
|
||||
crontab -l 2>/dev/null | grep -v "tg_master.sh" > /tmp/cron_backup
|
||||
crontab /tmp/cron_backup
|
||||
rm -f /tmp/cron_backup
|
||||
|
||||
# 3. 删除所有文件、配置与数据库
|
||||
echo "[3/3] 正在抹除核心程序、配置文件与 SQLite 数据库..."
|
||||
if [ -d "$MASTER_DIR" ]; then
|
||||
rm -rf "$MASTER_DIR"
|
||||
|
||||
Reference in New Issue
Block a user