I’m trying to set a nginx conf_regen hook in my app.
The packaging documentation says : “In the hooks dir, create a bash script called with the type of hook you want to create for example post_create_user.”
The conf_regen documentation says : “follow the naming convention dd-sss_xxx. dd are 2 digits and should be higher than the ones from the default hook (present in /usr/share/yunohost/hooks/conf_regen). sss is a string that defines the kind of hook (eg. ssh or postfix). xxx is a free field to help remind what is inside that hook”
So what should be the name of my file in the hook folder so that yunohost core install it as dd_nginx_whatever ?
Also, does someone knows how the digit (dd) are given by yunohost core?
I guess I can set the conf regen script in etc/yunohost/hooks.d myself during the installation, but it does not feel right
Yes I did, but nextcloud uses post_user_create and post_user_delete, not conf_regen. So it does not need to add these info about which config to regen: If i add a file conf_regen in the folder hooks, how will yunohost knows that it’s for nginx, postfix or whatever?
It’s a mess, there’s no “clean” way imho. The regen-conf hooks are a specific case imho for two reason :
a) typically you want your regen-conf hook to “overload” an existing one, for example to tweak the nginx or postfix configuration. Hence the weird name convention xx_nginx_whatever with the priority (xx) and service name. Whereas the other hooks such as post_create_user are more “independent from each other”.
b) typically you’ll want to run the modified regenconf during the app install by calling yunohost tools regen-conf nginx or something alone those line. But YunoHost will only add the hooks shipped in the app’s hooks/ folder after the app install completes, not before or during. So you end up having to copy your file manually for it to work …
Tbf this whole mechanism was designed like 10 years ago and didn’t really change despite what we learned about the use cases etc. Maybe there will be some improvements to the whole story for packaging v3
the strange thing is that the hooks disappears after the installation: the nginx config is correctly setup, but the hooks is not there anymore. It seems that there is some kind of clean up mechanism at the end of the installation that delete the hook.
If i place the hook in /usr/share/yunohost/hooks/conf_regen, in this case it is not deleted.