SHA256
1
0
forked from pool/pgbadger

Accepting request 1153509 from home:emilianolangella

Systemd unit files installed during the %install phase and other adjustments.

OBS-URL: https://build.opensuse.org/request/show/1153509
OBS-URL: https://build.opensuse.org/package/show/server:database:postgresql/pgbadger?expand=0&rev=7
This commit is contained in:
Reinhard Max 2024-03-04 14:15:19 +00:00 committed by Git OBS Bridge
parent 27da9c69f9
commit b03df37ae5
3 changed files with 39 additions and 34 deletions

View File

@ -1,6 +1,6 @@
Dear customer, Dear customer,
we provide two examples in this directory, which might help you We provide a cron job and a systemd timer and service, which might help you
implementing an automatism for pgbadger on your local systems. implementing an automatism for pgbadger on your local systems.
Security considerations: Security considerations:
@ -83,23 +83,23 @@ Now it's time to work on the automation.
= Using a cron job = Using a cron job
For historical reasons, we provide a small cron script in the following For historical reasons, we provide a small cron script for older distrubutions
folder, that can be adjusted to your needs: in the following
/usr/share/doc/packages/pgbadger/example/pgbadger-cron.sh folder, that you can adjust to your needs:
/etc/cron.d/
Just place the file into the /etc/cron.d/ directory and adjust it to your needs:
cp -v /usr/share/doc/packages/pgbadger/example/pgbadger-cron.sh /etc/cron.d/pgbadger
= Using systemd timer = Using systemd timer
This is the recommended way. This is the recommended way.
Copy the needed files to your /etc/systemd/system directory: Please adjust the following systemd timer and unit (see comments inline) to
your needs:
cp -v /usr/share/doc/packages/pgbadger/example/pgbadger.timer /etc/systemd/system/ systemctl edit pgbadger.timer
cp -v /usr/share/doc/packages/pgbadger/example/pgbadger.service /etc/systemd/system/ systemctl edit pgbadger.service
Once done, please adjust the files (see comments inline) to your needs.
After that, please enable the systemd timer with the following two After that, please enable the systemd timer with the following two
commands: commands:
@ -107,13 +107,6 @@ commands:
systemctl enable pgbadger.timer systemctl enable pgbadger.timer
---- ----
And remember to have a lot of fun! And remember to have a lot of fun!
Your SUSE Team. Your SUSE Team.

View File

@ -1 +0,0 @@
addFilter("missing-dependency-to-crontabs")

View File

@ -36,10 +36,9 @@ Url: https://pgbadger.darold.net/
Group: System/Monitoring Group: System/Monitoring
Source0: https://github.com/darold/%{name}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz Source0: https://github.com/darold/%{name}/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: %{name}-cron Source1: %{name}-cron
Source2: %{name}-rpmlintrc Source2: %{name}.timer
Source3: %{name}.timer Source3: %{name}.service
Source4: %{name}.service Source4: README.SUSE
Source5: README.SUSE
BuildRequires: cron BuildRequires: cron
BuildRequires: perl BuildRequires: perl
BuildRequires: perl(Getopt::Long) BuildRequires: perl(Getopt::Long)
@ -68,9 +67,12 @@ Requires: perl(Encode)
Requires: perl(Text::Wrap) Requires: perl(Text::Wrap)
Requires: perl(Time::Local) Requires: perl(Time::Local)
Requires: perl = %{perl_version} Requires: perl = %{perl_version}
%{?systemd_ordering}
%if %{with cron} %if %{with cron}
Recommends: cron Recommends: cron
%endif %endif
# handle package rename at 2023-11-27: # handle package rename at 2023-11-27:
Obsoletes: PgBadger < %{version} Obsoletes: PgBadger < %{version}
Provides: PgBadger = %{version}-%{release} Provides: PgBadger = %{version}-%{release}
@ -111,34 +113,45 @@ make test
%install %install
%perl_make_install %perl_make_install
%perl_process_packlist %perl_process_packlist
rmdir %{buildroot}%{perl_vendorarch} || : rmdir %{buildroot}%{perl_vendorarch} || :
# prepare docdir and install examples and documentation files mkdir -p %{buildroot}%{_defaultdocdir}/%{name}
mkdir -p %{buildroot}%{_defaultdocdir}/%{name}/examples/ mkdir -p %{buildroot}%{_unitdir}
mv tools %{buildroot}%{_defaultdocdir}/%{name}/ mv tools %{buildroot}%{_defaultdocdir}/%{name}/
mv ChangeLog README* %{buildroot}%{_defaultdocdir}/%{name}/ mv ChangeLog README* %{buildroot}%{_defaultdocdir}/%{name}/
%if %{with cron} %if %{with cron}
# keep the old behavior for now and install the cron job example into the cron directory: # keep the old behavior for now and install the cron job into the cron directory:
install -Dm 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/cron.d/%{name} install -Dm 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/cron.d/%{name}
%else
install -m 0644 %{SOURCE1} %{buildroot}%{_defaultdocdir}/%{name}/examples/pgbadger-cron.sh
%endif %endif
# install systemd-timer examples into the documentation directory: leave it to our # install the systemd timer and service in /usr/lib/systemd/system:
# customers to decide, if and how they want to use them install -m 0644 %{SOURCE2} %{buildroot}%{_unitdir}
install -m 0644 %{SOURCE3} %{buildroot}%{_defaultdocdir}/%{name}/examples/ install -m 0644 %{SOURCE3} %{buildroot}%{_unitdir}
install -m 0644 %{SOURCE4} %{buildroot}%{_defaultdocdir}/%{name}/examples/ # install the README.SUSE in the documentation dir:
install -m 0644 %{SOURCE5} %{buildroot}%{_defaultdocdir}/%{name}/ install -m 0644 %{SOURCE4} %{buildroot}%{_defaultdocdir}/%{name}/
%perl_gen_filelist %perl_gen_filelist
%pre
%service_add_pre pgbadger.timer pgbadger.service
%post
%service_add_post pgbadger.timer pgbadger.service
%preun
%service_del_preun pgbadger.timer pgbadger.service
%postun
%service_del_postun pgbadger.timer pgbadger.service
%files -f %{name}.files %files -f %{name}.files
%license LICENSE %license LICENSE
%defattr(-, root, root, -) %defattr(-, root, root, -)
%dir %{_defaultdocdir}/%{name} %dir %{_defaultdocdir}/%{name}
%dir %{_defaultdocdir}/%{name}/tools %dir %{_defaultdocdir}/%{name}/tools
%dir %{_defaultdocdir}/%{name}/examples
%{_defaultdocdir}/%{name}/* %{_defaultdocdir}/%{name}/*
%{_bindir}/pgbadger %{_bindir}/pgbadger
%{_mandir}/man1/pgbadger.1* %{_mandir}/man1/pgbadger.1*
%{_unitdir}/%{name}.timer
%{_unitdir}/%{name}.service
%if %{with cron} %if %{with cron}
%config(noreplace) %{_sysconfdir}/cron.d/%{name} %config(noreplace) %{_sysconfdir}/cron.d/%{name}
%endif %endif