%undefine _missing_build_ids_terminate_build %define debug_package %{nil} Name: netoik-api Version: %(make version) Release: 1%{?dist} Summary: Netoik rest API server License: GPLv3 URL: https://www.netoik.io/api Source0: %{name}-%{version}.tar.gz Buildarch: x86_64 BuildRequires: make %description Netoik rest API server %prep %autosetup -v %build %make_build %install %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 # Stop service only if uninstalling. if [ $1 -eq 0 ]; then systemctl disable --now %{name}-server.service fi %postun # 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} %attr(755, %{name}, %{name}) %dir %{_var}/%{name}/captcha %attr(755, root, root) %dir %{_sysconfdir}/%{name} %attr(644, root, root) %{_sysconfdir}/%{name}/server.conf.sample %attr(644, root, root) %config(noreplace) %{_sysconfdir}/%{name}/server.conf %attr(644, root, root) %{_unitdir}/%{name}-server.service %attr(755, root, root) %{_bindir}/%{name}-server