Missing wiki - need hook that regenerates config files from template files

  • Hey there,
    I want to create a new plugin (DefaultServerPage). For that I need a hook, that regenerates the template files (apache for example) after I activate the plugin.


    Attached my current version of the plugin.


    Thanks!

  • Hello ;


    What template you want regenerate exactly? I bet 00_master.conf... Anyway, those templates (panel vhost templates are builded while install/update process only). You can of course trigger the installer manually through the plugin but it's more hard.



    BTW: in the backend part, you cannot use relative path such as ../templates/apache/00_master.conf" because the backend is not executed from the Gui plugin directory. Backend part is copied into /var/www/engine/Plugins


    Edit: i'll show you how to process but before, I ask you to push this work on github and give me an access to your branch. Thanks

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

  • Hmm ok thank you. So the absolute path must be hardcoded?

  • Re;


    No, you must use the i-MSCP APi to get GUI base root plugin directory followed by PluginName/templates/apache/00_master.conf


    Also, for opening files and so on, please, use the i-MSCP library instead of reinventing the wheel ;)


    See the parameters defined in the imscp.conf file ;)


    Again, I can help you if you push this works on github.

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

  • Thanks! You are now collaborator of the repo. I will commit in the next hour the pathfix :)

  • Thx. Send me the link to your repo (via PM)

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

  • @Nuxwin I have relaunched the plugin and now it should work like a charm. You can have a look on it. If all is ok I will write a docu and upload it to the plugin store :-)

  • I'll check it and upload it. The code seem ok now. Only a restricted list of i-MSCP team members is allowed to upload new plugin (using same user).


    BTW: In my opinion, someone helped you or your are learning really fast... :P

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

  • Haha I'm a dev, so coding shouldn't be a problem for me. Today I coded the first time in perl, so at first it was a little bit hard to understand the language and imscp-api (also because of the missing documentations :D). But the code of the imscp-project and other plugins helped me out :D -> your code helped me! :saint:


    PS: Is there a function to copy an folder? I just found the copyFile()-function...
    EDIT: found the rcopy function in the iMSCP::Dir Class... :)