Files
Auto_Bangumi/entrypoint.sh
Estrella Pan f14ab65574 fix: address stable-review findings across config, update, downloader
Ship-readiness review of main...3.3-dev (multi-agent + codex verify pass)
surfaced 10 confirmed defects; all fixed with red-first tests (+24):

- config: masked list secrets restored by identity match, not index —
  deleting/reordering a notification provider no longer corrupts the
  survivor's credentials; unresolvable masks return 400 instead of guessing
- statics: mount dist/fonts — self-hosted Inter 404'd in every production
  build and the whole UI fell back to OS fonts
- boot_overlay: chown replaced trees to the app user (crash-loop under
  UMASK=077); snapshot-and-restore around the EXDEV in-place fallback so a
  mid-copy failure can't gut /app/module
- updater: rollback refuses to swap without the retained signed backup
  bundle — reverts to image version honestly instead of half-swapping
- qbittorrent: credential-failure latch (cleared on settings save) plus
  single-flighted auth sharing the negative result with queued waiters —
  failed logins no longer accumulate into a WebUI IP ban
- download_client: holder refcount registered before auth (no mid-login
  close), stale clients accumulated in a list (no pool leak on rapid
  settings saves), holder released on cancellation during __aenter__
- entrypoint: ownership marker written only after chown -R succeeds
- aria2: torrents_info provides num_seeds/num_leechs/eta/added_on and maps
  states to qB vocabulary (UI showed undefined / NaNhNaNm / raw states)
- program API: deprecated GET aliases for /restart /start /stop /shutdown
  (3.2 automation compatibility)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FAxVyRwrY7z5NotTtgnwVs
2026-07-06 16:37:28 +02:00

67 lines
2.3 KiB
Bash
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/bash
# shellcheck shell=bash
umask ${UMASK}
if [ -f /config/bangumi.json ]; then
mv /config/bangumi.json /app/data/bangumi.json
# Created as root by the mv; the gated chown below may skip the tree walk,
# so fix this one legacy file explicitly.
chown ab:ab /app/data/bangumi.json
fi
groupmod -o -g "${PGID}" ab
usermod -o -u "${PUID}" ab
# 重启循环让 shell 站在 tini 和应用之间,因此必须自己转发信号并等待
# 应用退出,否则 docker stop 时 shell 先死、tini 跟着退出,python 会被
# SIGKILL 打断(SQLite WAL 来不及落盘)。
child=""
forward_signal() {
if [ -n "${child}" ]; then
kill -TERM "${child}" 2>/dev/null
wait "${child}"
exit $?
fi
exit 0
}
trap forward_signal TERM INT
while true; do
# 应用持久卷中的在线更新覆盖层(在启动应用前、以 root 运行)。脚本内部已全程
# 兜底 try/except,这里再加 `|| true`:覆盖层失败绝不能阻断容器启动。
python /app/boot_overlay.py || true
# Recursive chown of the mounted volumes is O(files): a large poster cache
# on a NAS makes it the dominant cost of every container start. Only walk
# the tree when ownership actually needs fixing — first run or a changed
# PUID/PGID — recorded by a marker. /home/ab is image-internal and tiny, so
# chown it every time.
chown ab:ab -R /home/ab
own_marker="/app/config/.ab_owner"
want="${PUID}:${PGID}"
if [ "$(cat "${own_marker}" 2>/dev/null)" != "${want}" ] ||
[ "$(stat -c '%u:%g' /app/data 2>/dev/null)" != "${want}" ] ||
[ "$(stat -c '%u:%g' /app/config 2>/dev/null)" != "${want}" ]; then
# 先 chown、后写 marker:中途被打断(停容器/崩溃)或部分失败
# (NAS/root-squash 报错)时下次启动必须重跑树遍历,否则半途的
# 属主状态被记成"已完成"、永不自愈。
if chown ab:ab -R /app/data /app/config; then
echo "${want}" >"${own_marker}"
fi
fi
su-exec "${PUID}:${PGID}" python main.py &
child=$!
wait "${child}"
status=$?
child=""
if [ -f /app/config/updates/.restart ]; then
rm -f /app/config/updates/.restart
continue
fi
exit "${status}"
done