Plug-in example: how to add a menu module
This article walks you through the steps you need to perform to add a custom module into the interface module.
Interface description
To add a new menu item, create an XML file:
#cat /usr/local/mgr5/etc/xml/ispmgr_mod_menu.xml
<?xml version="1.0" encoding="UTF-8"?>
<mgrdata>
<mainmenu level="admin+">
<node name="account">
<node name="myfunc" />
</node>
</mainmenu>
<handler name="myaddon" type="xml">
<func name="myfunc" />
</handler>
<lang name="ru">
<messages name="desktop">
<msg name="menu_myfunc">Test</msg>
</messages>
</lang>
</mgrdata>
Be sure to specify the path /usr/local/mgr5/etc/xml/ and name ispmgr_mod_
The XML file must have read/write permissions for the root user.
As we can see in the file, in the mainmenu section we specify the level where this module will be available. In our example — admin+ — super admin level.
Adding a custom function
Create an add-on to add the myfunc function:
<handler name="myaddon" type="xml">
<func name="myfunc" />
</handler>
Locate the add-on in the /usr/local/mgr5/addon/ directory
# cat /usr/local/mgr5/addon/myaddon
#!/bin/bash
cat /tmp/tmp
Clicking the Test section (this name was specified in the lang section) will call myaddon to send the XML with required data to the panel stdin.
In our example the function returns the following data:
# cat /tmp/tmp
<?xml version="1.0" encoding="UTF-8"?>
<doc lang="ru" func="webdomain" binary="/ispmgr" host="[http://10.10.10.10:1500|http://10.10.10.10:1500] " features="6b49a92f5cc5153c76b78446d0d74eb40" notify="4" favorite="no" theme="/manimg/orion/" css="main.css" logo="logo-ispmgr.png" logolink="" favicon="favicon-ispmgr.ico" localdir="default/">
<metadata name="myfunc" type="list" key="name" mgr="ispmgr">
<toolbar view="buttontext">
<toolgrp name="new">
<toolbtn name="new" func="webdomain.edit" type="new" img="t-new" sprite="yes"/>
<toolbtn name="delete" func="webdomain.delete" type="group" img="t-delete" sprite="yes"/>
</toolgrp>
</toolbar>
<coldata>
<col type="data" name="name" sort="alpha" convert="punycode" sorted="-1"/>
<col type="data" name="value" sort="alpha" level="reseller+"/>
</coldata>
</metadata>
<messages name="myfunc" checked="6b49a92f5cc5153c76b78446d0d74eb4">
<msg name="title">Test</msg>
<msg name="hint_name"> Name </msg>
<msg name="hint_value">Value </msg>
<msg name="short_new" added="common">Add</msg>
<msg name="short_delete" added="common">Delete</msg>
<msg name="hint_delete" added="common">Delete</msg>
<msg name="hint_new" added="common">Add</msg>
<msg name="name" added="common">Name</msg>
<msg name="value" added="common">Value</msg>
<msg name="hint_export">Save in CSV</msg>
<msg name="hint_selectall">Select all list elements</msg>
<msg name="hint_reloadlist">Update data</msg>
<msg name="hint_print">Print version</msg>
<msg name="hint_autoupdate_stop">Disable auto-update for current list</msg>
<msg name="hint_takefavorite">Add to Favorites</msg>
<msg name="hint_takeunfavorite">Delete from Favorites</msg>
<msg name="msg_tsetting">Table settings</msg>
</messages>
<tparams>
<out>devel</out>
<func>myfunc</func>
</tparams>
<p_sort>name</p_sort>
<p_order>desc</p_order>
<page>test.ru — domain.mary</page>
<elem>
<name>One</name>
<value>Hello</value>
</elem>
<elem>
<name>Two</name>
<value>World!</value>
</elem>
<p_num>1</p_num>
<p_elems>6</p_elems>
</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>
Restart the panel killall core to apply the changes.