Plug-in example: how to change a domain directory

This article describes how to add a checkbox into a web-domain edit form. Selecting this checkbox 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

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 <home> element into xml to change the “Root directory” field. I use the xmlstarlet utility.

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 checkbox

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