diff --git a/fedora/SPECS/polemarch.spec b/fedora/SPECS/polemarch.spec index 8d183d4..e83e467 100644 --- a/fedora/SPECS/polemarch.spec +++ b/fedora/SPECS/polemarch.spec @@ -49,34 +49,40 @@ Simply WEB gui for orchestration infrastructure by ansible playbooks. # Blocks %files %defattr(-,%{user},%{user},-) -/opt/polemarch -/etc/%{namebase} -/var/log/%{namebase} -/var/run/%{namebase} -/var/lock/%{namebase} -%attr(755,root,root) /etc/systemd/system/%{shortname}.service -%attr(755,root,root) /etc/tmpfiles.d/%{namebase}.conf +%dir /opt/polemarch +%{_sysconfdir}/%{namebase} +%{_var}/log/%{namebase} +%{_rundir}/%{namebase} +%{_var}/lock/%{namebase} +%attr(755,root,root) %{_sysconfdir}/systemd/system/%{shortname}.service +%attr(755,root,root) %{_sysconfdir}/tmpfiles.d/%{namebase}.conf %config(noreplace) %{_sysconfdir}/%{namebase}/settings.ini -%pre -id -u %{user} || useradd %{user} -id -g %{user} || groupadd %{user} - %install make BUILD_DIR=%{buildroot} install %{S:1} %{buildroot}%{_sysconfdir}/%{namebase}/settings.ini bash %{S:2} +%pre +getent group %{user} >/dev/null || \ + groupadd -r %{user} +getent passwd %{user} >/dev/null || \ + useradd -r -g %{user} -d %{user} \ + -s /sbin/nologin -c "%{user} user" %{user} +exit 0 + %post +%systemd_post %{name}.service +# only migrate, if it is an update +if [ $2 -eq 1 ]; then su - %{user} -c "/opt/%{name}/bin/%{shortname}ctl migrate" -/usr/bin/systemctl daemon-reload -/usr/bin/systemctl enable %{shortname}.service +fi %preun -/usr/bin/systemctl disable %{shortname}.service > /dev/null 2>&1 -if [ "$1" = "0" ]; then - service %{shortname} stop >/dev/null 2>&1 -fi +%systemd_preun %{name}.service + +%postun +%systemd_postun_with_restart %{name}.service %prep %setup -q -n %name-%version