A restore, an import or an adopted database restarts protected: the engine stays stopped, reads from the broker what the archive does not know (orders, stops, executions, also from the OKX history up to 89 days), cancels orders left working, protects what it finds and waits for the user. Strategies with real money stay exit only until confirmed again. The database of before the restore, put back by mistake, is refused by its fingerprint. A failed migration leaves the engine off with one backup and a way to try again; an archive is checked whole before the database is touched; a changed secret key no longer crashes anything, and "anubis access reset" gives the access back to whoever holds the computer. The image runs the db and access commands without the guard. refs #69 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.3 KiB
Bash
39 lines
1.3 KiB
Bash
#!/bin/sh
|
|
# Container start (SPEC 15.2, issue #16). As root: prepare /data for PUID:PGID (99:100 on Unraid), then drop to that
|
|
# user with setpriv, which is part of the base image (no gosu). Started as another user (docker run --user): go straight on.
|
|
# The process is the guard (SPEC 9.3, ADR 0012): it starts the engine, watches it and passes the stop on to it.
|
|
set -eu
|
|
|
|
app="/app/Anubis.Guard.dll"
|
|
|
|
# A command ("docker run <immagine> db import ...") runs once and ends: without the guard, which would start it again.
|
|
case "${1:-}" in
|
|
db|access|data|diagnostics|soak)
|
|
app="/app/Anubis.Server.dll"
|
|
;;
|
|
esac
|
|
|
|
if [ "$(id -u)" != "0" ]; then
|
|
exec dotnet "$app" "$@"
|
|
fi
|
|
|
|
uid="${PUID:-99}"
|
|
gid="${PGID:-100}"
|
|
case "$uid$gid" in
|
|
*[!0-9]*|"")
|
|
echo "PUID e PGID devono essere numeri (adesso: PUID=$uid PGID=$gid)." >&2
|
|
exit 64
|
|
;;
|
|
esac
|
|
|
|
mkdir -p /data
|
|
for folder in db models research import backups logs web-keys guard; do
|
|
mkdir -p "/data/$folder"
|
|
done
|
|
# Only what does not already belong to PUID:PGID, so a large data folder does not slow every start.
|
|
find /data -xdev \( ! -user "$uid" -o ! -group "$gid" \) -exec chown -h "$uid:$gid" {} +
|
|
chmod 700 /data
|
|
|
|
export HOME=/tmp
|
|
exec setpriv --reuid="$uid" --regid="$gid" --clear-groups -- dotnet "$app" "$@"
|