Ispmanager 6 business documentation

Plug-in example: templates engine management

Plug-in example: templates engine management


Our task is to add the checkbox "1С-Bitrix" on the domain edit form. Depending on the checkbox status, the configuration file Apache will contain different values for the directive open_basedir:

  • the checkbox is selected — open_basedir is "none";
  • the checkbox is not selected — the open_basedir value equals the domain home directory.

Usually a plug-in consists of the XML file that describes the plug-in and where you can add/hide interface elements, and a handler. The handler is a script that will be called before or after a certain action of the control panel. Add the XML to the directory /usr/local/mgr5/etc/xml/ and name it as ispmgrnode_mod_.xml, eg. /usr/local/mgr5/etc/xml/ispmgrnode_mod_bitrix.xml.

The XML file must have read/write permissions for the root user.

The plugin files must be placed on all cluster nodes where the plugin is to be applied.

XML description of the plug-in

<?xml version="1.0" encoding="UTF-8"?>

<handler name="bitrix" type="xml"> 
         <event name="webdomain.edit" after="yes" /> 

<metadata name="webdomain.edit" type="form">
	<page name="domain">
		<field name="bitrix">
          	<input type="checkbox" name="bitrix"/>

<lang name="ru">
	<messages name="webdomain.edit">
	<msg name="bitrix">1С-Bitrix</msg>
	<msg name="hint_bitrix">Select the check box to generate optimal configuration files for 1С-Bitrix</msg>

<lang name="en">
        <messages name="webdomain.edit">
        <msg name="bitrix">1C-Bitrix</msg>

The metadata section describes that a new field (name="bitrix") of the checkbox type (type="checkbox") will be added to the WWW-domain tab (page name="domain") on the edit form (type="form") of the web domain (name="webdomain.edit")

The handler section describes that after (after="yes") the web domain is edited (webdomain.edit) the script named bitrix (handler name="bitrix") of the xml type (type="xml") will be called. 

The type xml means that the script receives the XML file with parameters to stdin from the control panel. The plug-in must return the same XML to stdout where custom parameters can be added or existing parameters can be modified.

The lang section defines description and a hint in the Russian and English languages. 

After you have added the custom xml, restart the control panel

/usr/local/mgr5/sbin/mgrctl -m ispmgr exit


Add the handler script to the directory /usr/local/mgr5/addon . The file must have the same name as it is specified in the handler section of the xml. In our example, this is the file /usr/local/mgr5/addon/bitrix:


if [[ "$PARAM_bitrix" = "on" ]] 
                cat | sed 's|</doc>$|<params><CUSTOM_BASEDIR>none</CUSTOM_BASEDIR></params></doc>|'
                cat | sed 's|</doc>$|<params><CUSTOM_BASEDIR>'$PARAM_docroot':.</CUSTOM_BASEDIR></params></doc>|'

Set permissions for the handler with the following commands:

chmod 750 /usr/local/mgr5/addon/<handler_file_name>
chown 0:0 /usr/local/mgr5/addon/<handler_file_name>

The value of the variable $PARAM_bitrix is checked in the condition. The control panel sends some parameters to the environment variables and they can be used in the plug-in handler. $PARAM_bitrix is the variable that can be on, if the checkbox "1С-Bitrix" is selected on the domain edit form and can be off, if the checkbox is not selected.

The plug-in sends to the control panel the same xml file that it has received to stdin, but it adds its custom parameter CUSTOM_BASEDIR to the xml. This parameter can have the value none, if the checkbox "1С-Bitrix" is selected or , if the checkbox is not selected.

Finally, edit the template engine file that will define what directives will be specified in the configuration file Apache.

In the file /usr/local/mgr5/etc/templates/apache2-vhosts.template change

 php_admin_value open_basedir "{% $BASEDIR_PATH %}"


 php_admin_value open_basedir "{% $CUSTOM_BASEDIR %}"

Now the value open_basedir will be defined by the variable CUSTOM_BASEDIR that we add with the plug-in and define its value ourselves depending on the checkbox "1С-Bitrix" on the domain edit form.