# Regen-conf hooks in app's package

**URL:** https://forum.yunohost.org/t/regen-conf-hooks-in-apps-package/41236
**Category:** Apps packaging
**Tags:** english
**Created:** [January 4, 2026, 9:59pm UTC](https://forum.yunohost.org/t/regen-conf-hooks-in-apps-package/41236 "2026-01-04T21:59:34Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Krakinou](https://forum.yunohost.org/user_avatar/forum.yunohost.org/krakinou/32/1702_2.png) [@Krakinou](https://forum.yunohost.org/u/Krakinou)
#### Post date: [January 4, 2026, 9:59pm UTC](https://forum.yunohost.org/t/regen-conf-hooks-in-apps-package/41236/1 "2026-01-04T21:59:34Z")

</div>

Hi there,

I’m trying to set a nginx conf\_regen hook in my app.

The [packaging documentation](https://doc.yunohost.org/fr/dev/packaging/advanced/hooks#how-to-add-a-hook-in-an-app-package) 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](https://doc.yunohost.org/fr/dev/packaging/advanced/hooks#conf_regen) 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 🙂

---

<div class="post-metadata">

### Author: ![orhtej2](https://forum.yunohost.org/user_avatar/forum.yunohost.org/orhtej2/32/8943_2.png) [@orhtej2](https://forum.yunohost.org/u/orhtej2)
#### Post date: [January 4, 2026, 11:21pm UTC](https://forum.yunohost.org/t/regen-conf-hooks-in-apps-package/41236/2 "2026-01-04T23:21:41Z")

</div>

See [Nextcloud](https://github.com/YunoHost-Apps/nextcloud_ynh/tree/master/hooks) for inspiration, add `hooks` dir and core will take care of placing them where needed.

---

<div class="post-metadata">

### Author: ![Krakinou](https://forum.yunohost.org/user_avatar/forum.yunohost.org/krakinou/32/1702_2.png) [@Krakinou](https://forum.yunohost.org/u/Krakinou)
#### Post date: [January 5, 2026, 12:07pm UTC](https://forum.yunohost.org/t/regen-conf-hooks-in-apps-package/41236/3 "2026-01-05T12:07:45Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Aleks](https://forum.yunohost.org/user_avatar/forum.yunohost.org/aleks/32/1704_2.png) [@Aleks](https://forum.yunohost.org/u/Aleks)
#### Post date: [January 5, 2026, 12:41pm UTC](https://forum.yunohost.org/t/regen-conf-hooks-in-apps-package/41236/4 "2026-01-05T12:41:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Krakinou](https://forum.yunohost.org/user_avatar/forum.yunohost.org/krakinou/32/1702_2.png) [@Krakinou](https://forum.yunohost.org/u/Krakinou)
#### Post date: [January 5, 2026, 12:52pm UTC](https://forum.yunohost.org/t/regen-conf-hooks-in-apps-package/41236/5 "2026-01-05T12:52:51Z")

</div>

Thanks for this answer, so I will do it the old way and manually manage the hook in the various scripts.

I will make a proposal to change the documentation too 🙂

---

<div class="post-metadata">

### Author: ![Krakinou](https://forum.yunohost.org/user_avatar/forum.yunohost.org/krakinou/32/1702_2.png) [@Krakinou](https://forum.yunohost.org/u/Krakinou)
#### Post date: [January 6, 2026, 9:49pm UTC](https://forum.yunohost.org/t/regen-conf-hooks-in-apps-package/41236/6 "2026-01-06T21:49:21Z")

</div>

ok, so strange behavior : Here is my code :

```auto
mkdir -p /etc/yunohost/hooks.d/conf_regen
ynh_config_add --template="regenconf_nginx" --destination="/etc/yunohost/hooks.d/conf_regen/19-nginx_$app"
yunohost tools regen-conf nginx

```

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.

Is that on purpose or is it a bug?
