Regen-conf not executed

Hi there,

I want to add a value to the postfix main.cf and tried to stick to the method of using a regen-conf hook.
Unfortunately it seems like this script is never executed.

How can I confirm, if the hook is executed, or am I doing something really wrong?

Thanks for your help
Samuel

/etc/yunohost/hooks.d/conf-regen/02-postfix-regex-aliases

#!/bin/bash

action=$1
pending_dir=$4
postfix_conf=$pending_dir/../postfix/etc/postfix/main.cf

# Check if everything is in place
[[ $action == "pre" ]] || exit 0
[[ -e $postfix_conf ]] || exit 0

awk -i inplace '{if (/^virtual_alias_maps = /) {$0=$0 ",regexp:/etc/postfix/aliases-regexp"}; print}' $postfix_conf

Probably the issue is with the name of the script … You might want to name it just 02-postfix

1 Like

As Aleks says, The name must be of the form: xx-postfix_whateveryouwant
xx is a number, it must be higher than 19 otherwise the default configuration will overwrite your modification. See /usr/share/yunohost/hooks/conf_regen to determine the number, each service has a different number.

Then, your script must be rename like 20-postfix_regexaliases

2 Likes

Hi,

thank you for your suggestions.

I just renamed it to 20-postfix_regexaliases.

Still it seems like it’s not getting executed.

Do you have another idea?

Thank you1

Where is your script? It must be in the folder /etc/yunohost/hooks.d/conf_regen/

Did you run:

yunohost tools regen-conf postfix --force

You can check the main.cf file:

grep virtual_alias_maps main.cf

The result must be:

virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf,regexp:/etc/postfix/aliases-regexp

1 Like

Hi,

from the title in nano:
/etc/yunohost/hooks.d/conf-regen/20-postfix_regexaliases

I did run

yunohost tools regen-conf postfix --force

I checked the main.cf afterwards. I meant, maybe there are debug logs indicating whether the script was executed or if there was a problem executing.

Thanks for your help!

Humm…perhaps with --debug option to see how the regen-conf is run?

You can use the options --dry-run to show what would have been regenerated and --with-diff to show differences in case of configuration changes.

I recommend you to delete your script (or move it elsewhere) and regen-conf --force to restore the original version of main.cf. Then you can try after putting the script in /etc/yunohost/hooks.d/conf-regen:

yunohost tools regen-conf postfix --force --dry-run --with-diff

If it’s OK, you can use the --debug option to see details:

yunohost tools regen-conf postfix --force --debug

I just test your script with --dry-run --with-diff and it’s OK , there’s no problem. I don’t understand why it don’t run for you:

yunohost tools regen-conf postfix --force -n -d        
Success! The configuration would have been updated for category 'postfix'
postfix: 
  applied: 
    /etc/postfix/main.cf: 
      diff: @@ -91,7 +91,7 @@
 virtual_mailbox_domains = ldap:/etc/postfix/ldap-domains.cf
 virtual_mailbox_maps = ldap:/etc/postfix/ldap-accounts.cf
 virtual_mailbox_base =
-virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf
+virtual_alias_maps = ldap:/etc/postfix/ldap-aliases.cf,regexp:/etc/postfix/aliases-regexp
 virtual_alias_domains =
 virtual_minimum_uid = 100
 virtual_uid_maps = static:vmail
      status: updated

Whoa,

I’m puzzled.

I just deleted the whole conf-regen directory and recreated it, incuding the 20-postfix_regexaliases file.

Still, if I run

yunohost tools regen-conf postfix --force --dry-run --with-diff

It doesn’t show my modification but only the unaltered main.cf file.

I don’t get it…

It’s strange!
Could you run in debug mode please. And give the access right:

ls -la /etc/yunohost/hooks.d/conf_regen/
yunohost tools regen-conf postfix --force -n -d --debug
1 Like

Oh, no.

I found the issue.

The directory i had the script in was conf-regen but it should have been conf_regen.

Thank you so much for your help, it works now - as expected.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.