Files
Chronos/deploy/docker/entrypoint.sh
T
Alby96andClaude Opus 5.5 8d41992d84 feat: Chronos Desktop shares its library on the LAN (owner review 5 P4)
Chronos Server for Windows is replaced by Settings > Server > Share this
library: Chronos Desktop hosts the server engine in its own process over its
own index, archive and processing services, job engine and scheduler, so a
second PC, the Uploader and render nodes use this PC's library without a
Windows service or a second index.

- Chronos.Server is a library; Chronos.Server.Host is the console exe that
  Docker and development runs start. The App references the library and the
  ASP.NET Core shared framework (no package).
- ServerHost.BuildHosted/HostedServer: reuses the desktop's engines and
  never creates, starts or disposes them; no static log sink, no console
  lifetime; server.json plus desktop-owned values locked "Set in Chronos
  Desktop"; only upload-cleanup and audit-cleanup schedules are added.
- Both modes: by-id endpoints scoped to the served archive, a client's
  render export folder dropped; hosted mode exposes server job kinds only.
- Desktop: LibraryShare (start after the schedules, stop first, port in
  use named), Settings > Server sharing rows, Server > This library panel
  (state, addresses with Copy, ports, fingerprint, temporary admin
  password, clients, admin panel), own library refused by ConnectFlow and
  dropped from LAN discovery, the uploads sweep step, thumbnails after scans
  while sharing, capture scenes server-share and server-share-failed.
- Removed: the Windows service hosting of Chronos.Server, its switches and
  its tests.

Refs #67

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:55:50 +01:00

69 lines
3.2 KiB
Bash
Executable File

#!/bin/sh
# Runs Chronos Server as PUID:PGID (Unraid/NAS convention). The data folder is owned by that user. The archive is left
# as mounted (it may hold terabytes) and only checked for write access; only when that user cannot write it and the
# folder is empty or owned by root (Docker creates a missing bind source or a fresh volume that way) is the folder
# itself, never its contents, given to PUID:PGID.
set -eu
PUID="${PUID:-1000}"
PGID="${PGID:-1000}"
DATA="${CHRONOS_DATA_PATH:-/data}"
ARCHIVE="${CHRONOS_ARCHIVE_PATH:-/archive}"
VIDEOS="${CHRONOS_VIDEOS_PATH:-}"
umask 002
# Help and the health probe touch neither folder.
case "${1:-}" in
--help | -h | -\? | /\? | --healthcheck) exec dotnet /app/Chronos.Server.Host.dll "$@" ;;
esac
as_user() {
setpriv --reuid="$PUID" --regid="$PGID" --clear-groups -- "$@"
}
if [ "$(id -u)" = "0" ]; then
mkdir -p "$DATA" "$ARCHIVE"
chown -R "$PUID:$PGID" "$DATA"
if ! as_user test -w "$ARCHIVE"; then
if [ -z "$(ls -A "$ARCHIVE")" ] || [ "$(stat -c %u "$ARCHIVE")" = "0" ]; then
owner="$(stat -c %u:%g "$ARCHIVE")"
if chown "$PUID:$PGID" "$ARCHIVE" 2>/dev/null; then
echo "chronos: $ARCHIVE belonged to $owner; it now belongs to $PUID:$PGID (the folder only, not its contents)"
fi
fi
if ! as_user test -w "$ARCHIVE"; then
echo "error: $ARCHIVE is not writable by $PUID:$PGID; give that user write access to the archive folder on the host, or set PUID and PGID to its owner" >&2
exit 1
fi
fi
# The server writes into the archive's .chronos folders at once (staging, trash, locks); one left to root by an
# earlier run as root, or copied in by root, would stop it in a restart loop. Reported, never chowned.
for dir in "$ARCHIVE/.chronos" "$ARCHIVE/.chronos"/*/; do
if [ -d "$dir" ] && ! as_user test -w "$dir"; then
echo "error: ${dir%/} is not writable by $PUID:$PGID; give that user write access to it on the host (for example chown -R $PUID:$PGID <archive>/.chronos)" >&2
exit 1
fi
done
# The videos folder (optional) is treated as the archive is, except that a problem only warns: copying fails with its
# reason in the admin panel until it is fixed, and everything else runs.
if [ -n "$VIDEOS" ] && [ -d "$VIDEOS" ]; then
if command -v mountpoint >/dev/null 2>&1 && ! mountpoint -q "$VIDEOS"; then
echo "warning: $VIDEOS is not a mounted volume: copies to the videos folder stay inside the container and are lost when it is replaced; map a host folder to $VIDEOS" >&2
fi
if ! as_user test -w "$VIDEOS"; then
if [ -z "$(ls -A "$VIDEOS")" ] || [ "$(stat -c %u "$VIDEOS")" = "0" ]; then
owner="$(stat -c %u:%g "$VIDEOS")"
if chown "$PUID:$PGID" "$VIDEOS" 2>/dev/null; then
echo "chronos: $VIDEOS belonged to $owner; it now belongs to $PUID:$PGID (the folder only, not its contents)"
fi
fi
if ! as_user test -w "$VIDEOS"; then
echo "warning: $VIDEOS is not writable by $PUID:$PGID; copies to the videos folder fail until that user can write it" >&2
fi
fi
fi
exec setpriv --reuid="$PUID" --regid="$PGID" --clear-groups -- dotnet /app/Chronos.Server.Host.dll "$@"
fi
exec dotnet /app/Chronos.Server.Host.dll "$@"