skyview/debian/DEBIAN/postinst

39 lines
1.3 KiB
Text
Raw Normal View History

#!/bin/bash
set -e
case "$1" in
configure)
# Create skyview user and group if they don't exist
if ! getent group skyview >/dev/null 2>&1; then
addgroup --system --quiet skyview
fi
if ! getent passwd skyview >/dev/null 2>&1; then
adduser --system --ingroup skyview --home /var/lib/skyview \
--no-create-home --disabled-password --quiet skyview
fi
# Create directories with proper permissions
mkdir -p /var/lib/skyview /var/log/skyview >/dev/null 2>&1 || true
chown skyview:skyview /var/lib/skyview /var/log/skyview >/dev/null 2>&1 || true
chmod 755 /var/lib/skyview /var/log/skyview >/dev/null 2>&1 || true
# Set permissions on config files
if [ -f /etc/skyview/config.json ]; then
chown root:skyview /etc/skyview/config.json >/dev/null 2>&1 || true
chmod 640 /etc/skyview/config.json >/dev/null 2>&1 || true
fi
# Handle systemd service
systemctl daemon-reload >/dev/null 2>&1 || true
# Check if service was previously enabled
if systemctl is-enabled skyview >/dev/null 2>&1; then
# Service was enabled, restart it
systemctl restart skyview >/dev/null 2>&1 || true
fi
;;
esac
exit 0