Skip to content

Add support for /etc/dhcpcd/hooks/ #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
perkelix opened this issue Mar 26, 2025 · 7 comments
Open

Add support for /etc/dhcpcd/hooks/ #494

perkelix opened this issue Mar 26, 2025 · 7 comments

Comments

@perkelix
Copy link
Contributor

In its current form, dhcpcd ships its configured hooks in --libexecdir and its extra sample hooks in /usr/share/dhcpcd/hooks/.

It would be desirable for dhcpcd to also source e.g. /etc/dhcpcd/hooks/ for administrator-added scripts.

At the same time, it would be desirable for BUILDING.md or README.md to document the existence of EGHOOKSCRIPTS and explain the difference with HOOKSCRIPTS.

@rsmarples
Copy link
Member

Administrator added scripts are /etc/dhcpcd.enter-hook and /etc/dhcpcd.exit-hook.
If the admin wants to source a directory inside these scripts they are more than welcome to.

@rsmarples
Copy link
Member

At the same time, it would be desirable for BUILDING.md or README.md to document the existence of EGHOOKSCRIPTS and explain the difference with HOOKSCRIPTS.

BUILDING.md already has this:

Not all the hooks in dhcpcd-hooks are installed by default.
By default we install 01-test, 20-resolv.confand 30-hostname.
The other hooks, 10-wpa_supplicant, 15-timezone and 29-lookup-hostname
are installed to $(datadir)/dhcpcd/hooks by default and need to be
copied to $(libexecdir)/dhcpcd-hooks for use.

I think it's already explained there?

@perkelix
Copy link
Contributor Author

That still doesn't tell us which one is which or what configure keys to use for either case.

@rsmarples
Copy link
Member

datadir defaults to /usr/share and libexecdir defaults to /libexec. I used the gnu configure variables here to make life easy I thought?

@perkelix
Copy link
Contributor Author

perkelix commented Apr 16, 2025

The variables' name remains opaque. It leaves downstream guessing.

--with-hooks="timesyncd.conf"

...apparently results in:

HOOKSCRIPTS = 50-timesyncd.conf

I emphasize apparently because it I wouldn't have known without experimenting with the configure options, which is how –among other thigns– I found out that --with-hooks expects filenames without the numeric prefix.

What option would populate the EGHOOKSCRIPTS line and what it's used for remains opaque.

"We install this here and that there" doesn't tell us much. i.e. BUILDING.md needs to show an example for both cases:

Not all the hooks in dhcpcd-hooks are installed by default. By default, we install 01-test, 20-resolv.confand 30-hostname into $(libexecdir)/dhcpcd-hooks for use. The other hooks, 10-wpa_supplicant, 15-timezone and 29-lookup-hostname are installed as examples into $(datadir)/dhcpcd/hooks by default. The configure program attempts to find hooks for daemons you have installed. These will appear on the HOOKSCRIPTS line in configure's output, along with any hook added using the --with-hooks option without the numeric prefix e.g. ./configure -with-hook=ntp.conf

This leaves EGHOOKSCRIPTS undocumented.

@perkelix
Copy link
Contributor Author

perkelix commented Apr 19, 2025

Looking into the source code for dhcpcd-run-hooks, I notice:

for hook in \
    @SYSCONFDIR@/dhcpcd.enter-hook \
    @HOOKDIR@/* \
    @SYSCONFDIR@/dhcpcd.exit-hook
do

Could this possibly be converted to:

for hook in \
    @SYSCONFDIR@/dhcpcd/enter-hooks.d/* \
    @HOOKDIR@/* \
    @SYSCONFDIR@/dhcpcd/exit-hooks.d/*
do

...for upcoming releases, @rsmarples? This would probably accomplish what was requested at Debian.

@rsmarples
Copy link
Member

Sorry for not doing anything on this for a while. If we're going to have an /etc/dhcpcd to avoid putting many things directly into /etc then we should move the config layout as well. Maybe something like this?

/etc/dhcpcd
    ./dhcpcd.conf
    ./enter-hook
    ./enter-hooks.d/
    ./exit-hooks.d/
    ./exit-hook

/etc/dhcpcd could then be a symlink to /var/chroot/dhcpcd/etc/dhcpcd if we ever need dhcpcd.conf inside the chroot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants