2025-08-23 23:51:37 +02:00
|
|
|
#!/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
|
2025-08-24 18:46:37 +02:00
|
|
|
addgroup --system --quiet skyview
|
2025-08-23 23:51:37 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ! getent passwd skyview >/dev/null 2>&1; then
|
|
|
|
|
adduser --system --ingroup skyview --home /var/lib/skyview \
|
2025-08-24 18:46:37 +02:00
|
|
|
--no-create-home --disabled-password --quiet skyview
|
2025-08-23 23:51:37 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Create directories with proper permissions
|
2025-08-24 18:46:37 +02:00
|
|
|
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
|
2025-08-23 23:51:37 +02:00
|
|
|
|
2025-08-24 18:24:08 +02:00
|
|
|
# Set permissions on config files
|
2025-08-23 23:51:37 +02:00
|
|
|
if [ -f /etc/skyview/config.json ]; then
|
2025-08-24 18:46:37 +02:00
|
|
|
chown root:skyview /etc/skyview/config.json >/dev/null 2>&1 || true
|
|
|
|
|
chmod 640 /etc/skyview/config.json >/dev/null 2>&1 || true
|
2025-08-23 23:51:37 +02:00
|
|
|
fi
|
|
|
|
|
|
2025-08-24 18:24:08 +02:00
|
|
|
|
2025-08-24 18:46:37 +02:00
|
|
|
# Handle systemd service
|
|
|
|
|
systemctl daemon-reload >/dev/null 2>&1 || true
|
2025-08-23 23:51:37 +02:00
|
|
|
|
2025-08-24 18:46:37 +02:00
|
|
|
# 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
|
2025-08-23 23:51:37 +02:00
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
exit 0
|