Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

override logrotate.timer from another package?

118 views
Skip to first unread message

Harald Dunkel

unread,
Jul 4, 2023, 5:40:06 AM7/4/23
to
Hi folks,

what is the recommended way to override logrotate.timer from a
metapackage to get hourly logfile rotation (depending on size
and age of the logfile, as usual)?

I had added

etc/systemd/system/logrotate.timer.d/hourly.conf

to the package install file, but at upgrade time it complained
that nobody ran systemctl daemon-reload. Ain't this the job of
the DEBHELPER macro in the postinst script?

Should this file be installed in /lib/systemd/system/logrotate.timer.d
instead, using dh_installsystemd ?


Every insightful is highly appreciated

Harri

Charles Curley

unread,
Jul 4, 2023, 8:40:06 AM7/4/23
to
On Tue, 4 Jul 2023 11:09:18 +0200
Harald Dunkel <harald...@aixigo.com> wrote:

> I had added
>
> etc/systemd/system/logrotate.timer.d/hourly.conf
>
> to the package install file, but at upgrade time it complained
> that nobody ran systemctl daemon-reload. Ain't this the job of
> the DEBHELPER macro in the postinst script?

No, it is not. You must do it manually, once you've made all the
changes you plan to make. Systemd is pretty powerful, but it doesn't
read your mind.

>
> Should this file be installed in /lib/systemd/system/logrotate.timer.d
> instead, using dh_installsystemd ?

No. All changes the local administrator makes should go under
/etc/systemd because you risk updates over-writing things in
/lib/systemd and elsewhere.

As for dh_installsystemd, the first paragraph of the man page for it
says,

dh_installsystemd is a debhelper program that is responsible for
installing package maintainer supplied systemd unit files.

Are you doing this as a package maintainer?

--
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/

Tim Woodall

unread,
Jul 4, 2023, 1:40:06 PM7/4/23
to
On Tue, 4 Jul 2023, Harald Dunkel wrote:

> Hi folks,
>
> what is the recommended way to override logrotate.timer from a
> metapackage to get hourly logfile rotation (depending on size
> and age of the logfile, as usual)?
>
> I had added
>
> etc/systemd/system/logrotate.timer.d/hourly.conf

I'm not exactly clear what you're doing but I guess you're creating a
package that provides the config file?

Sticking config files in packages can be problematic when it comes to
upgrades. I do it a lot, in particular it makes it much easier to change
the config across lots of machines, but doing it all "properly" in the
face of local edits isn't easy.

Others would probably say use ansible (or something like that) but
it works for me.

>
> to the package install file, but at upgrade time it complained
> that nobody ran systemctl daemon-reload. Ain't this the job of
> the DEBHELPER macro in the postinst script?
>
Once your package is installed, what does the postinst script look like?


> Should this file be installed in /lib/systemd/system/logrotate.timer.d
> instead, using dh_installsystemd ?
>

Assuming you are creating a package and you want to share it with
possible local edits in /etc then this would be the way to go. If, like
me, you're using a package in place of manually editing then /etc is
more likely the right place.

Harald Dunkel

unread,
Jul 5, 2023, 6:50:07 AM7/5/23
to
On 2023-07-04 14:36:19, Charles Curley wrote:
>
> No. All changes the local administrator makes should go under
> /etc/systemd because you risk updates over-writing things in
> /lib/systemd and elsewhere.
>
> As for dh_installsystemd, the first paragraph of the man page for it
> says,
>
> dh_installsystemd is a debhelper program that is responsible for
> installing package maintainer supplied systemd unit files.
>
> Are you doing this as a package maintainer?
>
Yes. Its my own metapackage to be installed on all our hosts in the
office to establish certain configuration standards, like hourly log
file rotation, our own certificates, a standard set of packages to be
installed, etc.

Actually I've got a set of about 50 metapackages for Debian by now,
describing development hosts, laptop setups, virtualization servers,
different GUI configurations, VPNs, and so on. This could have been
done by ansible or others as well, but when I started this there was
no ansible.

Point is, if I add a config file to /etc/systemd/system/logrotate.timer.d
using my own package, then it seems to be off-limits somehow. The
daemon-reload is not run, and systemctl revert logrotate.timer will
wipe out the file provided by my package as well, without confirmation
dialog. That doesn't seem right.


Regards
Harri

Harald Dunkel

unread,
Jul 5, 2023, 7:10:06 AM7/5/23
to
Hi Tim,

On 2023-07-04 19:35:35, Tim Woodall wrote:
> On Tue, 4 Jul 2023, Harald Dunkel wrote:
>
> I'm not exactly clear what you're doing but I guess you're creating a
> package that provides the config file?
>

Yes, together with other things (other config files, package depen-
dencies, etc).

>
> Others would probably say use ansible (or something like that) but
> it works for me.
>
>>
>> to the package install file, but at upgrade time it complained
>> that nobody ran systemctl daemon-reload. Ain't this the job of
>> the DEBHELPER macro in the postinst script?
>>
> Once your package is installed, what does the postinst script look like?
>
It looks like this

#!/bin/bash -e
:
# some bash function definitions
:
case "$1" in
configure)
set_distro
set_debconf_defaults
adjust_ssh_config
adjust_sshd_config
adjust_login_defs
cleanup_logrotate
cleanup_old_garbage
systemctl daemon-reload || echo ignored
;;

abort-upgrade|abort-remove|abort-deconfigure)
;;

triggered)
cleanup_logrotate
;;

*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

#DEBHELPER#

exit 0

I had expected the systemctl daemon-reload is added by
DEBHELPER, but it isn't.

>
>> Should this file be installed in /lib/systemd/system/logrotate.timer.d
>> instead, using dh_installsystemd ?
>>
>
> Assuming you are creating a package and you want to share it with
> possible local edits in /etc then this would be the way to go. If, like
> me, you're using a package in place of manually editing then /etc is
> more likely the right place.
>

Thank you very much for your detailed reply. I will try to override
logrotate.timer in /lib, as you suggested.


Regards

Harri

Charles Curley

unread,
Jul 5, 2023, 1:20:06 PM7/5/23
to
On Wed, 5 Jul 2023 12:30:21 +0200
Harald Dunkel <harald...@aixigo.com> wrote:

> On 2023-07-04 14:36:19, Charles Curley wrote:
> [...]
> Yes. Its my own metapackage to be installed on all our hosts in the
> office to establish certain configuration standards, like hourly log
> file rotation, our own certificates, a standard set of packages to be
> installed, etc.

Ah, that does change things. Sorry about the incorrect assumption.

>
> Actually I've got a set of about 50 metapackages for Debian by now,
> describing development hosts, laptop setups, virtualization servers,
> different GUI configurations, VPNs, and so on. This could have been
> done by ansible or others as well, but when I started this there was
> no ansible.

An interesting concept.

>
> Point is, if I add a config file to
> /etc/systemd/system/logrotate.timer.d using my own package, then it
> seems to be off-limits somehow. The daemon-reload is not run, and
> systemctl revert logrotate.timer will wipe out the file provided by
> my package as well, without confirmation dialog. That doesn't seem
> right.

Right.

Which puts you in a bit of a dilemma. You could create a file under
/lib/systemd, but then you run the risk of some future package update
stomping on your file. I suppose you could give yourself a private
pseudo-namespace, and call the file something like
30.aixigo.hourly.conf.


>
>
> Regards
> Harri
0 new messages