Skip to content

Commit 916b3a2

Browse files
committed
Use systemd service and timer to upload katello tracer
Instead of using cron, use systemd service and timer to upload the katello tracer. This is modern solution which is also supported by SUSE Micro distribution (which does not deliver a cron daemon)
1 parent b2e6957 commit 916b3a2

3 files changed

Lines changed: 46 additions & 13 deletions

File tree

packages/client/katello-host-tools/katello-host-tools-4.5.0.tar.gz

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../.git/annex/objects/pG/55/SHA256E-s26387--b7068ad6abd8cfa0c691d0241b8cd5b9448ee9e7b8d2f8768451ead3bc87e58b.tar.gz/SHA256E-s26387--b7068ad6abd8cfa0c691d0241b8cd5b9448ee9e7b8d2f8768451ead3bc87e58b.tar.gz

packages/client/katello-host-tools/katello-host-tools.spec

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
%global zypper_install (0%{?suse_version} > 0)
44
%global build_tracer 0%{?rhel} >= 7 || 0%{?fedora} || 0%{?suse_version}
55

6+
%if 0%{?suse_version}
7+
%define pkg_systemd_post() %service_add_post %{*}
8+
%define pkg_systemd_preun() %service_del_preun %{*}
9+
%define pkg_systemd_postun() %service_del_postun %{*}
10+
%else
11+
%define pkg_systemd_post() %systemd_post %{*}
12+
%define pkg_systemd_preun() %systemd_preun %{*}
13+
%define pkg_systemd_postun() %systemd_postun %{*}
14+
%endif
15+
616
%if 0%{?suse_version}
717
%define dist suse%{?suse_version}
818
%endif
@@ -33,8 +43,8 @@
3343
%global katello_libdir %{python_libdir}/katello
3444

3545
Name: katello-host-tools
36-
Version: 4.5.0
37-
Release: 2%{?dist}
46+
Version: 4.6.0
47+
Release: 1%{?dist}
3848
Summary: A set of commands and yum plugins that support a Katello host
3949
Group: Development/Languages
4050
%if 0%{?suse_version}
@@ -54,6 +64,8 @@ BuildArch: noarch
5464
%endif
5565

5666
Requires: subscription-manager
67+
Requires: systemd
68+
BuildRequires: systemd-rpm-macros systemd
5769
Obsoletes: %{name}-fact-plugin < %{version}-%{release}
5870
Obsoletes: katello-agent < %{version}-%{release}
5971

@@ -98,11 +110,6 @@ BuildArch: noarch
98110
Summary: Adds Tracer functionality to a client managed by katello-host-tools
99111
Group: Development/Languages
100112
Requires: %{name} = %{version}-%{release}
101-
%if 0%{?suse_version}
102-
Requires: cronie
103-
%else
104-
Requires: crontabs
105-
%endif
106113
%if %{yum_install}
107114
Requires: python2-tracer >= 0.6.12
108115
%endif
@@ -208,9 +215,12 @@ mkdir -p %{buildroot}%{_sbindir}
208215
cp extra/katello-tracer-upload-dnf %{buildroot}%{_sbindir}/katello-tracer-upload
209216
%endif
210217

211-
# crontab
212-
mkdir -p %{buildroot}%{_sysconfdir}/cron.d/
213-
cp extra/katello-tracer-upload.cron %{buildroot}%{_sysconfdir}/cron.d/katello-tracer-upload
218+
# tracer systemd service and timer
219+
install -Dp -m0644 extra/katello-tracer-upload.service.in %{buildroot}%{_unitdir}/katello-tracer-upload.service
220+
install -Dp -m0644 extra/katello-tracer-upload.timer %{buildroot}%{_unitdir}/katello-tracer-upload.timer
221+
222+
# replace @SBIN_PATH@ in the service file with the actual path to the executable
223+
sed -i "s|@SBIN_PATH@|%{_sbindir}|" %{buildroot}%{_unitdir}/katello-tracer-upload.service
214224
%endif
215225

216226
%clean
@@ -223,6 +233,25 @@ katello-enabled-repos-upload 2> /dev/null
223233
exit 0
224234
%endif
225235

236+
%if %{build_tracer}
237+
%post tracer
238+
%pkg_systemd_post katello-tracer-upload.timer
239+
240+
if [ "$1" -eq 1 ]; then
241+
systemctl enable --now katello-tracer-upload.timer >/dev/null 2>&1 || :
242+
fi
243+
244+
%preun tracer
245+
%pkg_systemd_preun katello-tracer-upload.timer
246+
247+
if [ "$1" -eq 0 ]; then
248+
systemctl disable --now katello-tracer-upload.timer >/dev/null 2>&1 || :
249+
fi
250+
251+
%postun tracer
252+
%pkg_systemd_postun katello-tracer-upload.timer
253+
%endif
254+
226255
%files
227256
%defattr(-,root,root,-)
228257
%if 0%{?rhel} == 6
@@ -273,7 +302,6 @@ exit 0
273302
%dir %{_usr}/lib/zypp
274303
%dir %{_usr}/lib/zypp/plugins
275304
%dir %{plugins_dir}
276-
%dir %{_sysconfdir}/cron.d/
277305
%{plugins_dir}/tracer_upload.py
278306
%else
279307
%if %{yum_install}
@@ -284,12 +312,17 @@ exit 0
284312
%endif
285313
%{katello_libdir}/tracer
286314
%{plugins_confdir}/tracer_upload.conf
287-
%config(noreplace) %attr(0644, root, root) %{_sysconfdir}/cron.d/katello-tracer-upload
315+
%{_unitdir}/katello-tracer-upload.service
316+
%{_unitdir}/katello-tracer-upload.timer
288317
%attr(750, root, root) %{_sbindir}/katello-tracer-upload
289318
%endif
290319

291320

292321
%changelog
322+
* Tue Jun 09 2026 Bernhard Suttner <suttner@atix.de> - 4.6.0-1
323+
- Use systemd timer implementation instead of cron based
324+
solution for tracer upload
325+
293326
* Wed Nov 05 2025 Bernhard Suttner <suttner@atix.de> - 4.5.0-2
294327
- Fix missing /etc/cron.d/ dir for SLES / OBS build.
295328

0 commit comments

Comments
 (0)