sysutils/nut: add listen, make arguments more flexible (#1020)

(cherry picked from commit 6ca68369b9)
This commit is contained in:
Michael 2018-11-25 12:40:58 +01:00 committed by Franco Fichtner
parent add80b4fa8
commit 8cd461d92b
5 changed files with 47 additions and 17 deletions

View file

@ -1,6 +1,5 @@
PLUGIN_NAME= nut
PLUGIN_VERSION= 1.3
PLUGIN_REVISION= 2
PLUGIN_VERSION= 1.4
PLUGIN_COMMENT= Network UPS Tools
PLUGIN_DEPENDS= nut
PLUGIN_MAINTAINER= m.muenz@gmail.com

View file

@ -19,6 +19,14 @@
<type>text</type>
<help>Set a name for your UPS.</help>
</field>
<field>
<id>nut.general.listen</id>
<label>Listen Address</label>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set the addresses this service listen on.</help>
</field>
</subtab>
<subtab id="nut-general-account" description="Nut Account Settings">
<field>
@ -46,7 +54,9 @@
<field>
<id>nut.usbhid.args</id>
<label>Extra Arguments</label>
<type>text</type>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
@ -60,7 +70,9 @@
<field>
<id>nut.apcsmart.args</id>
<label>Extra Arguments</label>
<type>text</type>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
@ -74,7 +86,9 @@
<field>
<id>nut.blazerusb.args</id>
<label>Extra Arguments</label>
<type>text</type>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>
@ -88,7 +102,9 @@
<field>
<id>nut.blazerser.args</id>
<label>Extra Arguments</label>
<type>text</type>
<style>tokenize</style>
<type>select_multiple</type>
<allownew>true</allownew>
<help>Set extra arguments for this UPS, e.g. "port=auto".</help>
</field>
</subtab>

View file

@ -1,7 +1,7 @@
<model>
<mount>//OPNsense/Nut</mount>
<description>Network UPS Tools</description>
<version>1.0.1</version>
<version>1.0.2</version>
<items>
<general>
<enable type="BooleanField">
@ -20,6 +20,10 @@
<default>UPSName</default>
<Required>Y</Required>
</name>
<listen type="CSVListField">
<default>127.0.0.1,::1</default>
<Required>Y</Required>
</listen>
</general>
<account>
@ -38,7 +42,7 @@
<Required>Y</Required>
<default>0</default>
</enable>
<args type="TextField">
<args type="CSVListField">
<default>port=auto</default>
<Required>N</Required>
</args>
@ -48,7 +52,7 @@
<Required>Y</Required>
<default>0</default>
</enable>
<args type="TextField">
<args type="CSVListField">
<default>port=auto</default>
<Required>N</Required>
</args>
@ -58,7 +62,7 @@
<Required>Y</Required>
<default>0</default>
</enable>
<args type="TextField">
<args type="CSVListField">
<default>port=auto</default>
<Required>N</Required>
</args>
@ -68,7 +72,7 @@
<Required>Y</Required>
<default>0</default>
</enable>
<args type="TextField">
<args type="CSVListField">
<default>port=auto</default>
<Required>N</Required>
</args>

View file

@ -6,28 +6,36 @@
[{{ OPNsense.Nut.general.name }}]
driver=usbhid-ups
{% if helpers.exists('OPNsense.Nut.usbhid.args') and OPNsense.Nut.usbhid.args != '' %}
{{ OPNsense.Nut.usbhid.args }}
{% for args in OPNsense.Nut.usbhid.args.split(',') %}
{{ args }}
{% endfor %}
{% endif %}
{% endif %}
{% if helpers.exists('OPNsense.Nut.apcsmart.enable') and OPNsense.Nut.apcsmart.enable == '1' %}
[{{ OPNsense.Nut.general.name }}]
driver=apcsmart
{% if helpers.exists('OPNsense.Nut.apcsmart.args') and OPNsense.Nut.apcsmart.args != '' %}
{{ OPNsense.Nut.apcsmart.args }}
{% for args in OPNsense.Nut.apcsmart.args.split(',') %}
{{ args }}
{% endfor %}
{% endif %}
{% endif %}
{% if helpers.exists('OPNsense.Nut.blazerusb.enable') and OPNsense.Nut.blazerusb.enable == '1' %}
[{{ OPNsense.Nut.general.name }}]
driver=blazer_usb
{% if helpers.exists('OPNsense.Nut.blazerusb.args') and OPNsense.Nut.blazerusb.args != '' %}
{{ OPNsense.Nut.blazerusb.args }}
{% for args in OPNsense.Nut.blazerusb.args.split(',') %}
{{ args }}
{% endfor %}
{% endif %}
{% endif %}
{% if helpers.exists('OPNsense.Nut.blazerser.enable') and OPNsense.Nut.blazerser.enable == '1' %}
[{{ OPNsense.Nut.general.name }}]
driver=blazer_ser
{% if helpers.exists('OPNsense.Nut.blazerser.args') and OPNsense.Nut.blazerser.args != '' %}
{{ OPNsense.Nut.blazerser.args }}
{% for args in OPNsense.Nut.blazerser.args.split(',') %}
{{ args }}
{% endfor %}
{% endif %}
{% endif %}
{% endif %}

View file

@ -3,7 +3,10 @@
#
{% if helpers.exists('OPNsense.Nut.general.enable') and OPNsense.Nut.general.enable == '1' %}
{% if helpers.exists('OPNsense.Nut.general.mode') and OPNsense.Nut.general.mode == 'standalone' %}
LISTEN 127.0.0.1
LISTEN ::1
{% if helpers.exists('OPNsense.Nut.general.listen') %}
{% for listenaddress in OPNsense.Nut.general.listen.split(',') %}
LISTEN {{ listenaddress }} 3493
{% endfor %}
{% endif %}
{% endif %}
{% endif %}