Skip to content
Snippets Groups Projects
Commit 57994e74 authored by Markus Frosch's avatar Markus Frosch
Browse files

Add systemd service

parent 6e793aaf
No related branches found
No related tags found
No related merge requests found
Pipeline #5152 failed
[Unit]
Description=Icinga vSphereDB Daemon
Documentation=https://icinga.com/docs/icinga-vsphere/latest/
Wants=network.target
[Service]
Type=notify
User=icingaweb2
ExecStart=/usr/bin/icingacli vspheredb daemon run
; For debugging purposes:
; ExecStart=/usr/bin/icingacli vspheredb daemon run --trace --debug
User=icingaweb2
NotifyAccess=main
WatchdogSec=10
Restart=on-failure
RestartSec=30
[Install]
WantedBy=multi-user.target
......@@ -17,6 +17,10 @@ Source0: https://github.com/Icinga/icingaweb2-module-%{module_name}/archi
BuildArch: noarch
%global basedir %{_datadir}/icingaweb2/modules/%{module_name}
%global service_name icinga-%{module_name}
BuildRequires: systemd-devel
Requires: systemd
Requires: icingaweb2 >= %{icingaweb_min_version}
Requires: php-Icinga >= %{icingaweb_min_version}
......@@ -74,12 +78,44 @@ mkdir -p %{buildroot}%{basedir}
cp -r * %{buildroot}%{basedir}
install -d %{buildroot}%{_unitdir}
install -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{service_name}.service
%if "%{_vendor}" == "suse"
install -d %{buildroot}%{_sbindir}
ln -sf /usr/sbin/service %{buildroot}%{_sbindir}/rc%{service_name}
%endif # suse
%clean
rm -rf %{buildroot}
%pre
%if "%{_vendor}" == "suse"
%service_add_pre %{service_name}.service
%endif # suse
exit 0
%post
set -e
%if "%{_vendor}" == "suse"
%service_add_post %{service_name}.service
%else # suse
%systemd_post %{service_name}.service
%endif # suse
exit 0
%preun
set -e
%if "%{_vendor}" == "suse"
%service_del_preun %{service_name}.service
%else # suse
%systemd_preun %{service_name}.service
%endif # suse
# Only for removal
if [ $1 == 0 ]; then
echo "Disabling icingaweb2 module '%{module_name}'"
......@@ -88,12 +124,29 @@ fi
exit 0
%postun
set -e
%if "%{_vendor}" == "suse"
%service_del_postun %{service_name}.service
%else # suse
%systemd_postun_with_restart %{service_name}.service
%endif # suse
exit 0
%files
%doc README.md LICENSE
%defattr(-,root,root)
%{basedir}
%{_unitdir}/%{service_name}.service
%if "%{_vendor}" == "suse"
%{_sbindir}/rc%{service_name}
%endif # suse
%changelog
* Fri Aug 30 2019 Markus Frosch <markus.frosch@icinga.com> - 1.0.4-1
- Initial package version
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment