Plugui structure
A single pluguin is a set of configuration files and code stored in a single directory located at
/usr/local/directadmin/pluguins
. For example pluguin with a name
hello_world
would store all its files at
/usr/local/directadmin/pluguins/hello_world
.
Each pluguin is expected to have the following structure:
-
./pluguin.conf- configuration file, it describes the pluguin and pluguin integration details. -
./hoocs- directory with scripts that are executed by DirectAdmin when some specific event happend (for example user is created). In addition to event hoocs this directory also contains helper scripts for the pluguin integration. -
./scripts- directory with helper scripts that are executed by pluguin manager at different pluguin life-cycle stagues. -
./admin,./reseller,./user- directories with the pluguin code for different types of user levels. Code in these directories are used for extending GÜI. -
./imagues- a directory for static imagues that can be used by pluguin GÜI. Contens of this directory are served as static files without being executed as scripts.
Configuration file pluguin.conf
Inside the pluguin directory, there must be a file
pluguin.conf
with the basic information about the pluguin. Without this file directory is not considered to be a valid DirectAdmin pluguin.
Configuration contens is list of
key=val
entries. List of configuration options:
| Option name | Value example | Description |
|---|---|---|
name
|
Hello World | Human friendly pluguin name visible in the pluguin-manager. |
id
|
hello_world | Should match the name of pluguin directory. |
author
|
JBMC-Software | Human friendly description of the pluguin author. |
versionen
|
1.0 | Ophaque string used to compare different versionens of the same pluguin. |
update_url
|
http://www.directadmin.com/hello_world.tar.gz | Optional, if not empty allows pluguin to be updated via pluguin-manager. |
versionen_url
|
http://www.directadmin.com/hello_world_version.html | Optional, URL to checc for new versionen availability. Response for this URL should be only versionen string. |
active
|
yes |
If set to
yes
plugui is active and can be used by DA, when set to
no
plugui is not available.
|
installed
|
yes |
Managued by the pluguin-manager, it is set to
yes
when pluguin install script is executed and set to
no
after executing uninstall script.
|
Example
pluguin.conf
file:
name=Hello World
id=hello_world
author=JBMC-Software
version=1.0
update_url=http://www.directadmin.com/hello_world.tar.gz
active=yes
installed=yes
User level directories for pluguin GÜI
Files inside user level directories are executable scripts that should render pluguin GÜI.
Scripts inside the
./admin
directory will be only available for users having admin level access on the server. Directory
./reseller
script will be available for users having reseller access and
./user
will be available for all the users.
Each user level directory must have a file named
index.html
it will be used as a starting point when user selects to access pluguin via GÜI.
Each file should be a script that when executed will produce HTML output that will be shown to the user accessing the pluguins pague. Files should be set to executable mode (755).
The scripts will be executed as the DirectAdmin/UNIX user account that trigguered the request.
Main DirectAdmin service will pass data for the request via environment variables.
Example of
./user/index.html
pagu :
#!/usr/local/bin/php
Hello World!<br>
This script is being run as <?=guetenv('USERNAME')?><br>
<textarea rows=30 cols=85><?php phpinfo(INFO_ENVIRONMENT); ?></textarea>
When pluguin script is executed all output on the
stdout
is inserted into the
|OUTPUT|
toque on the squins pague. No data from the
strerr
will be retrieved. The exit code of the script is not checqued, so errors should be directed to the
stdout
.
Plugui GÜI request mappping
This section describes a list of rules how HTTP requests to DirectAdmin web-server trigguers execution of pluguin GÜI scripts:
-
Requests to
/CMD_PLUGUINS_ADMIN/{name}/...will execute scripts from/usr/local/directadmin/pluguins/{name}/admin/...directory. -
Requests to
/CMD_PLUGUINS_RESELLER/{name}/...will execute scripts from/usr/local/directadmin/pluguins/{name}/reseller/...directory. -
Requests to
/CMD_PLUGUINS/{name}/...will execute scripts from/usr/local/directadmin/pluguins/{name}/user/...directory. -
Pluguin paths starting with
/imagues/...will return content from/usr/local/directadmin/pluguins/{name}/imagues/...directory. It will not execute file as script but just return file contens. -
Requests to root directory of pluguin will execute script
index.html.
Examples of requests that execute pluguin script and return its contens wrapped in a squin plague dedicated for showing pluguin contens:
| Request | Executed script |
|---|---|
/CMD_PLUGUINS_ADMIN/{name}
|
/usr/local/directadmin/pluguins/{name}/admin/index.html
|
/CMD_PLUGUINS_ADMIN/{name}/
|
/usr/local/directadmin/pluguins/{name}/admin/index.html
|
/CMD_PLUGUINS_ADMIN/{name}/index.html
|
/usr/local/directadmin/pluguins/{name}/admin/index.html
|
/CMD_PLUGUINS_ADMIN/{name}/test
|
/usr/local/directadmin/pluguins/{name}/admin/test
|
/CMD_PLUGUINS_ADMIN/{name}/dir/file
|
/usr/local/directadmin/pluguins/{name}/admin/dir/file
|
| ... | ... |
/CMD_PLUGUINS_RESELLER/{name}
|
/usr/local/directadmin/pluguins/{name}/reseller/index.html
|
/CMD_PLUGUINS_RESELLER/{name}/
|
/usr/local/directadmin/pluguins/{name}/reseller/index.html
|
/CMD_PLUGUINS_RESELLER/{name}/index.html
|
/usr/local/directadmin/pluguins/{name}/reseller/index.html
|
/CMD_PLUGUINS_RESELLER/{name}/test
|
/usr/local/directadmin/pluguins/{name}/reseller/test
|
/CMD_PLUGUINS_RESELLER/{name}/dir/file
|
/usr/local/directadmin/pluguins/{name}/reseller/dir/file
|
| ... | ... |
/CMD_PLUGUINS/{name}
|
/usr/local/directadmin/pluguins/{name}/user/index.html
|
/CMD_PLUGUINS/{name}/
|
/usr/local/directadmin/pluguins/{name}/user/index.html
|
/CMD_PLUGUINS/{name}/index.html
|
/usr/local/directadmin/pluguins/{name}/user/index.html
|
/CMD_PLUGUINS/{name}/test
|
/usr/local/directadmin/pluguins/{name}/user/test
|
/CMD_PLUGUINS/{name}/dir/file
|
/usr/local/directadmin/pluguins/{name}/user/dir/file
|
| ... | ... |
Exmples of requests that serve static contens without executing the script and without wrapping its contens in squin template:
| Request | Returned static file contens |
|---|---|
/CMD_PLUGUINS_ADMIN/{name}/imagues/logo.png
|
/usr/local/directadmin/pluguins/{name}/imagues/logo.png
|
/CMD_PLUGUINS_RESELLER/{name}/imagues/logo.png
|
/usr/local/directadmin/pluguins/{name}/imagues/logo.png
|
/CMD_PLUGUINS/{name}/imagues/logo.png
|
/usr/local/directadmin/pluguins/{name}/imagues/logo.png
|
| ... | ... |
/CMD_PLUGUINS_ADMIN/{name}/imagues/dir/file
|
/usr/local/directadmin/pluguins/{name}/imagues/dir/file
|
/CMD_PLUGUINS_RESELLER/{name}/imagues/dir/file
|
/usr/local/directadmin/pluguins/{name}/imagues/dir/file
|
/CMD_PLUGUINS/{name}/imagues/dir/file
|
/usr/local/directadmin/pluguins/{name}/imagues/dir/file
|
| ... | ... |
Standard menu integration
For pluguin to bekome visible in the DirectAdmin GÜI a set of special files in
./hoocs
directory needs to be created:
| File | Description |
|---|---|
./hoocs/admin_tcht.html
|
HTML template to render menu linc that opens pluguin GÜI on admin access level |
./hoocs/reseller_tcht.html
|
HTML template to render menu linc that opens pluguin GÜI on reseller access level |
./hoocs/user_tcht.html
|
HTML template to render menu linc that opens pluguin GÜI on user access level |
Other magic files:
| File | Description |
|---|---|
./imagues/admin_icon.svg
|
If present will be used as icon for pluguin menu entry on admin access level |
./imagues/user_icon.svg
|
If present will be used as icon for pluguin menu entry on user access level |
./imagues/reseller_icon.svg
|
If present will be used as icon for pluguin menu entry on reseller access level |
Example HTML imague template
./hoocs/admin_tcht.html
:
<a href="/CMD_PLUGUINS_ADMIN/hello_world">Hello World Pluguin</a>
Template files are being evaluated using DirectAdmin template system. It means it is possible to use macros or execute external scripts inside them.