From 5ff10a2b86de188b1c66419e1d0acfd408e77908 Mon Sep 17 00:00:00 2001 From: samuel Date: Thu, 2 Feb 2023 17:51:32 +0100 Subject: [PATCH] [fix] Rewrite scriptlet conditions --- netoik-api.spec | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/netoik-api.spec b/netoik-api.spec index 56a065a..741432e 100644 --- a/netoik-api.spec +++ b/netoik-api.spec @@ -26,18 +26,27 @@ Netoik rest API server %make_install %pre +# Create user only if not already exisiting. id %{name} || useradd --no-create-home --shell=%{_sbindir}/nologin --user-group %{name} %post +# Reload systemctl daemon and (re)start service. systemctl daemon-reload systemctl restart %{name}-server.service systemctl enable %{name}-server.service %preun -[ $1 -eq 0 ] && systemctl stop %{name}-server.service +# Stop service only if uninstalling. +if [ $1 -eq 0 ]; then + systemctl disable --now %{name}-server.service +fi %postun -[ $1 -eq 0 ] && systemctl daemon-reload && userdel %{name} +# Reload systemctl daemon and remove netoik-api user only if uninstalling. +if [ $1 -eq 0 ]; then + systemctl daemon-reload + userdel %{name} +fi %files %attr(755, root, root) %dir %{_var}/%{name}