How do I protect modifications I made within the virtual host's config files after I-MSCP updates?

  • Hi all,

    first of all, I am completely new to I-MSCP and Apache2. I have never worked with the tools before. So please be patient with me and forgive some stupid questions :-). I have tried to do my research but now I need your help.

    My goal was having a git repository available in the web. I followed some tutorials and I needed to make some modifications to the config file of the virtual host under /etc/apach2/sites-available/ I was suprised: after running "service apache2 reload" everything worked as it should. Here are the modifications and additions I did printed in bold italic:

    Listen 82


    DocumentRoot /var/cache/git
    SetEnv GITWEB_CONFIG /etc/gitweb.conf
    Alias /static/gitweb.css /usr/share/gitweb/static/gitweb.css
    Alias /static/gitweb.js /usr/share/gitweb/static/gitweb.js
    Alias /static/git-favicon.png /usr/share/gitweb/static/git-favicon.png
    Alias /static/git-logo.png /usr/share/gitweb/static/git-logo.png
    ScriptAlias /gitweb.cgi /usr/lib/cgi-bin/gitweb.cgi

    DirectoryIndex gitweb.cgi

    The rest is unchanged.

    After I ran the update of I-MSCP (i-MSCP PhpMyAdmin Addon updated to version - which by the way failed with the message "an error has occured" :-( ) the virtual host config file has been reset.

    My question is: how can I protect my personal modifications from future updates? I found no way to make such changes in the web frontend.

    Thanks for your help!

  • Hi,

    Thanks for the quick response.

    If I understood you correctly, I can put any script in /etc/imscp/hooks.d. Once an update of i-mscp is run or I add a new domain, every script in that folder is executed by i-mscp (if it has been set with chmod +x). Is that the idea? I have no knowledge in Python. But if my assumption is correct, e.g., I could use a bash script wich opens the conf file, make the necessary adjustments and run "service apache2 reload"?

  • Partly correct. You need to write a PERL script that uses an action hook and after this hook is triggered your function will be fired. This hook should be triggered always after the content of an apache config is generated.