forked from zingolabs/zaino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
44 lines (38 loc) · 1.52 KB
/
Copy pathentrypoint.sh
File metadata and controls
44 lines (38 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
# Entrypoint for running Zaino in a container.
#
# The container MUST run as a non-root user. If started as root, the
# entrypoint exits immediately with an error.
#
# Configuration is managed by config-rs using defaults, optional TOML, and
# environment variables prefixed with ZAINO_.
#
# NOTE: This script only handles directories specified via environment variables
# or the defaults below. If you configure custom paths in a TOML config file,
# you are responsible for ensuring those directories exist with appropriate
# permissions before starting the container.
set -eo pipefail
if [[ "$(id -u)" == '0' ]]; then
echo "ERROR: Refusing to run as root. Run this container as a non-root user." >&2
exit 1
fi
# Default writable paths.
# The Dockerfile creates symlinks: /app/config -> ~/.config/zaino, /app/data -> ~/.cache/zaino
# So we handle /app/* paths directly for container users.
#
# Database path (symlinked from ~/.cache/zaino)
: "${ZAINO_STORAGE__DATABASE__PATH:=/app/data}"
#
# Cookie dir (runtime, ephemeral)
: "${ZAINO_JSON_SERVER_SETTINGS__COOKIE_DIR:=${XDG_RUNTIME_DIR:-/tmp}/zaino}"
#
# Config directory (symlinked from ~/.config/zaino)
ZAINO_CONFIG_DIR="/app/config"
# Create directories if they don't exist
for dir in "${ZAINO_STORAGE__DATABASE__PATH}" "${ZAINO_JSON_SERVER_SETTINGS__COOKIE_DIR}" "${ZAINO_CONFIG_DIR}"; do
[[ -z "${dir}" ]] && continue
if ! mkdir -p "${dir}" 2>/dev/null; then
echo "WARN: Cannot create ${dir} (read-only or permission denied), skipping" >&2
fi
done
exec zainod "$@"