Files
wrong-notebook/packaging/qnap/shared/wrongnotebook.sh
margrop c175cc4538 fix: 修复 QNAP 数据目录丢失、健康检查与密钥暴露
- 数据目录不再回退到会被卸载删除的 QPKG 目录:优先 /share/Container,其次 /share/Public,都不存在时明确报错
- 容器就绪优先检查 docker inspect 的健康状态,无 curl/wget 也可判定,unhealthy 时输出日志
- 容器启动补充日志轮转、WN_PLATFORM=qnap 与 NEXTAUTH_SECRET_FILE,避免密钥出现在命令行和 ps
- 入口脚本支持从 NEXTAUTH_SECRET_FILE 读取已有密钥,兼容旧套件的 config/nextauth-secret
- 补充数据目录、健康检查与容器参数的脚本测试
Refs: https://github.com/margrop/wrong-notebook/issues/114
2026-12-04 01:34:34 +08:00

58 lines
1.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# 威联通 QPKG 服务控制:start / stop / status / restart。
# 套件只负责 Docker 容器;数据放在 Container Station 的 Container 共享目录下,卸载套件不会删除。
set -eu
QPKG_NAME="wrongnotebook"
QPKG_DIR="${QPKG_DIR:-$(/sbin/getcfg "${QPKG_NAME}" Install_Path -f /etc/config/qpkg.conf 2>/dev/null || true)}"
if [ -z "${QPKG_DIR}" ] || [ ! -d "${QPKG_DIR}" ]; then
echo "未找到 QPKG 安装目录" >&2
exit 1
fi
WN_HOST_PORT=39300
WN_IMAGE_TAG="$(cat "${QPKG_DIR}/image-tag" 2>/dev/null || echo 0.0.0)"
# 内置镜像的套件把归档放在安装目录;在线套件没有该文件,启动时联网拉取
WN_IMAGE_ARCHIVE="${QPKG_DIR}/image.tar.gz"
. "${QPKG_DIR}/docker-container.sh"
DATA_ROOT="$(wn_resolve_data_root)" || exit 1
WN_DATA_DIR="${DATA_ROOT}/data"
WN_CONFIG_DIR="${DATA_ROOT}/config"
setup_hint() {
NAS_HOST="$(hostname -f 2>/dev/null || hostname 2>/dev/null || echo NAS)"
echo "错题本已启动:http://${NAS_HOST}:39300/"
if [ -s "${WN_CONFIG_DIR}/setup-token" ]; then
echo "初始化链接:http://${NAS_HOST}:39300/initialize?token=$(cat "${WN_CONFIG_DIR}/setup-token")"
fi
}
start() {
wn_start_container
setup_hint
}
stop() {
wn_stop_container
echo "stopped"
}
status() {
if wn_status_container; then
echo "running"
return 0
fi
echo "stopped"
return 1
}
case "${1:-start}" in
start) start ;;
stop) stop ;;
status) status ;;
restart) stop; sleep 1; start ;;
remove) exit 0 ;;
*) echo "Usage: $0 {start|stop|status|restart|remove}" >&2; exit 1 ;;
esac