✨ feat(bookSource): 聚合书源支持弹窗段评并兼容官方阅读
- showCmt 能力检测:魔改版(有 showBrowser)原地弹窗(点遮罩关闭/80%高度),官方版降级 startBrowser - 弹窗预载 ajax 强制 https,规避反代 301 拿到空内容 - jsLib 函数不再引用规则变量 baseUrl(作用域隔离),fqTab 显式传参 - bookList 返回数组对象;ruleBookInfo 以 init 提取 data;searchUrl 改用局部变量并 encodeURIComponent
This commit is contained in:
1 parent
067a2816d9
commit
99826c6d25
2 files changed
+98
-49
No files matched your search
@@ -7,6 +7,10 @@
|
||||
# ./deploy.sh v1.2.0 # 编译 + 部署(指定版本)
|
||||
# ./deploy.sh v1.2.0 --init # 首次初始化(写 systemd/nginx 配置)
|
||||
# ./deploy.sh v1.2.0 --no-pull # 跳过 git pull
|
||||
# ./deploy.sh v1.2.0 --no-autostart # 部署后不开机自启
|
||||
# ./deploy.sh v1.2.0 --no-restart # 只部署,不重启服务
|
||||
# ./deploy.sh --stop # 停止服务
|
||||
# ./deploy.sh --start # 启动服务
|
||||
# ./deploy.sh --build-only # 只编译,不部署
|
||||
# ./deploy.sh --rollback # 交互式回滚到指定版本
|
||||
# ./deploy.sh --rollback v1.0.0 # 直接回滚到指定版本
|
||||
@@ -39,6 +43,7 @@ CERT_EMAIL="${CERT_EMAIL:-admin@${DOMAIN}}" # 证书申请邮箱(过期提醒
|
||||
BUILD_TARGET="${BUILD_TARGET:-./cmd/fanqie}" # go build 的包路径
|
||||
ENV_FILE="${ENV_FILE:-${SRC_DIR}/.env}" # 应用环境变量(.env.example 为模板)
|
||||
KEEP_VERSIONS="${KEEP_VERSIONS:-5}" # 保留最近几个版本
|
||||
AUTO_START="${AUTO_START:-true}" # 服务是否开机自启(--no-autostart 覆盖)
|
||||
|
||||
# ==================== 颜色与日志 ====================
|
||||
C_GREEN='\033[1;32m'; C_YELLOW='\033[1;33m'; C_RED='\033[1;31m'; C_BLUE='\033[1;34m'; C_RESET='\033[0m'
|
||||
@@ -63,6 +68,10 @@ ROLLBACK_VERSION=""
|
||||
LIST=false
|
||||
FORCE=false
|
||||
SYNC_NGINX=false
|
||||
AUTO_START="${AUTO_START:-true}"
|
||||
NO_RESTART=false
|
||||
STOP=false
|
||||
START=false
|
||||
|
||||
print_help() {
|
||||
cat <<EOF
|
||||
@@ -71,6 +80,10 @@ print_help() {
|
||||
选项:
|
||||
--init 首次初始化,写入 systemd 和 nginx 配置
|
||||
--no-pull 跳过 git pull
|
||||
--no-autostart 服务不设置开机自启(默认自启)
|
||||
--no-restart 只部署不重启服务(自启设置仍会应用)
|
||||
--stop 停止服务后退出
|
||||
--start 启动服务后退出
|
||||
--build-only 只编译,不部署、不重启服务
|
||||
--force, -f 允许覆盖已存在的同名版本(默认报错退出)
|
||||
--rollback [版本] 回滚到指定版本(不带版本号则交互式选择)
|
||||
@@ -96,6 +109,10 @@ while [ $i -lt ${#ARGS[@]} ]; do
|
||||
case "$arg" in
|
||||
--init) INIT=true ;;
|
||||
--no-pull) NO_PULL=true ;;
|
||||
--no-autostart) AUTO_START=false ;;
|
||||
--no-restart) NO_RESTART=true ;;
|
||||
--stop) STOP=true ;;
|
||||
--start) START=true ;;
|
||||
--build-only) BUILD_ONLY=true ;;
|
||||
--rollback)
|
||||
ROLLBACK=true
|
||||
@@ -171,19 +188,35 @@ cleanup_old_versions() {
|
||||
done
|
||||
}
|
||||
|
||||
# 重启服务 + 验证
|
||||
restart_and_verify() {
|
||||
log "重启 ${APP_NAME} 服务..."
|
||||
# 注意:不要用 "list-unit-files | grep -q"——grep -q 提前退出会让 systemctl 收到
|
||||
# SIGPIPE,在 pipefail 下整条管道判假(unit 多的机器必踩),误报"服务不存在"
|
||||
if systemctl cat "${APP_NAME}" >/dev/null 2>&1; then
|
||||
$SUDO systemctl restart "${APP_NAME}"
|
||||
# 应用开机自启设置(AUTO_START 由 --no-autostart / .deploy.env 决定)
|
||||
apply_autostart() {
|
||||
if [ "$AUTO_START" = true ]; then
|
||||
$SUDO systemctl enable "${APP_NAME}" >/dev/null 2>&1 || true
|
||||
else
|
||||
$SUDO systemctl disable "${APP_NAME}" >/dev/null 2>&1 || true
|
||||
info "开机自启已禁用(--no-autostart)"
|
||||
fi
|
||||
}
|
||||
|
||||
# 重启服务 + 验证
|
||||
restart_and_verify() {
|
||||
# 注意:不要用 "list-unit-files | grep -q"——grep -q 提前退出会让 systemctl 收到
|
||||
# SIGPIPE,在 pipefail 下整条管道判假(unit 多的机器必踩),误报"服务不存在"
|
||||
if ! systemctl cat "${APP_NAME}" >/dev/null 2>&1; then
|
||||
warn "服务 ${APP_NAME}.service 不存在,请先执行 $0 --init"
|
||||
return 0
|
||||
fi
|
||||
|
||||
apply_autostart
|
||||
|
||||
if [ "$NO_RESTART" = true ]; then
|
||||
info "跳过服务重启(--no-restart),需要时执行: sudo systemctl restart ${APP_NAME}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log "重启 ${APP_NAME} 服务..."
|
||||
$SUDO systemctl restart "${APP_NAME}"
|
||||
|
||||
if command -v nginx >/dev/null 2>&1; then
|
||||
$SUDO systemctl reload nginx 2>/dev/null || $SUDO nginx -s reload 2>/dev/null || true
|
||||
fi
|
||||
@@ -342,6 +375,20 @@ if [ "$SYNC_NGINX" = true ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ==================== --stop / --start ====================
|
||||
if [ "$STOP" = true ] || [ "$START" = true ]; then
|
||||
systemctl cat "${APP_NAME}" >/dev/null 2>&1 || { err "服务 ${APP_NAME}.service 不存在,请先执行 $0 --init"; exit 1; }
|
||||
if [ "$STOP" = true ]; then
|
||||
$SUDO systemctl stop "${APP_NAME}"
|
||||
log "✅ 已停止 ${APP_NAME}(开机自启设置不变)"
|
||||
else
|
||||
$SUDO systemctl start "${APP_NAME}"
|
||||
sleep 1
|
||||
$SUDO systemctl status "${APP_NAME}" --no-pager -l | head -n 15 || true
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ==================== --rollback ====================
|
||||
if [ "$ROLLBACK" = true ]; then
|
||||
if [ ! -d "${BIN_DIR}" ]; then
|
||||
|
||||
Reference in new issue
Block a user