How to override bind9 template files?

  • After an i-mscp upgrade, the file /etc/imscp/bind/parts/db.tpl will be overwritten. That's not such a huge problem, as I've written a script to replace the file after the update among other files getting overwritten.


    But now I have the problem, that during the upgrade, all DNS Zonefiles under /var/cache/bind/ will be rewritten based on the default "db.tpl" template. After changing back the template according our needs, we should have a quick method to re-write all DNS Zonefiles again, deriving from our (replaced) Zone template. Is there a possibility besides deactiviating and activiating every single user / domain (should be one of the steps conducted by the system when deactivating or activating a domain)?


    Unfortunatley, that doesn't work:
    http://blog.grufo.com/2010/11/…template-geaendert-wurde/
    (used imscp instead of ispcp of course!)


    Thank you very much for a short hint as it's very painful to fiddle with each single user within the GUI...

  • Hello ;


    You must use an event listener to copy your own templates when the afterBuild event is triggered by the i-MSCP installer.


    Here, your mistake is to copy your own templates once the update is done. This is done too late because the zone files were already regenerated. Also, the files shouldn't be copied into /etc/imscp/bind/parts directly but in $main::{'INST_PREF'}/etc/imscp/bind/parts that is the build directory used by the i-MSCP installer.


    To resume, you could

    • Create a directory on your system for storing your own templates such as /root/imscp/custom/templates/bind/parts
    • Create a file 10_named_custom_templates.pl into the /etc/imscp/listeners.d directory, with the following content: http://pastebin.com/3Q8eZXxW
    • Adjust both the source and target directory paths if needed (see the configuration variable in the provided listener example)

    That's all. Now, when you'll run the i-MSCP installer the files/directories from the source directory will be automatically copied recursively into the target directory.



    BTW: Coding that listener took me ~ 1 minute. I've not tested it but it should works.

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206