From c93dd0fa97fdbaa20c358c1787f10a56160eca83 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Sat, 21 May 2022 12:12:34 +0200 Subject: [PATCH] Add PKGBUILD and systemd files --- PKGBUILD | 26 ++++++++++++++++++++++++++ nummi.service | 19 +++++++++++++++++++ nummi.socket | 9 +++++++++ nummi.sysusers | 1 + nummi.tmpfiles | 1 + nummi/nummi/settings.py | 2 +- 6 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 PKGBUILD create mode 100644 nummi.service create mode 100644 nummi.socket create mode 100644 nummi.sysusers create mode 100644 nummi.tmpfiles diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..98e0439 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,26 @@ +pkgname=nummi +pkgver=0.1.0 +pkgrel=1 +pkgdesc="Web-based accounting interface" +arch=("any") +url="https://git.edgarpierre.fr/edpibu/nummi" +license=("AGPL3") +depends=( + "gunicorn: server" + "python-django: django server" +) +optdepends=("postgresql: database") + +source=( + "${pkgname}" + "${pkgname}.service" + "${pkgname}.socket" +) + +package() { + install -Dm755 ${pkgname}/${pkgname} -t "${pkgdir}"/opt/ + install -Dm644 ${pkgname}.service -t "${pkgdir}"/usr/lib/systemd/system/ + install -Dm644 ${pkgname}.socket -t "${pkgdir}"/usr/lib/systemd/system/ + install -Dm644 ${pkgname}.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/${pkgname}.conf + install -Dm644 ${pkgname}.sysusers "${pkgdir}"/usr/lib/sysusers.d/${pkgname}.conf +} diff --git a/nummi.service b/nummi.service new file mode 100644 index 0000000..1fc3c33 --- /dev/null +++ b/nummi.service @@ -0,0 +1,19 @@ +[Unit] +Description=Nummi server (accounting) +Requires=nummi.socket +After=network.target + +[Service] +Type=notify +User=nummi +Group=nummi +RuntimeDirectory=nummi +WorkingDirectory=/opt/nummi +ExecStart=/usr/bin/gunicorn nummi.asgi:application +ExecReload=/bin/kill -s HUP $MAINPID +KillMode=mixed +TimeoutStopSec=5 +PrivateTmp=true + +[Install] +WantedBy=multi-user.target diff --git a/nummi.socket b/nummi.socket new file mode 100644 index 0000000..23000f1 --- /dev/null +++ b/nummi.socket @@ -0,0 +1,9 @@ +[Unit] +Description=Nummi socket + +[Socket] +ListenStream=/run/nummi.socket +SocketUser=http + +[Install] +WantedBy=sockets.target diff --git a/nummi.sysusers b/nummi.sysusers new file mode 100644 index 0000000..208e626 --- /dev/null +++ b/nummi.sysusers @@ -0,0 +1 @@ +u nummi - "Nummi daemon user" /var/lib/nummi /usr/bin/bash diff --git a/nummi.tmpfiles b/nummi.tmpfiles new file mode 100644 index 0000000..ef1e6bf --- /dev/null +++ b/nummi.tmpfiles @@ -0,0 +1 @@ +d /var/lib/nummi 0750 nummi nummi diff --git a/nummi/nummi/settings.py b/nummi/nummi/settings.py index 6c756bd..6262187 100644 --- a/nummi/nummi/settings.py +++ b/nummi/nummi/settings.py @@ -14,7 +14,7 @@ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent -MEDIA_ROOT = BASE_DIR.joinpath("media") +MEDIA_ROOT = Path("/var/lib/nummi") # Quick-start development settings - unsuitable for production