摘要:参考网址创建应用创建应用目录创建菜单节点设置菜单节点图标内创建对应内的张图片创建设置面板刷新缓存创建脚本生成配置信息的脚本命令执行添加默认配置以下条命令用于安装包安装直接执行可注释掉创建删除配置信息的脚本执行命令
参考网址:https://forum.openmediavault....
创建应用GUI
创建应用目录:/var/www/openmediavault/js/omv/module/admin/service/example
创建菜单节点: Node.js
// require("js/omv/WorkspaceManager.js") OMV.WorkspaceManager.registerNode({ id: "example", path: "/service", text: _("Example"), icon16: "images/example.png", iconSvg: "images/example.svg" });
设置菜单节点图标
var/www/openmediavault/images 内创建对应Node.js内的2张图片
创建设置面板: Settings.js
// require("js/omv/WorkspaceManager.js") // require("js/omv/workspace/form/Panel.js") Ext.define("OMV.module.admin.service.example.Settings", { extend: "OMV.workspace.form.Panel", rpcService: "Example", rpcGetMethod: "getSettings", rpcSetMethod: "setSettings", getFormItems: function() { return [{ xtype: "fieldset", title: _("General"), fieldDefaults: { labelSeparator: "" }, items: [{ xtype: "checkbox", name: "enable", fieldLabel: _("Enable"), checked: false }, { xtype: "numberfield", name: "max_value", fieldLabel: _("Max value"), minValue: 0, maxValue: 100, allowDecimals: false, allowBlank: true }] }]; } }); OMV.WorkspaceManager.registerPanel({ id: "settings", path: "/service/example", text: _("Settings"), position: 10, className: "OMV.module.admin.service.example.Settings" });
刷新js缓存:
source /usr/share/openmediavault/scripts/helper-functions && omv_purge_internal_cache
创建shell脚本
生成配置信息的脚本postinst 命令执行:/bin/sh postinst configure
#!/bin/sh set -e . /etc/default/openmediavault . /usr/share/openmediavault/scripts/helper-functions case "$1" in configure) SERVICE_XPATH_NAME="example" SERVICE_XPATH="/config/services/${SERVICE_XPATH_NAME}" # 添加默认配置 if ! omv_config_exists "${SERVICE_XPATH}"; then omv_config_add_element "/config/services" "${SERVICE_XPATH_NAME}" omv_config_add_element "${SERVICE_XPATH}" "enable" "0" omv_config_add_element "${SERVICE_XPATH}" "max_value" "0" fi # 以下2条命令用于安装包安装 直接执行可注释掉 dpkg-trigger update-fixperms dpkg-trigger update-locale ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument" >&2 exit 1 ;; esac #DEBHELPER# exit 0
创建删除配置信息的shell脚本 postrm 执行命令:/bin/sh postrm purge
#!/bin/sh set -e . /etc/default/openmediavault . /usr/share/openmediavault/scripts/helper-functions SERVICE_XPATH_NAME="example" SERVICE_XPATH="/config/services/${SERVICE_XPATH_NAME}" case "$1" in purge) if omv_config_exists ${SERVICE_XPATH}; then omv_config_delete ${SERVICE_XPATH} fi ;; remove) ;; upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) ;; *) echo "postrm called with unknown argument `$1"" >&2 exit 1 ;; esac #DEBHELPER# exit 0
创建rpc
在目录/usr/share/openmediavault/engined/rpc创建example.inc
registerMethod("getSettings"); $this->registerMethod("setSettings"); } public function getSettings($params, $context) { // Validate the RPC caller context. $this->validateMethodContext($context, [ "role" => OMV_ROLE_ADMINISTRATOR ]); // Get the configuration object. $db = OMVConfigDatabase::getInstance(); $object = $db->get("conf.service.example"); // Remove useless properties from the object. return $object->getAssoc(); } public function setSettings($params, $context) { // Validate the RPC caller context. $this->validateMethodContext($context, [ "role" => OMV_ROLE_ADMINISTRATOR ]); // Validate the parameters of the RPC service method. $this->validateMethodParams($params, "rpc.example.setsettings"); // Get the existing configuration object. $db = OMVConfigDatabase::getInstance(); $object = $db->get("conf.service.example"); $object->setAssoc($params); $db->set($object); // Return the configuration object. return $object->getAssoc(); } }
创建对应的配置文件
在usrshareopenmediavaultdatamodels创建conf.service.example.json
{ "type": "config", "id": "conf.service.example", "title": "EXAMPLE", "queryinfo": { "xpath": "//services/example", "iterable": false }, "properties": { "enable": { "type": "boolean", "default": false }, "max_value": { "type": "integer", "minimum": 1, "maximum": 100, "default": 0 } } }
在usrshareopenmediavaultdatamodels创建rpc.example.json
[{ "type": "rpc", "id": "rpc.example.setsettings", "params": { "type": "object", "properties": { "enable": { "type": "boolean", "required": true }, "max_value": { "type": "integer", "minimum": 1, "maximum": 100, "required": true } } } }]
运行命令重启omv服务:service openmediavault-engined restart
创建shell脚本获取配置信息
创建执行脚本 example 执行命令:omv-mkconf example
#!/bin/sh set -e . /etc/default/openmediavault . /usr/share/openmediavault/scripts/helper-functions OMV_EXAMPLE_XPATH="/config/services/example" OMV_EXAMPLE_CONF="/tmp/example.conf" cat <${OMV_EXAMPLE_CONF} enable = $(omv_config_get "${OMV_EXAMPLE_XPATH}/enable") max_value = $(omv_config_get "${OMV_EXAMPLE_XPATH}/max_value") EOF exit 0
为了监听触发执行脚本,将脚本放在/usr/share/openmediavault/mkconf目录下
脚本权限改为 chmod 755 example
配置保存事件监听
/usr/share/openmediavault/engined/module创建监听的example.inc
setRedirect2to1(); $cmd->execute(); } function bindListeners(OMVEngineNotifyDispatcher $dispatcher) { $dispatcher->addListener(OMV_NOTIFY_MODIFY, "org.openmediavault.conf.service.example", // 和rpc内的配置文件一致conf.service.example [ $this, "setDirty" ]); } }
运行命令重启omv服务:service openmediavault-engined restart
创建deb包 https://blog.csdn.net/gatieme...
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/29536.html
摘要:参考网址创建应用创建应用目录创建菜单节点设置菜单节点图标内创建对应内的张图片创建设置面板刷新缓存创建脚本生成配置信息的脚本命令执行添加默认配置以下条命令用于安装包安装直接执行可注释掉创建删除配置信息的脚本执行命令 参考网址:https://forum.openmediavault.... 创建应用GUI 创建应用目录:/var/www/openmediavault/js/om...
摘要:这里使用的是数据库启动类上加上注解在启动类中添加对包扫描扫描多个包下的可以有以下几种方法扫描会自动加载相关配置,数据源就会自动注入到中,会自动注入到中,可以直接使用。有配置文件下的使用扫描多个包下的可以有以下几种方法扫描 Spring-Boot 学习笔记 1 Spring-Boot 介绍 1.1 什么是Spring-Boot Spring-Boot是由Pivotal团队提供的全新框架...
摘要:目前网上关于插件开发的文章少得可怜,下面分享最近的经历,如何快速上手开发一个插件。第六步调试插件在打开的网页中可以看到工具栏中实现了插件。 TinyMCE是一个非常优秀的轻量级的所见即所得HTML编辑器,历史悠久,开源,在github的start也非常高的,且长期保持更新。TinyMCE的官方插件不少,基本能满足日常需求,但是有时候我们还需要一些结合业务的功能。这时官方插件无法满足,就...
摘要:提示插件可以重写默认的比如打开新时。这是在插件中定义的,因此不能后面做更改。把你的插件提交到的子版块中。从图中蓝色点开始到后面的两天曲线变化。曲线中间的那个小凸起,是二月份在发布的时候产生的。关于在插件中如何使用的教程在这里。 showImg(https://segmentfault.com/img/remote/1460000008971998?w=1920&h=1080); 本文...
阅读 3177·2021-11-17 09:33
阅读 3273·2021-11-15 11:37
阅读 2934·2021-10-19 11:47
阅读 3178·2019-08-29 15:32
阅读 978·2019-08-29 15:27
阅读 1509·2019-08-29 13:15
阅读 900·2019-08-29 12:47
阅读 1996·2019-08-29 11:30