Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sysutils/nut/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PLUGIN_NAME= nut
PLUGIN_VERSION= 1.9
PLUGIN_REVISION= 1
PLUGIN_VERSION= 2.0
PLUGIN_COMMENT= Network UPS Tools
PLUGIN_DEPENDS= nut
PLUGIN_MAINTAINER= m.muenz@gmail.com
Expand Down
6 changes: 6 additions & 0 deletions sysutils/nut/pkg-descr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and management interface.
Plugin Changelog
----------------

2.0

* Add support for any number UPS drivers
* Add support for any UPS driver
* Add support for arbitrary global UPS driver options

1.9

* Add dashboard widget
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

/**
* Copyright (C) 2026 Gabriel Smith <ga29smith@gmail.com>
*
* 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\Nut\Api;

use OPNsense\Base\ApiMutableModelControllerBase;

class DriversController extends ApiMutableModelControllerBase
{
protected static $internalModelClass = '\OPNsense\Nut\Nut';
protected static $internalModelName = 'nut';

public function searchDriverAction()
{
return $this->searchBase("drivers.ups", null, "name");
}

public function getDriverAction($uuid = null)
{
return $this->getBase("ups", "drivers.ups", $uuid);
}

public function addDriverAction()
{
return $this->addBase("ups", "drivers.ups");
}

public function setDriverAction($uuid)
{
return $this->setBase("ups", "drivers.ups", $uuid);
}

public function delDriverAction($uuid)
{
return $this->delBase("drivers.ups", $uuid);
}

public function toggleDriverAction($uuid, $enabled = null)
{
return $this->toggleBase("drivers.ups", $uuid, $enabled);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/*
* Copyright (C) 2026 Gabriel Smith <ga29smith@gmail.com>
*
* 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\Nut;

use OPNsense\Base\IndexController;

class DriversController extends IndexController
{
public function indexAction()
{
$this->view->pick('OPNsense/Nut/drivers');
$this->view->driversForm = $this->getForm("drivers");
$this->view->formDialogDriver = $this->getForm("dialogDriver");
$this->view->formGridDriver = $this->getFormGrid("dialogDriver");
$model = new \OPNsense\Nut\Nut();
$this->view->server_enabled = $model->general->mode == "standalone";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<form>
<field>
<id>ups.enabled</id>
<label>Enabled</label>
<type>checkbox</type>
<help>Enable or disable this UPS.</help>
<grid_view>
<width>20</width>
<type>boolean</type>
<formatter>rowtoggle</formatter>
</grid_view>
</field>
<field>
<id>ups.name</id>
<label>Name</label>
<type>text</type>
<help>Set a name for this UPS.</help>
</field>
<field>
<id>ups.driver</id>
<label>Driver</label>
<type>text</type>
<help>Set the driver for this UPS.</help>
</field>
<field>
<id>ups.port</id>
<label>Port</label>
<type>text</type>
<help>Set the port for this UPS.</help>
</field>
<field>
<id>ups.options</id>
<label>UPS Options</label>
<style>tokenize</style>
<separator>;</separator>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set options for for this UPS. Valid options depend on the driver.</help>
<grid_view>
<visible>false</visible>
</grid_view>
</field>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<form>
<field>
<type>header</type>
<label>Global Driver Settings</label>
<advanced>true</advanced>
</field>
<field>
<id>nut.drivers.extra_global_options</id>
<label>ups.conf Extra Global Options</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra options for ups.conf not for a specific driver.</help>
<advanced>true</advanced>
</field>
</form>
Loading