favoritter/dist/postinstall.sh
Ole-Morten Duesund f4480dd510 fix: remove chatty install message from postinstall script
README already documents the setup steps. Package install scripts
should be silent on success.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 19:28:22 +02:00

28 lines
1,005 B
Bash
Executable file

#!/bin/sh
# Post-install script for Favoritter .deb/.rpm package.
# Creates the system user, sets directory permissions, and handles upgrades.
#
# Debian/Ubuntu: called with "configure" on install/upgrade.
# RPM: called with 1 on first install, 2+ on upgrade.
set -e
# Create system user if it doesn't exist.
if ! getent passwd favoritter >/dev/null 2>&1; then
useradd -r -s /usr/sbin/nologin -d /var/lib/favoritter favoritter
fi
# Ensure data directories exist with correct ownership.
install -d -o favoritter -g favoritter -m 0750 /var/lib/favoritter
install -d -o favoritter -g favoritter -m 0750 /var/lib/favoritter/uploads
# Reload systemd to pick up any service file changes.
if command -v systemctl >/dev/null 2>&1; then
systemctl daemon-reload
# On upgrade: restart the service if it was running.
# This picks up the new binary without losing enable/disable state.
if systemctl is-active --quiet favoritter 2>/dev/null; then
systemctl restart favoritter
fi
fi