Debian: add service and post installation script to create user and group

This commit is contained in:
jordi fita mas 2023-06-13 14:48:43 +02:00
parent d79ddc6731
commit 3c14447ef9
2 changed files with 55 additions and 0 deletions

40
debian/numerus.postinst vendored Normal file
View File

@ -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

15
debian/numerus.service vendored Normal file
View File

@ -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