spec: install systemd unit
Thanks-To: sketch242 <github@rednsx.org> Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Alon Bar-Lev committed
Apr 2, 2016 at 19:36 UTC
8443257227f6670abaf630280c168764666fc161
1 file changed
+30
netdata.spec.in
+30
@@ -1,3 +1,9 @@
1
+%if 0%{?fedora} || 0%{?rhel} >= 7
2
+%global do_systemd 1
3
+%else
4
+%global do_systemd 0
5
+%endif
6
+
7
Summary: Linux real time system monitoring, over the web
8
Name: @PACKAGE_NAME@
9
Version: @PACKAGE_RPM_VERSION@
@@ -14,6 +20,12 @@ Requires: zlib
20
BuildRequires: libnetfilter_acct-devel
21
Requires: libnetfilter_acct
22
%endif
23
+%if 0%{do_systemd}
24
+BuildRequires: systemd
25
+Requires(post): systemd
26
+Requires(preun): systemd
27
+Requires(postun): systemd
28
+%endif
29
30
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
31
@@ -24,6 +36,15 @@ Real-time performance monitoring, in the greatest possible detail!
36
getent group netdata > /dev/null || groupadd -r netdata
37
getent passwd netdata > /dev/null || useradd -r -g netdata -c netdata -s /sbin/nologin -d / netdata
38
39
+%if 0%{do_systemd}
40
+%post
41
+%systemd_post netdata.service
42
+%preun
43
+%systemd_preun netdata.service
44
+%postun
45
+%systemd_postun_with_restart netdata.service
46
+%endif
47
+
48
%global ovirt_create_user_engine \
49
%_ovirt_create_user %{engine_user} %{engine_uid} %{engine_group} %{engine_gid} "%{ovirt_user_description}" %{engine_state}
50
@@ -48,6 +69,11 @@ rm -rf "%{buildroot}"
69
make %{?_smp_mflags} install DESTDIR="%{buildroot}"
70
find "%{buildroot}" -name .keep -exec rm {} \;
71
72
+%if 0%{do_systemd}
73
+install -m 0755 -d "%{buildroot}/%{_unitdir}"
74
+install -m 0644 system/netdata.service "%{buildroot}/%{_unitdir}"
75
+%endif
76
+
77
%files
78
%attr(-, netdata, netdata) %dir %{_localstatedir}/cache/%{name}/
79
%attr(-, netdata, netdata) %dir %{_localstatedir}/log/%{name}/
@@ -56,6 +82,10 @@ find "%{buildroot}" -name .keep -exec rm {} \;
82
%{_libexecdir}/%{name}/
83
%{_sbindir}/%{name}
84
85
+%if 0%{do_systemd}
86
+%{_unitdir}/netdata.service
87
+%endif
88
+
89
%changelog
90
* Tue Mar 22 2016 Costa Tsaousis <costa@tsaousis.gr> - 1.0.0-1
91
- First public release.