[fix] Rewrite scriptlet conditions

This commit is contained in:
samuel 2023-02-02 17:51:32 +01:00
parent 139c6beab6
commit 5ff10a2b86
1 changed files with 11 additions and 2 deletions

View File

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