From d2f4256f152457318462f2cf27ca9df37add1c2a Mon Sep 17 00:00:00 2001 From: Nicholas Smith Date: Sat, 30 Oct 2021 11:57:54 +1000 Subject: luci-app-openwisp: inital checkin Signed-off-by: Nicholas Smith - Commit heading rewritten Signed-off-by: Florian Eckert --- applications/luci-app-openwisp/Makefile | 15 ++ .../htdocs/luci-static/resources/view/openwisp.js | 101 ++++++++++ .../luci-app-openwisp/po/templates/openwisp.pot | 223 +++++++++++++++++++++ .../usr/share/luci/menu.d/luci-app-openwisp.json | 13 ++ .../usr/share/rpcd/acl.d/luci-app-openwisp.json | 11 + 5 files changed, 363 insertions(+) create mode 100644 applications/luci-app-openwisp/Makefile create mode 100644 applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js create mode 100644 applications/luci-app-openwisp/po/templates/openwisp.pot create mode 100644 applications/luci-app-openwisp/root/usr/share/luci/menu.d/luci-app-openwisp.json create mode 100644 applications/luci-app-openwisp/root/usr/share/rpcd/acl.d/luci-app-openwisp.json diff --git a/applications/luci-app-openwisp/Makefile b/applications/luci-app-openwisp/Makefile new file mode 100644 index 0000000000..03fbd83c11 --- /dev/null +++ b/applications/luci-app-openwisp/Makefile @@ -0,0 +1,15 @@ +# Copyright 2021 Nicholas Smith (nicholas@nbembedded.com) +# This is free software, licensed under the GNU General Public License v2. + +include $(TOPDIR)/rules.mk + +PKG_LICENSE:=GPL-2.0-or-later +PKG_MAINTAINER:=Nicholas Smith + +LUCI_TITLE:=LuCI support for OpenWISP +LUCI_DESCRIPTION:=Allows configuration of OpenWISP agent settings +LUCI_DEPENDS:=+openwisp-config + +include ../../luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js b/applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js new file mode 100644 index 0000000000..23dc162d0a --- /dev/null +++ b/applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js @@ -0,0 +1,101 @@ +'use strict'; +'require view'; +'require form'; +'require tools.widgets as widgets'; + +return view.extend({ + render: function () { + var m, s, o; + + m = new form.Map('openwisp', + _('OpenWISP'), + _("Configure, start and stop the OpenWISP agent on this device. Read more about configuration values: https://github.com/openwisp/openwisp-config")); + + s = m.section(form.NamedSection, 'http', 'controller'); + + s.tab('general', _('General Settings')); + s.tab('advanced', _('Advanced Settings')); + + // General settings + o = s.taboption('general', form.Value, 'uuid', _('UUID'), _('The UUID of this device in the OpenWISP server.')) + o.readonly = true; + + o = s.taboption('general', form.Value, 'key', _('Key'), _('The Key of this device in the OpenWISP server.')) + o.readonly = true; + + o = s.taboption('general', form.ListValue, 'enabled', + _('Enable'), + _("Enable or disable the OpenWISP service.")); + o.value('disabled', _('Disabled')); + o.value('monitoring', _('Enabled')); + + o = s.taboption('general', form.Value, 'url', _('Server URL'), _('The URL to the OpenWISP server. Example: https://openwisp2.mynetwork.com')) + o.placeholder = 'https://openwisp2.mynetwork.com' + + o = s.taboption('general', form.Value, 'shared_secret', _('Shared Secret'), _('The organization shared secret for auto enrollment.')) + o.password = true + + o = s.taboption('general', form.Value, 'interval', _('Update Interval'), 'How often to check in with the OpenWISP server. Expressed in seconds.') + o.placeholder = '120' + o.datatype = 'uinteger'; + + // Advanced settings + o = s.taboption('advanced', form.Flag, 'verify_ssl', _('Verify SSL'), _('Verify the server SSL certificate.')) + o.rmempty = false + + o = s.taboption('advanced', form.Flag, 'consistent_key', _('Consistent Key'), _('When using Automatic registration, this feature allows devices to keep the same configuration even if reset or re-flashed. This feature is enabled by default, but must be enabled also in the controller application in order to work.')) + o.rmempty = false + + o = s.taboption('advanced', widgets.DeviceSelect, 'mac_interface', _('MAC Interface'), _('The interface to use for getting the MAC for this device.')) + o.rmempty = false + + o = s.taboption('advanced', widgets.NetworkSelect, 'management_interface', _('Management Interface'), _('The interface to use for management and control.')) + o.rmempty = false + + o = s.taboption('advanced', form.Flag, 'merge_config', _('Merge Config'), _('If selected, in the event a config item is present in both the remote and local configuration, the remote configuration takes precedence over local configuration.')) + o.rmempty = false + + o = s.taboption('advanced', form.DynamicList, 'tags', _('Tags'), _('Tags applied to this device.')) + + o = s.taboption('advanced', form.Flag, 'test_config', _('Test Config'), _('If the agent is unable to reach the controller after applying the downloaded config it will be reverted.')) + + o = s.taboption('advanced', form.Value, 'test_script', _('Test Script'), 'Path to a custom test script if the default Test Config script does not meet your needs.') + o.depends({ test_config: '1' }) + o.datatype = "file" + + o = s.taboption('advanced', form.Flag, 'hardware_id_key', _('Hardware ID Key'), _('Use a unique hardware ID for device identification, for example a serial number.')) + o.rmempty = false + + o = s.taboption('advanced', form.Value, 'hardware_id_script', _('Hardware ID Script'), 'Path to the script used to return the value of the hardware key.') + o.depends({ hardware_id_key: '1' }) + o.datatype = "file" + + o = s.taboption('advanced', form.Value, 'bootup_delay', _('Boot Delay'), 'Maximum value of the delay after boot before starting OpenWISP service. Expressed in seconds.') + o.placeholder = '0' + o.datatype = 'uinteger'; + + o = s.taboption('advanced', form.Value, 'connect_timeout', _('Connect Timeout'), 'Value passed to curl --connect-timeout argument, defaults to 15. Expressed in seconds.') + o.placeholder = '15' + o.datatype = 'uinteger'; + + o = s.taboption('advanced', form.Value, 'max_time', _('Max Time'), _('Value passed to curl --max-time argument, defaults to 30. Expressed in seconds.')) + o.placeholder = '30' + o.datatype = 'uinteger'; + + o = s.taboption('advanced', form.Value, 'capath', _('CA Path'), _('Use the specified certificate file to verify the peer. The file may contain multiple CA certificates. The certificate(s) must be in PEM format.')) + o.datatype = "file" + + o = s.taboption('advanced', form.Value, 'cacert', _('CA Cert'), _('Use the specified certificate directory to verify the peer. The certificates must be in PEM format, and the directory must have been processed using the c_rehash utility supplied with openssl.')) + o.datatype = "file" + + o = s.taboption('advanced', form.Value, 'pre_reload_hook', _('Pre-reload Hook'), _('Path to pre-reload hook. The hook is not called if the path does not point to an executable script file. This hook is called each time openwisp-config applies a configuration, but before services are reloaded.')) + o.placeholder = '/usr/sbin/my_pre_reload_hook' + o.datatype = "file" + + o = s.taboption('advanced', form.Value, 'post_reload_hook', _('Post-reload Hook'), _('Path to post reload hook script. The hook is not called if the path does not point to an executable script file. This hook is called each time openwisp-config applies a configuration, but after services are reloaded.')) + o.placeholder = '/usr/sbin/my_post_reload_hook' + o.datatype = "file" + + return m.render(); + } +}); diff --git a/applications/luci-app-openwisp/po/templates/openwisp.pot b/applications/luci-app-openwisp/po/templates/openwisp.pot new file mode 100644 index 0000000000..fc72634059 --- /dev/null +++ b/applications/luci-app-openwisp/po/templates/openwisp.pot @@ -0,0 +1,223 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:17 +msgid "Advanced Settings" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:73 +msgid "Bootup Delay" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:88 +msgid "CA Cert" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:85 +msgid "CA Path" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:12 +msgid "" +"Configure, start and stop the OpenWISP agent on this device. Read more about " +"configuration values: https://github.com/openwisp/openwisp-config" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:77 +msgid "Connect Timeout" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:46 +msgid "Consistent Key" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:29 +msgid "Disabled" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:27 +msgid "Enable" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:28 +msgid "Enable or disable the OpenWISP service." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:30 +msgid "Enabled" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:16 +msgid "General Settings" +msgstr "" + +#: applications/luci-app-openwisp/root/usr/share/rpcd/acl.d/luci-app-openwisp.json:3 +msgid "Grant access to luci-app-openwisp" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:66 +msgid "Hardware ID Key" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:69 +msgid "Hardware ID Script" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:55 +msgid "" +"If selected, in the event a config item is present in both the remote and " +"local configuration, the remote configuration takes prescedence over local " +"configuration." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:60 +msgid "" +"If the agent is unable to reach the controller after applying the downloaded " +"config it will be reverted." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:23 +msgid "Key" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:49 +msgid "MAC Interface" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:52 +msgid "Management Interface" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:81 +msgid "Max Time" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:55 +msgid "Merge Config" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:11 +#: applications/luci-app-openwisp/root/usr/share/luci/menu.d/luci-app-openwisp.json:3 +msgid "OpenWISP" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:95 +msgid "" +"Path to post reload hook script. The hook is not called if the path does not " +"point to an executable script file. This hook is called each time openwisp-" +"config applies a configuration, but after services are reloaded." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:91 +msgid "" +"Path to pre-reload hook. The hook is not called if the path does not point " +"to an executable script file. This hook is called each time openwisp-config " +"applies a configuration, but before services are reloaded." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:95 +msgid "Post-reload Hook" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:91 +msgid "Pre-reload Hook" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:32 +msgid "Server URL" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:35 +msgid "Shared Secret" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:58 +msgid "Tags" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:58 +msgid "Tags applied to this device." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:60 +msgid "Test Config" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:62 +msgid "Test Script" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:23 +msgid "The Key of this device in the OpenWISP server." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:32 +msgid "" +"The URL to the OpenWISP server. Example: https://openwisp2.mynetwork.com" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:20 +msgid "The UUID of this device in the OpenWISP server." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:49 +msgid "The interface to use for getting the MAC for this device." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:52 +msgid "The interface to use for management and control." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:35 +msgid "The organization shared secret for auto enrollment." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:20 +msgid "UUID" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:38 +msgid "Update Interval" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:66 +msgid "" +"Use a unique hardware ID for device identification, for example a serial " +"number." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:88 +msgid "" +"Use the specified certificate directory to verify the peer. The certificates " +"must be in PEM format, and the directory must have been processed using the " +"c_rehash utility supplied with openssl." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:85 +msgid "" +"Use the specified certificate file to verify the peer. The file may contain " +"multiple CA certificates. The certificate(s) must be in PEM format." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:81 +msgid "" +"Value passed to curl --max-time argument, defaults to 30. Expressed in " +"seconds." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:43 +msgid "Verify SSL" +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:43 +msgid "Verify the server SSL certificate." +msgstr "" + +#: applications/luci-app-openwisp/htdocs/luci-static/resources/view/openwisp.js:46 +msgid "" +"When using Automatic registration, this feature allows devices to keep the " +"same configuration even if reset or reflashed. This feature is enabled by " +"default, but must be enabled also in the controller application in order to " +"work." +msgstr "" diff --git a/applications/luci-app-openwisp/root/usr/share/luci/menu.d/luci-app-openwisp.json b/applications/luci-app-openwisp/root/usr/share/luci/menu.d/luci-app-openwisp.json new file mode 100644 index 0000000000..75d13b9560 --- /dev/null +++ b/applications/luci-app-openwisp/root/usr/share/luci/menu.d/luci-app-openwisp.json @@ -0,0 +1,13 @@ +{ + "admin/services/openwisp": { + "title": "OpenWISP", + "order": 90, + "action": { + "type": "view", + "path": "openwisp" + }, + "depends": { + "acl": [ "luci-app-openwisp" ] + } + } +} diff --git a/applications/luci-app-openwisp/root/usr/share/rpcd/acl.d/luci-app-openwisp.json b/applications/luci-app-openwisp/root/usr/share/rpcd/acl.d/luci-app-openwisp.json new file mode 100644 index 0000000000..35a3d128d0 --- /dev/null +++ b/applications/luci-app-openwisp/root/usr/share/rpcd/acl.d/luci-app-openwisp.json @@ -0,0 +1,11 @@ +{ + "luci-app-openwisp": { + "description": "Grant access to luci-app-openwisp", + "read": { + "uci": [ "openwisp" ] + }, + "write": { + "uci": [ "openwisp" ] + } + } +} -- cgit v1.2.3