Files
wrong-notebook/packaging/qnap/shared/wrongnotebook.sh
margrop 45988361a2 feat: 群晖与威联通套件内置镜像,安装时无需联网拉取
- 发版时等同一标签的镜像推送后用 skopeo 按架构导出,套件按 x86_64 / arm64 分别出包
- 群晖经 docker-project 的 preload-image 加载;威联通把归档放进架构目录,启动时 docker load
- 威联通启动时本地已有该版本镜像就不再联网拉取,重启和断网时不依赖镜像仓库;升级后清理旧版本镜像
- 不传 --image 时仍生成在线拉取镜像的 noarch 套件,用于本地调试
2026-11-11 17:16:34 +08:00

63 lines
1.7 KiB
Bash
Executable File
Raw Permalink 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
if [ -d /share/Container ]; then
DATA_ROOT=/share/Container/wrong-notebook
else
DATA_ROOT="${QPKG_DIR}/data-root"
fi
WN_DATA_DIR="${DATA_ROOT}/data"
WN_CONFIG_DIR="${DATA_ROOT}/config"
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"
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