La regola del progetto è «codice e commenti in inglese; interfaccia, documenti e messaggi in italiano», e gli script di .gitea/ (script e flussi), di installer/ e docker/entrypoint.sh avevano ancora i commenti in italiano (decisione di Alberto del 29 novembre 2026). Cambiano solo i commenti: i messaggi che una persona legge (echo, ::warning::, ::error::, nomi dei passi, note della release) restano in italiano e nessun comando cambia. I programmi awk e gli script finti delle prove erano già in inglese. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
4.4 KiB
Bash
Executable File
80 lines
4.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# Febe: container start (specification §11).
|
|
#
|
|
# It does only three things and then hands over to the server:
|
|
# 1. creates, if missing, the group PGID and the user PUID (on Unraid 99 and 100, «nobody:users»);
|
|
# 2. makes /dati owned by that user (the first time, or if PUID/PGID changed) and has it prepare /dati/home;
|
|
# 3. execs the server with setpriv, as that user: the server starts and watches Xvfb and Chromium by itself.
|
|
# Always exec, never a child process: the server takes the place of this script as process 1 of the container
|
|
# (no tini), receives SIGTERM from «docker stop» and, with the .NET runtime, reaps the orphaned processes.
|
|
# No watch loop here: that is the job of Febe.Server (no shell script acting as a supervisor).
|
|
# /libreria is never changed recursively (it holds Alberto's photos); /importa is read only and is not touched;
|
|
# of /esporta (the external copies, specification §4.10) only the root is assigned, never recursively, and only if
|
|
# the external copies are declared (FEBE_ESPORTA=1 or --esporta).
|
|
# If /dati cannot be fixed (network disk, permissions) it starts anyway: Febe explains the problem on its page,
|
|
# instead of a container that restarts without saying why.
|
|
set -eu
|
|
|
|
PUID="${PUID:-99}"
|
|
PGID="${PGID:-100}"
|
|
|
|
# Already started as a normal user (docker run --user ...): nothing to change.
|
|
if [ "$(id -u)" != "0" ]; then
|
|
exec "$@"
|
|
fi
|
|
|
|
if [ "${PUID}" = "0" ]; then
|
|
echo "Febe: PUID=0 non è ammesso. Il browser di Febe non gira come root: indica l'utente dei file (su Unraid PUID=99, PGID=100)." >&2
|
|
exit 64
|
|
fi
|
|
|
|
if ! getent group "${PGID}" >/dev/null 2>&1; then
|
|
groupadd -g "${PGID}" febe
|
|
fi
|
|
|
|
if ! getent passwd "${PUID}" >/dev/null 2>&1; then
|
|
useradd -o -u "${PUID}" -g "${PGID}" -M -d /dati/home -s /usr/sbin/nologin febe
|
|
fi
|
|
|
|
# /dati belongs to the PUID user, who can put anything in it, even symbolic links to files of the container: as root
|
|
# nothing is written in there. The only thing done as root is the change of owner, recursive and without following
|
|
# links (-R without -H/-L: it changes the link, never what it points to). The rest is done by the user itself.
|
|
if mkdir -p /dati 2>/dev/null; then
|
|
da_assegnare=""
|
|
[ "$(stat -c '%u:%g' /dati)" = "${PUID}:${PGID}" ] || da_assegnare=1
|
|
# A /dati/home with another owner (an earlier start as root): only a real folder counts.
|
|
if [ -d /dati/home ] && [ ! -L /dati/home ] && [ "$(stat -c '%u:%g' /dati/home)" != "${PUID}:${PGID}" ]; then
|
|
da_assegnare=1
|
|
fi
|
|
if [ -n "${da_assegnare}" ]; then
|
|
echo "Febe: assegno /dati a ${PUID}:${PGID}."
|
|
chown -R "${PUID}:${PGID}" /dati 2>/dev/null || echo "Febe: non riesco ad assegnare /dati a ${PUID}:${PGID}." >&2
|
|
fi
|
|
chmod 0750 /dati 2>/dev/null || true
|
|
# Chromium's HOME is created and locked by the user, with its own permissions.
|
|
setpriv --reuid="${PUID}" --regid="${PGID}" --init-groups sh -c 'mkdir -p /dati/home && chmod 0700 /dati/home' 2>/dev/null || true
|
|
# The seccomp profile no longer lives in /dati: Docker reads it on the server when the container is created, and in
|
|
# /dati the container's user could loosen it. It is kept outside the data volume (docs/docker.md, «Sandbox»).
|
|
if [ -e /dati/seccomp.json ] || [ -L /dati/seccomp.json ]; then
|
|
echo "Febe: /dati/seccomp.json non si aggiorna più. Se --security-opt seccomp= indica quel file, sposta il profilo fuori dalla cartella dei dati (su Unraid /mnt/user/appdata/febe-seccomp.json): vedi docs/docker.md, «Sandbox»." >&2
|
|
fi
|
|
fi
|
|
|
|
# A library folder just created by Docker belongs to root: only that folder, without recursion.
|
|
if [ -d /libreria ] && [ "$(stat -c '%u' /libreria)" = "0" ]; then
|
|
chown "${PUID}:${PGID}" /libreria 2>/dev/null || true
|
|
fi
|
|
|
|
# /esporta: only the root, never recursive, and only if the external copies are declared (SPECIFICA §4.10). Inside
|
|
# there are Alberto's files copied by Febe or put there by him: they are never changed. Febe does not create /esporta
|
|
# if it is missing.
|
|
case "${FEBE_ESPORTA:-}" in 1|true|sì|si|yes) esporta=1 ;; *) esporta= ;; esac
|
|
case " $* " in *" --esporta "*) esporta=1 ;; esac
|
|
if [ -n "$esporta" ] && [ -d /esporta ] && [ "$(stat -c '%u' /esporta)" = "0" ]; then
|
|
chown "${PUID}:${PGID}" /esporta 2>/dev/null || true
|
|
fi
|
|
|
|
export HOME=/dati/home
|
|
echo "Febe: avvio come utente ${PUID}, gruppo ${PGID}, fuso ${TZ:-Europe/Rome}, lingua ${LANG:-it_IT.UTF-8}."
|
|
exec setpriv --reuid="${PUID}" --regid="${PGID}" --init-groups "$@"
|