Type Files:
├── DEBIAN
│ ├── changelog
│ ├── compat
│ ├── control
│ ├── copyright
│ ├── install
│ ├── postinst
│ ├── postrm
│ ├── rules
│ └── triggers
└── usr
├── sbin
│ └── plugin-file-name
└── share
└── openmediavault
├── confdb
│ └── create.d
│ └── conf.system.network.PLUGINNAME.sh
├── datamodels
│ └── conf.system.network.PLUGINNAME.json
├── engined
│ ├── inc
│ │ └── PLUGINNAME.inc # LogFileSpec
│ ├── module
│ │ └── PLUGINNAME.inc
│ └── rpc
│ └── PLUGINNAME.inc
├── locale
│ ├── openmediavault-PLUGINNAME.pot
│ ├── pl
│ │ └── openmediavault-PLUGINNAME.po
│ └── pl_PL
│ └── openmediavault-PLUGINNAME.po
└── workbench
├── component.d
│ ├── omv-network-PLUGINNAME-form-page.yaml
│ ├── omv-network-PLUGINNAME-navigation-page.yaml
│ └── omv-network-PLUGINNAME-noip-form-page.yaml
├── log.d
│ └── PLUGINNAME.yaml
├── navigation.d
│ └── network.PLUGINNAME.yaml
└── route.d
└── network.PLUGINNAME.yaml
#!/bin/sh
set -e
. /usr/share/openmediavault/scripts/helper-functions
SERVICE_XPATH_NAME="PLUGINNAME"
SERVICE_XPATH="/config/services/${SERVICE_XPATH_NAME}"
if ! omv_config_exists "${SERVICE_XPATH}"; then
omv_config_add_node "/config/services" "${SERVICE_XPATH_NAME}"
omv_config_add_key "${SERVICE_XPATH}" "enable" "0"
omv_config_add_key "${SERVICE_XPATH}" "ADD_NEXT_KEY" "true" # Option true,false or everyone else
fi
exit 0
Notes:
{
"type": "config",
"id": "conf.service.PLUGINNAME",
"title": "PLUGINNAME",
"queryinfo": {
"xpath": "//services/PLUGINNAME",
"iterable": false
},
"properties": {
"enable": {
"type": "boolean",
"default": false
},
"ADD_NEXT_KEY": {
"type": "boolean",
"default": true
}
}
}
Notes:
// Is service enabled?
$db = \OMV\Config\Database::getInstance();
$object = $db->get("conf.service.PLUGINNAME");
if (FALSE === $object->get("enable")) {
$result = gettext("Service disabled");
} else {
$result = gettext("Service enabled");
}
function getSettings($params, $context) {
$this->validateMethodContext($context, [ 'role' => OMV_ROLE_ADMINISTRATOR ]);
$db = \OMV\Config\Database::getInstance();
$object = $db->get('conf.system.FILETYPE.PLUGINNAME');
return $object->getAssoc();
}
function setSettings($params, $context) {
$this->validateMethodContext($context, ['role' => OMV_ROLE_ADMINISTRATOR]);
$db = \OMV\Config\Database::getInstance();
$object = $db->get('conf.system.FILETYPE.PLUGINNAME');
$object->setAssoc($params);
$db->set($object);
return $object->getAssoc();
}
PLUGINNAME.inc
<?php
#SET NAME filetypePluginame example - ServicesExample
class ServicesExample extends \OMV\Rpc\ServiceAbstract {
#SET NAME filetypePluginame example - ServicesExample
public function getName() {
return "NAME";
}
#Register Method to use function
public function initialize() {
$this->registerMethod('getSettings');
$this->registerMethod('setSettings');
}
}
?>
changelog
control
- Set name and author plugin
postinst
- Creating a database, directories, and installing the necessary libraries you need
postrm
- Code used when uninstalling a plugin
version: "1.0"
type: component
data:
name: omv-services-FILETYPE-FILENAME-form-page
type: datatablePage
config:
autoReload: false
hasSearchField: true
rowId: name
sorters:
- dir: asc
prop: name
store:
proxy:
service: Example
get:
method: getExampleList //GET ROWS FROM rpc
columns:
- name: " "
prop: image
flexGrow: 0.15
cellTemplateName: image
cellTemplateConfig:
class: "mat-icon notranslate mat-icon-no-color"
alt: " "
src: "{{ image }}"
- name: _("Name")
prop: name
flexGrow: 1
sortable: true
actions:
- type: iconButton
icon: mdi:plus-box
tooltip: _("Add example file")
enabledConstraints:
minSelected: 1
maxSelected: 1
execute:
type: formDialog
formDialog:
title: _("Add...")
fields:
- type: textInput
name: name
label: _("Name")
value: "{{ _selected[0].name }}"
- type: textInput
name: description
label: _("Description")
value: ""
buttons:
submit:
text: _("Add")
execute:
type: request
request:
service: Example
method: setExample
progressMessage: _("Adding an example ...")
successNotification: _("Example has been added.")
successUrl: /services/FILETYPE/PLUGINNAME
version: "1.0"
type: component
data:
name: omv-FILETYPE-PLUGINNAME-form-page
type: formPage
config:
request:
service: NetworkDnshost #FILETYPE PLUGINNAME
get:
method: getSettings # From RPC file
post:
method: setSettings # From RPC file
fields:
- type: checkbox
name: option1_fromDB
label: _("NAME OPTION1")
value: false
- type: textInput
name: option2_fromDB
label: _("Option Name2")
value: "username"
buttons:
- template: submit
- template: cancel
execute:
type: url
url: "/FILETYPE/PLUGINNAME"
In RPC file command example
function Example($params) {
return $this->execBgProc(function($bgStatusFilename, $bgOutputFilename)
use ($object, $params) {
$db = \OMV\Config\Database::getInstance();
$provider = $params['provider'];
$object = $db->get('conf.system.FILETYPE.PLUGINNAME');
if (FALSE === $object->get("".$provider."") ) {
throw new \OMV\Exception(
"Failed to run scheduled job because the service is disabled.");
} else {
$cmdArgs = [];
$cmdArgs[] = "--shell";
$cmdArgs[] = "--non-interactive";
$cmdArgs[] = "--";
$cmdArgs[] = build_path(DIRECTORY_SEPARATOR, \OMV\Environment::get("OMV_CRONSCRIPTS_DIR"), sprintf("$provider-%s", 100));
$cmd = new \OMV\System\Process("python3 /usr/sbin/EXAMPLE.py", "-d $provider");
$cmd->setRedirect2to1();
$cmd->execute($output);
$cmdLine = $cmd->getCommandLine();
$stats = implode("\n", $output);
$exitStatus = $this->exec($cmdLine, $output, $bgOutputFilename);
if (0 !== $exitStatus)
throw new \OMV\ExecException($cmdLine, $output, $exitStatus);
return $output;
}
});
}
cd openmediavault-pluginame
dpkg-buildpackage -us -uc
Install
dpkg -i openmediavault-pluginname_VERSION_all.deb