sysutils/nut: New plugin (#441)

(cherry picked from commit d0c1e45334)
(cherry picked from commit 3cc82d5b4b)
This commit is contained in:
Michael 2017-12-19 10:09:19 +01:00 committed by Franco Fichtner
parent 24c7f50123
commit 93be37d713
22 changed files with 674 additions and 1 deletions

View file

@ -41,9 +41,10 @@ net-mgmt/collectd -- Collect system and application performance metrics periodic
net-mgmt/snmp -- SNMP Server via bsnmpd
net-mgmt/telegraf -- Agent for collecting metrics and data
net-mgmt/zabbix-agent -- Enterprise-class open source distributed monitoring agent
net-mgmt/zabbix-proxy -- Zabbix-Proxy enables decentralized monitoring
net-mgmt/zabbix-proxy -- Zabbix Proxy enables decentralized monitoring
net/arp-scan -- Get all peers connected to a local network
net/freeradius -- RADIUS Authentication, Authorization and Accounting Server
net/frr -- FRR Routing Suite
net/ftp-proxy -- Control ftp-proxy processes
net/haproxy -- Reliable, high performance TCP/HTTP load balancer
net/igmp-proxy -- IGMP-Proxy Service
@ -66,6 +67,7 @@ security/tinc -- Tinc VPN
security/tor -- The Onion Router
sysutils/boot-delay -- Apply a persistent 10 second boot delay
sysutils/monit -- Proactive system monitoring
sysutils/nut -- Network UPS Tools
sysutils/smart -- SMART tools
sysutils/vmware -- VMware tools
sysutils/xen -- Xen guest utilities

8
sysutils/nut/Makefile Normal file
View file

@ -0,0 +1,8 @@
PLUGIN_NAME= nut
PLUGIN_VERSION= 0.1
PLUGIN_COMMENT= Network UPS Tools
PLUGIN_DEPENDS= nut
PLUGIN_MAINTAINER= m.muenz@gmail.com
PLUGIN_DEVEL= yes
.include "../../Mk/plugins.mk"

7
sysutils/nut/pkg-descr Normal file
View file

@ -0,0 +1,7 @@
The primary goal of the Network UPS Tools (NUT) project is to provide
support for Power Devices, such as Uninterruptible Power Supplies,
Power Distribution Units, Automatic Transfer Switch, Power Supply Units
and Solar Controllers.
NUT provides many control and monitoring features, with a uniform control
and management interface.

View file

@ -0,0 +1,56 @@
<?php
/*
Copyright (C) 2017 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.
*/
function nut_enabled()
{
$model = new \OPNsense\Nut\Nut();
if ((string)$model->general->enabled == '1') {
return true;
}
return false;
}
function nut_services()
{
$services = array();
if (nut_enabled()) {
$services[] = array(
'description' => gettext('Network UPS Tools'),
'configd' => array(
'restart' => array('nut restart'),
'start' => array('nut start'),
'stop' => array('nut stop'),
),
'name' => 'nut',
'pidfile' => '/var/run/nut.pid'
);
}
return $services;
}

View file

@ -0,0 +1,143 @@
<?php
/*
* Copyright (C) 2017 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.
*/
namespace OPNsense\Nut\Api;
use \OPNsense\Base\ApiControllerBase;
use \OPNsense\Core\Backend;
use \OPNsense\Nut\Nut;
class ServiceController extends ApiControllerBase
{
/**
* restart nut service
* @return array
*/
public function restartAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun('nut restart');
return array('response' => $response);
} else {
return array('response' => array());
}
}
/**
* retrieve status of nut
* @return array
* @throws \Exception
*/
public function statusAction()
{
$backend = new Backend();
$nut = new Nut();
$response = $backend->configdRun('nut status');
if (strpos($response, 'not running') > 0) {
if ((string)$nut->general->enabled == 1) {
$status = 'stopped';
} else {
$status = 'disabled';
}
} elseif (strpos($response, 'is running') > 0) {
$status = 'running';
} elseif ((string)$nut->general->enabled == 0) {
$status = 'disabled';
} else {
$status = 'unknown';
}
return array('status' => $status);
}
/**
* reconfigure nut, generate config and reload
*/
public function reconfigureAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$nut = new Nut();
$backend = new Backend();
$this->stopAction();
// generate template
$backend->configdRun('template reload OPNsense/Nut');
// (re)start daemon
if ((string)$nut->general->enabled == '1') {
$this->startAction();
}
return array('status' => 'ok');
} else {
return array('status' => 'failed');
}
}
/**
* stop nut service
* @return array
*/
public function stopAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun('nut stop');
return array('response' => $response);
} else {
return array('response' => array());
}
}
/**
* start nut service
* @return array
*/
public function startAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun('nut start');
return array('response' => $response);
} else {
return array('response' => array());
}
}
}

View file

@ -0,0 +1,38 @@
<?php
/**
* Copyright (C) 2017 Fabian Franz
*
* 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 SettingsController extends ApiMutableModelControllerBase
{
static protected $internalModelClass = '\OPNsense\Nut\Nut';
static protected $internalModelName = 'nut';
}

View file

@ -0,0 +1,49 @@
<?php
/*
Copyright (C) 2017 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.
*/
namespace OPNsense\Nut;
use \OPNsense\Core\Backend;
use \OPNsense\Nut;
/**
* Class IndexController
* @package OPNsense/Nut
*/
class IndexController extends \OPNsense\Base\IndexController
{
public function indexAction()
{
$backend = new Backend();
$this->view->settings = $this->getForm("settings");
$this->view->pick('OPNsense/Nut/index');
}
}

View file

@ -0,0 +1,50 @@
<form>
<tab id="nut-general" description="General Settings">
<subtab id="nut-general-settings" description="General Nut Settings">
<field>
<id>nut.general.enable</id>
<label>Enable Nut</label>
<type>checkbox</type>
<help>Enable or disable the nut service.</help>
</field>
</subtab>
<subtab id="nut-general-account" description="Nut Account Settings">
<field>
<id>nut.account.admin_password</id>
<label>Admin Password</label>
<type>text</type>
<help>Set the admin password.</help>
</field>
<field>
<id>nut.account.mon_password</id>
<label>Monitor Password</label>
<type>text</type>
<help>Set the monitor password.</help>
</field>
</subtab>
</tab>
<tab id="nut-ups-type" description="UPS Type">
<subtab id="nut-ups-usbhid" description="USBHID-Driver">
<field>
<id>nut.usbhid.enable</id>
<label>Enable</label>
<type>checkbox</type>
<help>Enable the USBHID driver.</help>
</field>
<field>
<id>nut.usbhid.name</id>
<label>Name</label>
<type>text</type>
<help>Set a name for your UPS.</help>
</field>
<field>
<id>nut.usbhid.args</id>
<label>Extra Arguments</label>
<type>text</type>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
</tab>
<activetab>nut-general-settings</activetab>
</form>

View file

@ -0,0 +1,9 @@
<acl>
<page-nut>
<name>Nut</name>
<patterns>
<pattern>ui/nut/*</pattern>
<pattern>api/nut/*</pattern>
</patterns>
</page-nut>
</acl>

View file

@ -0,0 +1,5 @@
<menu>
<Services>
<Nut cssClass="fa fa-battery-full fa-fw" url="/ui/nut/" />
</Services>
</menu>

View file

@ -0,0 +1,34 @@
<?php
/*
Copyright (C) 2017 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.
*/
namespace OPNsense\Nut;
use OPNsense\Base\BaseModel;
class Nut extends BaseModel
{
}

View file

@ -0,0 +1,38 @@
<model>
<mount>//OPNsense/Nut</mount>
<description>Network UPS Tools</description>
<items>
<general>
<enable type="BooleanField">
<default>0</default>
<Required>Y</Required>
</enable>
</general>
<account>
<admin_password type="TextField">
<Required>Y</Required>
<default>Password</default>
</admin_password>
<mon_password type="TextField">
<Required>Y</Required>
<default>Password</default>
</mon_password>
</account>
<usbhid>
<enable type="BooleanField">
<Required>Y</Required>
<default>0</default>
</enable>
<name type="TextField">
<default>UPS-Name</default>
<Required>Y</Required>
</name>
<args type="TextField">
<default>port=auto</default>
<Required>N</Required>
</args>
</usbhid>
</items>
</model>

View file

@ -0,0 +1,145 @@
{#
Copyright (C) 2017 Michael Muenz
OPNsense® is Copyright © 2014 2017 by Deciso B.V.
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.
#}
<script type="text/javascript">
$( document ).ready(function() {
var data_get_map = {'frm_nut':'/api/nut/settings/get'};
// load initial data
mapDataToFormUI(data_get_map).done(function(){
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
// request service status on load and update status box
ajaxCall(url="/api/nut/service/status", sendData={}, callback=function(data,status) {
updateServiceStatusUI(data['status']);
});
});
// update history on tab state and implement navigation
if(window.location.hash != "") {
$('a[href="' + window.location.hash + '"]').click()
}
$('.nav-tabs a').on('shown.bs.tab', function (e) {
history.pushState(null, null, e.target.hash);
});
// form save event handlers for all defined forms
$('[id*="save_"]').each(function(){
$(this).click(function() {
var frm_id = $(this).closest("form").attr("id");
var frm_title = $(this).closest("form").attr("data-title");
// save data for General TAB
saveFormToEndpoint(url="/api/nut/settings/set", formid=frm_id, callback_ok=function(){
// on correct save, perform reconfigure. set progress animation when reloading
$("#"+frm_id+"_progress").addClass("fa fa-spinner fa-pulse");
ajaxCall(url="/api/nut/service/reconfigure", sendData={}, callback=function(data,status){
// when done, disable progress animation.
$("#"+frm_id+"_progress").removeClass("fa fa-spinner fa-pulse");
if (status != "success" || data['status'] != 'ok' ) {
// fix error handling
BootstrapDialog.show({
type:BootstrapDialog.TYPE_WARNING,
title: frm_title,
message: JSON.stringify(data),
draggable: true
});
} else {
// request service status after successful save and update status box (wait a few seconds before update)
setTimeout(function(){
ajaxCall(url="/api/nut/service/status", sendData={}, callback=function(data,status) {
updateServiceStatusUI(data['status']);
});
},3000);
}
});
});
});
});
});
</script>
<ul class="nav nav-tabs" role="tablist" id="maintabs">
{% for tab in settings['tabs']|default([]) %}
{% if tab['subtabs']|default(false) %}
{# Tab with dropdown #}
{# Find active subtab #}
{% set active_subtab="" %}
{% for subtab in tab['subtabs']|default({}) %}
{% if subtab[0]==settings['activetab']|default("") %}
{% set active_subtab=subtab[0] %}
{% endif %}
{% endfor %}
<li role="presentation" class="dropdown {% if settings['activetab']|default("") == active_subtab %}active{% endif %}">
<a data-toggle="dropdown" href="#" class="dropdown-toggle pull-right visible-lg-inline-block visible-md-inline-block visible-xs-inline-block visible-sm-inline-block" role="button" style="border-left: 1px dashed lightgray;">
<b><span class="caret"></span></b>
</a>
<a data-toggle="tab" href="#subtab_{{ tab['subtabs'][0][0] }}" class="visible-lg-inline-block visible-md-inline-block visible-xs-inline-block visible-sm-inline-block" style="border-right:0px;"><b>{{ tab[1] }}</b></a>
<ul class="dropdown-menu" role="menu">
{% for subtab in tab['subtabs']|default({}) %}
<li class="{% if settings['activetab']|default("") == subtab[0] %}active{% endif %}"><a data-toggle="tab" href="#subtab_{{subtab[0]}}"><i class="fa fa-check-square"></i> {{ subtab[1] }}</a></li>
{% endfor %}
</ul>
</li>
{% else %}
{# Standard Tab #}
<li {% if settings['activetab']|default("") == tab[0] %} class="active" {% endif %}>
<a data-toggle="tab" href="#tab_{{ tab[0] }}">
<b>{{ tab[1] }}</b>
</a>
</li>
{% endif %}
{% endfor %}
</ul>
<div class="content-box tab-content">
{% for tab in settings['tabs']|default([]) %}
{% if tab['subtabs']|default(false) %}
{# Tab with dropdown #}
{% for subtab in tab['subtabs']|default({})%}
<div id="subtab_{{subtab[0]}}" class="tab-pane fade{% if settings['activetab']|default("") == subtab[0] %} in active {% endif %}">
{{ partial("layout_partials/base_form",['fields':subtab[2],'id':'frm_'~subtab[0],'data_title':subtab[1],'apply_btn_id':'save_'~subtab[0]]) }}
</div>
{% endfor %}
{% endif %}
{% if tab['subtabs']|default(false)==false %}
<div id="tab_{{tab[0]}}" class="tab-pane fade{% if settings['activetab']|default("") == tab[0] %} in active {% endif %}">
{{ partial("layout_partials/base_form",['fields':tab[2],'id':'frm_'~tab[0],'apply_btn_id':'save_'~tab[0]]) }}
</div>
{% endif %}
{% endfor %}
</div>

View file

@ -0,0 +1,4 @@
#!/bin/sh
mkdir -p /var/db/nut
chown uucp:uucp /var/db/nut

View file

@ -0,0 +1,23 @@
[start]
command:/usr/local/opnsense/scripts/OPNsense/Nut/setup.sh;/usr/local/etc/rc.d/nut start
parameters:
type:script
message:starting nut
[stop]
command:/usr/local/etc/rc.d/nut onestop
parameters:
type:script
message:stopping nut
[restart]
command:/usr/local/opnsense/scripts/OPNsense/Nut/setup.sh;/usr/local/etc/rc.d/nut restart
parameters:
type:script
message:restarting nut
[status]
command:/usr/local/etc/rc.d/nut status;exit 0
parameters:
type:script_output
message:request nut status

View file

@ -0,0 +1,6 @@
nut:/etc/rc.conf.d/nut
nut.conf:/usr/local/etc/nut/nut.conf
ups.conf:/usr/local/etc/nut/ups.conf
upsd.conf:/usr/local/etc/nut/upsd.conf
upsd.users:/usr/local/etc/nut/upsd.users
upsmon.conf:/usr/local/etc/nut/upsmon.conf

View file

@ -0,0 +1,7 @@
{% if helpers.exists('OPNsense.Nut.general.enable') and OPNsense.Nut.general.enable == '1' %}
nut_opnsense_bootup_run="/usr/local/opnsense/scripts/OPNsense/Nut/setup.sh"
nut_var_script="/usr/local/opnsense/scripts/OPNsense/Nut/setup.sh"
nut_enable="YES"
{% else %}
nut_enable="NO"
{% endif %}

View file

@ -0,0 +1,6 @@
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
{% if helpers.exists('OPNsense.Nut.general.enable') and OPNsense.Nut.general.enable == '1' %}
MODE=standalone
{% endif %}

View file

@ -0,0 +1,12 @@
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
{% if helpers.exists('OPNsense.Nut.general.enable') and OPNsense.Nut.general.enable == '1' %}
{% if helpers.exists('OPNsense.Nut.usbhid.enable') and OPNsense.Nut.usbhid.enable == '1' %}
[{{ OPNsense.Nut.usbhid.name }}]
driver=usbhid-ups
{% if helpers.exists('OPNsense.Nut.usbhid.args') and OPNsense.Nut.usbhid.args != '' %}
{{ OPNsense.Nut.usbhid.args }}
{% endif %}
{% endif %}
{% endif %}

View file

@ -0,0 +1,7 @@
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
{% if helpers.exists('OPNsense.Nut.general.enable') and OPNsense.Nut.general.enable == '1' %}
LISTEN 127.0.0.1
LISTEN ::1
{% endif %}

View file

@ -0,0 +1,16 @@
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
{% if helpers.exists('OPNsense.Nut.general.enable') and OPNsense.Nut.general.enable == '1' %}
{% if helpers.exists('OPNsense.Nut.account.admin_password') and OPNsense.Nut.account.admin_password != '' %}
[admin]
password={{ OPNsense.Nut.account.admin_password }}
actions=set
instcmds=all
{% endif %}
{% if helpers.exists('OPNsense.Nut.account.mon_password') and OPNsense.Nut.account.mon_password != '' %}
[monuser]
password={{ OPNsense.Nut.account.mon_password }}
upsmon master
{% endif %}
{% endif %}

View file

@ -0,0 +1,8 @@
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
{% if helpers.exists('OPNsense.Nut.usbhid.enable') and OPNsense.Nut.usbhid.enable == '1' %}
MONITOR {{ OPNsense.Nut.usbhid.name }} 1 monuser {{ OPNsense.Nut.account.mon_password }} master
SHUTDOWNCMD "/sbin/shutdown -p +0"
POWERDOWNFLAG /etc/killpower
{% endif %}