From 3c14447ef9a26544e3764aa329c376ae0488c1f7 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Tue, 13 Jun 2023 14:48:43 +0200 Subject: [PATCH] Debian: add service and post installation script to create user and group --- debian/numerus.postinst | 40 ++++++++++++++++++++++++++++++++++++++++ debian/numerus.service | 15 +++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 debian/numerus.postinst create mode 100644 debian/numerus.service diff --git a/debian/numerus.postinst b/debian/numerus.postinst new file mode 100644 index 0000000..a5d30f3 --- /dev/null +++ b/debian/numerus.postinst @@ -0,0 +1,40 @@ +#!/bin/sh +set -e + +. /usr/share/debconf/confmodule + +case "$1" in + configure) + # Create numerus user and group + if ! getent group numerus >/dev/null; then + addgroup --system --quiet numerus + fi + if ! getent passwd numerus >/dev/null; then + adduser --quiet \ + --system \ + --disabled-login \ + --no-create-home \ + --shell /bin/bash \ + --ingroup numerus \ + --home /usr/share/numerus \ + --gecos "Numerus Daemon" \ + numerus + fi + + # Make sure log directory has correct permissions set + dpkg-statoverride --list "/var/log/numerus" >/dev/null || \ + dpkg-statoverride --add --force --quiet --update numerus adm 0750 /var/log/numerus + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/debian/numerus.service b/debian/numerus.service new file mode 100644 index 0000000..0d0c62d --- /dev/null +++ b/debian/numerus.service @@ -0,0 +1,15 @@ +[Unit] +Description=Numerus application server +Requires=postgresql.service +After=postgresql.service + +[Service] +Type=simple +User=numerus +Group=numerus +WorkingDirectory=/usr/share/numerus +EnvironmentFile=-/etc/default/numerus +ExecStart=/usr/bin/numerus +Restart=always +StandardOutput=append:/var/log/numerus/access.log +StandardError=append:/var/log/numerus/error.log