From 02269d96af2f2415ba0fc1b761ed3c2effbce624 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 22 Oct 2020 09:19:32 +0200 Subject: [PATCH] sysutils/hw-probe: New plugin (#2075) --- sysutils/hw-probe/Makefile | 8 +++ sysutils/hw-probe/pkg-descr | 1 + .../Hwprobe/Api/GeneralController.php | 37 +++++++++++++ .../Hwprobe/Api/ServiceController.php | 51 ++++++++++++++++++ .../OPNsense/Hwprobe/GeneralController.php | 38 +++++++++++++ .../OPNsense/Hwprobe/forms/general.xml | 8 +++ .../app/models/OPNsense/Hwprobe/ACL/ACL.xml | 9 ++++ .../app/models/OPNsense/Hwprobe/General.php | 35 ++++++++++++ .../app/models/OPNsense/Hwprobe/General.xml | 11 ++++ .../app/models/OPNsense/Hwprobe/Menu/Menu.xml | 7 +++ .../app/views/OPNsense/Hwprobe/general.volt | 54 +++++++++++++++++++ .../conf/actions.d/actions_hwprobe.conf | 5 ++ 12 files changed, 264 insertions(+) create mode 100644 sysutils/hw-probe/Makefile create mode 100644 sysutils/hw-probe/pkg-descr create mode 100644 sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/Api/GeneralController.php create mode 100644 sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/Api/ServiceController.php create mode 100644 sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/GeneralController.php create mode 100644 sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/forms/general.xml create mode 100644 sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/ACL/ACL.xml create mode 100644 sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/General.php create mode 100644 sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/General.xml create mode 100644 sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/Menu/Menu.xml create mode 100644 sysutils/hw-probe/src/opnsense/mvc/app/views/OPNsense/Hwprobe/general.volt create mode 100644 sysutils/hw-probe/src/opnsense/service/conf/actions.d/actions_hwprobe.conf diff --git a/sysutils/hw-probe/Makefile b/sysutils/hw-probe/Makefile new file mode 100644 index 000000000..8ce8dff66 --- /dev/null +++ b/sysutils/hw-probe/Makefile @@ -0,0 +1,8 @@ +PLUGIN_NAME= hw-probe +PLUGIN_VERSION= 0.1 +PLUGIN_COMMENT= Collect hardware diagnostics +PLUGIN_DEPENDS= hw-probe +PLUGIN_MAINTAINER= m.muenz@gmail.com +PLUGIN_DEVEL= yes + +.include "../../Mk/plugins.mk" diff --git a/sysutils/hw-probe/pkg-descr b/sysutils/hw-probe/pkg-descr new file mode 100644 index 000000000..efb1be1a1 --- /dev/null +++ b/sysutils/hw-probe/pkg-descr @@ -0,0 +1 @@ +Send anonymized hardware diagnostics to https://bsd-hardware.info \ No newline at end of file diff --git a/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/Api/GeneralController.php b/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/Api/GeneralController.php new file mode 100644 index 000000000..41096f3bb --- /dev/null +++ b/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/Api/GeneralController.php @@ -0,0 +1,37 @@ + + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OPNsense\Hwprobe\Api; + +use OPNsense\Base\ApiMutableModelControllerBase; + +class GeneralController extends ApiMutableModelControllerBase +{ + protected static $internalModelClass = '\OPNsense\Hwprobe\General'; + protected static $internalModelName = 'general'; +} diff --git a/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/Api/ServiceController.php b/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/Api/ServiceController.php new file mode 100644 index 000000000..8fd5e8d39 --- /dev/null +++ b/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/Api/ServiceController.php @@ -0,0 +1,51 @@ + + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OPNsense\Hwprobe\Api; + +use OPNsense\Base\ApiMutableServiceControllerBase; +use OPNsense\Core\Backend; + +class ServiceController extends ApiMutableServiceControllerBase +{ + protected static $internalServiceClass = '\OPNsense\Hwprobe\General'; + protected static $internalServiceTemplate = 'OPNsense/Hwprobe'; + protected static $internalServiceEnabled = 'enabled'; + protected static $internalServiceName = 'hwprobe'; + + /** + * generate report + * @return array + */ + public function reportAction() + { + $backend = new Backend(); + $response = $backend->configdRun("hwprobe report"); + return array("response" => $response); + } +} diff --git a/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/GeneralController.php b/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/GeneralController.php new file mode 100644 index 000000000..1c9c039da --- /dev/null +++ b/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/GeneralController.php @@ -0,0 +1,38 @@ + + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OPNsense\Hwprobe; + +class GeneralController extends \OPNsense\Base\IndexController +{ + public function indexAction() + { + $this->view->generalForm = $this->getForm('general'); + $this->view->pick('OPNsense/Hwprobe/general'); + } +} diff --git a/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/forms/general.xml b/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/forms/general.xml new file mode 100644 index 000000000..6b7782611 --- /dev/null +++ b/sysutils/hw-probe/src/opnsense/mvc/app/controllers/OPNsense/Hwprobe/forms/general.xml @@ -0,0 +1,8 @@ +
+ + general.enabled + + checkbox + Enable HW-Probe. + +
diff --git a/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/ACL/ACL.xml b/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/ACL/ACL.xml new file mode 100644 index 000000000..6e3f60689 --- /dev/null +++ b/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/ACL/ACL.xml @@ -0,0 +1,9 @@ + + + Services: HWProbe + + ui/hwprobe/* + api/hwprobe/* + + + diff --git a/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/General.php b/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/General.php new file mode 100644 index 000000000..769be9ab1 --- /dev/null +++ b/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/General.php @@ -0,0 +1,35 @@ + + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +namespace OPNsense\Hwprobe; + +use OPNsense\Base\BaseModel; + +class General extends BaseModel +{ +} diff --git a/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/General.xml b/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/General.xml new file mode 100644 index 000000000..96efb0749 --- /dev/null +++ b/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/General.xml @@ -0,0 +1,11 @@ + + //OPNsense/hwprobe/general + HWProbe configuration + 0.0.1 + + + 0 + Y + + + diff --git a/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/Menu/Menu.xml b/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/Menu/Menu.xml new file mode 100644 index 000000000..33d99e72d --- /dev/null +++ b/sysutils/hw-probe/src/opnsense/mvc/app/models/OPNsense/Hwprobe/Menu/Menu.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/sysutils/hw-probe/src/opnsense/mvc/app/views/OPNsense/Hwprobe/general.volt b/sysutils/hw-probe/src/opnsense/mvc/app/views/OPNsense/Hwprobe/general.volt new file mode 100644 index 000000000..8e1a7d353 --- /dev/null +++ b/sysutils/hw-probe/src/opnsense/mvc/app/views/OPNsense/Hwprobe/general.volt @@ -0,0 +1,54 @@ +{# + # Copyright (c) 2020 Deciso B.V. + # Copyright (c) 2020 Michael Muenz + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without modification, + # are permitted provided that the following conditions are met: + # + # 1. Redistributions of source code must retain the above copyright notice, + # this list of conditions and the following disclaimer. + # + # 2. Redistributions in binary form must reproduce the above copyright notice, + # this list of conditions and the following disclaimer in the documentation + # and/or other materials provided with the distribution. + # + # THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + # POSSIBILITY OF SUCH DAMAGE. + #} + +
+
+
+
+
+

+    
+
+
+ +
+
+ + + diff --git a/sysutils/hw-probe/src/opnsense/service/conf/actions.d/actions_hwprobe.conf b/sysutils/hw-probe/src/opnsense/service/conf/actions.d/actions_hwprobe.conf new file mode 100644 index 000000000..14c0771a8 --- /dev/null +++ b/sysutils/hw-probe/src/opnsense/service/conf/actions.d/actions_hwprobe.conf @@ -0,0 +1,5 @@ +[report] +command:/usr/local/bin/hw-probe +parameters: +type:script_output +message:collecting hardware diagnostics