update
This commit is contained in:
@@ -13,6 +13,19 @@ EnvironmentFile=/etc/bookstack-mcp/env
|
||||
WorkingDirectory=/opt/bookstack-mcp
|
||||
ExecStart=/opt/bookstack-mcp/venv/bin/python -m bookstack_mcp
|
||||
|
||||
# ProtectSystem=strict makes everything read-only, but the MCP library writes
|
||||
# to a data directory under $HOME (OAuth client registrations, caches). The
|
||||
# service user's home is /opt/bookstack-mcp, which is part of the read-only
|
||||
# tree -- so point HOME and the XDG dirs at directories systemd creates and
|
||||
# grants write access to. Without this the service dies with
|
||||
# "OSError: [Errno 30] Read-only file system: '/opt/bookstack-mcp/.local'".
|
||||
StateDirectory=bookstack-mcp
|
||||
CacheDirectory=bookstack-mcp
|
||||
Environment=HOME=/var/lib/bookstack-mcp
|
||||
Environment=XDG_DATA_HOME=/var/lib/bookstack-mcp
|
||||
Environment=XDG_CONFIG_HOME=/var/lib/bookstack-mcp
|
||||
Environment=XDG_CACHE_HOME=/var/cache/bookstack-mcp
|
||||
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
TimeoutStopSec=20s
|
||||
|
||||
+16
-4
@@ -98,12 +98,24 @@ log "Installing Python dependencies (this takes a minute)"
|
||||
chown -R "$SVC_USER:$SVC_USER" "$APP_DIR"
|
||||
|
||||
# --- Configuration --------------------------------------------------------
|
||||
# --- Configuration --------------------------------------------------------
|
||||
# Prefer a filled-in .env if one exists, otherwise fall back to the template.
|
||||
ENV_SRC=""
|
||||
for candidate in "$SRC_DIR/.env" "$SRC_DIR/.env.example"; do
|
||||
[[ -f "$candidate" ]] && { ENV_SRC="$candidate"; break; }
|
||||
done
|
||||
[[ -n "$ENV_SRC" ]] || die "Can't find $SRC_DIR/.env or $SRC_DIR/.env.example to seed the config from."
|
||||
|
||||
mkdir -p "$CONF_DIR"
|
||||
if [[ ! -f "$CONF_DIR/env" ]]; then
|
||||
log "Creating $CONF_DIR/env from the template"
|
||||
# An empty file counts as "not configured" -- a previous failed run can leave
|
||||
# a zero-byte config behind, and silently keeping it is worse than replacing it.
|
||||
if [[ ! -s "$CONF_DIR/env" ]]; then
|
||||
log "Creating $CONF_DIR/env from $(basename "$ENV_SRC")"
|
||||
# systemd EnvironmentFile does not understand quotes or inline comments the
|
||||
# way a shell does, so strip comments and blank lines out of the example.
|
||||
grep -vE '^\s*(#|$)' "$SRC_DIR/.env.example" > "$CONF_DIR/env"
|
||||
# way a shell does, so strip comments and blank lines out of the source.
|
||||
# Write to a temp file first so a failure here can't leave an empty config.
|
||||
grep -vE '^\s*(#|$)' "$ENV_SRC" > "$CONF_DIR/env.tmp"
|
||||
mv "$CONF_DIR/env.tmp" "$CONF_DIR/env"
|
||||
NEW_CONFIG=1
|
||||
else
|
||||
log "Keeping existing $CONF_DIR/env"
|
||||
|
||||
Reference in New Issue
Block a user