Pre(un) and post(un) script changed

This commit is contained in:
2019-02-22 10:13:19 +01:00
parent aff2b9423e
commit 852e7fc7c1

View File

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