Plug-in example: How to change a domain directory

Plug-in example: How to change a domain directory

This article describes how to add a check box into a web-domain edit form. Selecting this check box will automatically change the domain's home directory.

XML description

# cat /usr/local/mgr5/etc/xml/ispmgr_mod_example.xml 
<?xml version="1.0" encoding="UTF-8"?>
   <handler name="*dir*" type="*xml*"> // dir — name of the handler to be called. Specify _xml_
         <event name="*webdomain.edit*" *after="yes"* /> 
// if you want a plug-in to edit web-domain, specify the _webdomain.edit function_ as _event name_ 
// select  _after_ if you want to apply the plug-in after changing the form 
<metadata name="webdomain.edit" type="form">
      <page name="features">
        <field name="cms" experience="expert">
           <input type="checkbox" name="cms" *setvalues="yes"*> // set setvalues="yes" for check boxб so that the plug-in will be activated after selecting check box 
<lang name="en">
   <messages name="webdomain.edit">
      <msg name="cms">Example</msg> //  the name of the check box
      <msg name="hint_cms">This is an example</msg> // Hint

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

Note. If you are using ISPmanager Business, the name of the xml file should be ispmgrnode_mod_example.xml, and plug-in's files should locate on all nodes.


# cat /usr/local/mgr5/addon/dir 
   if [ "$PARAM_cms" = "on" ] 
               cat |xmlstarlet ed -i "/doc/cancreatebox" -t elem -n "home" -v "www/pub"

To change the value of the "Root directory" field while editing the form, edit the xml this form is based on. Add the element into xml to change the "Root directory" field. I use the xmlstarlet utility.

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>

Once the xml file with plug-in description is created, and the handler file is added,restart the panel:

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

If you are using ISPmanager Business, execute

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


The WWW-domain edit form contains an additional check box



When selecting or clearing the check box, domain's home directory will change into www/pub



P. S. Tested on ISPmanager Lite 5.23

In this article