The basics for doing plugins

Discussion in 'Developers' Forum' started by spr, Sep 18, 2009.

  1. spr

    spr New Member

    Hi

    I've decided to write a Plugin for lighttpd.
    For that I've looked deep into the Code...
    Am I right that Apache2 and other "Webserver-Plugins" will rival due installation?
    For me this seems because of all the Plugins are hardcoded in the install.php !?

    May be I'm wrong, but for my opinion the installation should only know the Mods and in my "Installation Profile" I've to definde which Plugin is used for each Module...

    Please advice.

    regards

    spr
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Hi,

    the plugins are not hardcoded in install.php. Every plugin has a function called onInstall() which is called during installation. There you can add code to detect if the the requirements are fullfilled or not e.g. if lighttpd is installed. If this function returns true, the plugin gets enabled, otherwise the plugin is disabled. Not all plugins implement this yet as there are no rival plugins, but the mechanism is implemented already.

    The thing that is hardcoded at the moment in install.php are the function calls for the configuration routines of services, which are independant from the plugins. Thats the case as there are no rivaling plugins yet. But there is already a mechanism implemented that checks which software is installed (see installer_base.lib.php -> find_installed_apps() ). So you we just have to change the line(s) in install.php as soon as we have more then one configuration routine for a service:

    $inst->configure_apache();

    to:

    if($conf['apache']['installed']) {
    $inst->configure_apache();
    }

    or in case we add lighttpd:

    if($conf['apache']['installed']) {
    $inst->configure_apache();
    } elseif($conf['lighttpd']['installed']) {
    $inst->configure_lighttpd();
    } else {
    swriteln('No webserver found');
    }
     
  3. spr

    spr New Member

    Hi

    Ok I haven't recognized that there're no concurrent yet.
    For my opinion it could make sense to have Install-Profiles which could be hardcoded or done over the Adminpanel !?
    Of course there's no need for, but I think it's interessting.
    E.g. for checking if the Server still fits the Profile...

    regards

    spr
     
  4. spr

    spr New Member

    Hi till,

    I've burried my head deep into the code for 2 nights :D
    For me it seems definitly that doing a lighty Plugin is much more than writing a plugin!
    The Apache part is hardcoded in the Install-Libs and other parts.

    However, ISPConfig is great because it fits most of my dependencies ;)
    So please let me know your mentions about a lighty plugin, if any...

    Btw. my No.1 priority is making ISPConfig more powerful by building in lighty.
    But I don't want to reach that at any price! Contribution and woking in harmony is my maxim :cool:
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    See my comments above about that: its changed in 5 minutes as you have to edit just one file and add just one if statement as all the code to detect the services is already present.

    Of course you will have to write configuration routies, but that the case for any service you want to add. The code for the apache part has not to be modified.
     

Share This Page