#!/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" 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" "$@"