diff --git a/sysutils/nut/Makefile b/sysutils/nut/Makefile
index 84c84f78f..7863e03f5 100644
--- a/sysutils/nut/Makefile
+++ b/sysutils/nut/Makefile
@@ -1,5 +1,5 @@
PLUGIN_NAME= nut
-PLUGIN_VERSION= 0.2
+PLUGIN_VERSION= 0.3
PLUGIN_COMMENT= Network UPS Tools
PLUGIN_DEPENDS= nut
PLUGIN_MAINTAINER= m.muenz@gmail.com
diff --git a/sysutils/nut/src/etc/inc/plugins.inc.d/nut.inc b/sysutils/nut/src/etc/inc/plugins.inc.d/nut.inc
index 43e95f2b4..9dcb6149b 100644
--- a/sysutils/nut/src/etc/inc/plugins.inc.d/nut.inc
+++ b/sysutils/nut/src/etc/inc/plugins.inc.d/nut.inc
@@ -1,7 +1,7 @@
general->mode == 'netclient') {
+ return true;
+ }
+
+ return false;
+}
+
function nut_services()
{
$services = array();
@@ -52,5 +62,17 @@ function nut_services()
'pidfile' => '/var/run/nut.pid'
);
}
+ if (nut_netclient()) {
+ $services[] = array(
+ 'description' => gettext('Network UPS Monitor'),
+ 'configd' => array(
+ 'restart' => array('nut restart'),
+ 'start' => array('nut start'),
+ 'stop' => array('nut stop'),
+ ),
+ 'name' => 'upsmon'
+ );
+ }
+
return $services;
}
diff --git a/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/forms/settings.xml b/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/forms/settings.xml
index d2c659f35..4bb232bce 100644
--- a/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/forms/settings.xml
+++ b/sysutils/nut/src/opnsense/mvc/app/controllers/OPNsense/Nut/forms/settings.xml
@@ -7,6 +7,12 @@
checkbox
Enable or disable the nut service.
+
+ nut.general.mode
+
+ dropdown
+ Set the service mode. Currently only standalone and netclient are available.
+
@@ -44,6 +50,38 @@
Set extra arguments for this UPS, e.g. "port=auto".
+
+
+ nut.netclient.enable
+
+ checkbox
+ Enable the Netclient driver.
+
+
+ nut.netclient.name
+
+ text
+ Set a name for your UPS.
+
+
+ nut.netclient.address
+
+ text
+ Set the IP address of the remote NUT server.
+
+
+ nut.netclient.user
+
+ text
+ Set the username of the remote NUT server.
+
+
+ nut.netclient.password
+
+ password
+ Set the password of the remote NUT server.
+
+
nut-general-settings
diff --git a/sysutils/nut/src/opnsense/mvc/app/models/OPNsense/Nut/Nut.xml b/sysutils/nut/src/opnsense/mvc/app/models/OPNsense/Nut/Nut.xml
index c7625f750..484ed8f9f 100644
--- a/sysutils/nut/src/opnsense/mvc/app/models/OPNsense/Nut/Nut.xml
+++ b/sysutils/nut/src/opnsense/mvc/app/models/OPNsense/Nut/Nut.xml
@@ -7,6 +7,14 @@
0
Y
+
+ standalone
+ Y
+
+ standalone
+ netclient
+
+
@@ -34,5 +42,25 @@
N
+
+
+ Y
+ 0
+
+
+ UPS-Name
+ Y
+
+
+
+ N
+
+
+ N
+
+
+ N
+
+
diff --git a/sysutils/nut/src/opnsense/service/conf/actions.d/actions_nut.conf b/sysutils/nut/src/opnsense/service/conf/actions.d/actions_nut.conf
index 7637019ce..994fd034b 100644
--- a/sysutils/nut/src/opnsense/service/conf/actions.d/actions_nut.conf
+++ b/sysutils/nut/src/opnsense/service/conf/actions.d/actions_nut.conf
@@ -1,17 +1,17 @@
[start]
-command:/usr/local/opnsense/scripts/OPNsense/Nut/setup.sh;/usr/local/etc/rc.d/nut start
+command:/usr/local/opnsense/scripts/OPNsense/Nut/setup.sh;/usr/local/etc/rc.d/nut start;/usr/local/etc/rc.d/nut_upsmon start
parameters:
type:script
message:starting nut
[stop]
-command:/usr/local/etc/rc.d/nut onestop
+command:/usr/local/etc/rc.d/nut stop;/usr/local/etc/rc.d/nut_upsmon stop;exit 0
parameters:
type:script
message:stopping nut
[restart]
-command:/usr/local/opnsense/scripts/OPNsense/Nut/setup.sh;/usr/local/etc/rc.d/nut restart
+command:/usr/local/opnsense/scripts/OPNsense/Nut/setup.sh;/usr/local/etc/rc.d/nut restart;/usr/local/etc/rc.d/nut_upsmon restart
parameters:
type:script
message:restarting nut
diff --git a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/+TARGETS b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/+TARGETS
index 6b77fcd28..afceabe42 100644
--- a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/+TARGETS
+++ b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/+TARGETS
@@ -1,4 +1,5 @@
nut:/etc/rc.conf.d/nut
+nut_upsmon:/etc/rc.conf.d/nut_upsmon
nut.conf:/usr/local/etc/nut/nut.conf
ups.conf:/usr/local/etc/nut/ups.conf
upsd.conf:/usr/local/etc/nut/upsd.conf
diff --git a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/nut.conf b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/nut.conf
index 3ac32575f..a45db613b 100644
--- a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/nut.conf
+++ b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/nut.conf
@@ -2,5 +2,7 @@
# the next update.
#
{% if helpers.exists('OPNsense.Nut.general.enable') and OPNsense.Nut.general.enable == '1' %}
-MODE=standalone
+{% if helpers.exists('OPNsense.Nut.general.mode') and OPNsense.Nut.general.mode != '' %}
+MODE={{ OPNsense.Nut.general.mode }}
+{% endif %}
{% endif %}
diff --git a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/nut_upsmon b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/nut_upsmon
new file mode 100644
index 000000000..6c93b51f4
--- /dev/null
+++ b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/nut_upsmon
@@ -0,0 +1,7 @@
+{% 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 == 'netclient' %}
+nut_upsmon_enable="YES"
+{% else %}
+nut_upsmon_enable="NO"
+{% endif %}
+{% endif %}
diff --git a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsd.conf b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsd.conf
index 8e715095d..6cf23d5b4 100644
--- a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsd.conf
+++ b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsd.conf
@@ -2,6 +2,8 @@
# the next update.
#
{% 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
+{% endif %}
{% endif %}
diff --git a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsd.users b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsd.users
index 60675121b..9b13c90f2 100644
--- a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsd.users
+++ b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsd.users
@@ -2,15 +2,19 @@
# 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 != '' %}
+{% if helpers.exists('OPNsense.Nut.general.mode') and OPNsense.Nut.general.mode == 'standalone' %}
+{% 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 %}
{% endif %}
-{% if helpers.exists('OPNsense.Nut.account.mon_password') and OPNsense.Nut.account.mon_password != '' %}
+{% if helpers.exists('OPNsense.Nut.general.mode') and OPNsense.Nut.general.mode == 'standalone' %}
+{% 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 %}
{% endif %}
diff --git a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsmon.conf b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsmon.conf
index 4784c6569..955c16f58 100644
--- a/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsmon.conf
+++ b/sysutils/nut/src/opnsense/service/templates/OPNsense/Nut/upsmon.conf
@@ -6,3 +6,8 @@ MONITOR {{ OPNsense.Nut.usbhid.name }} 1 monuser {{ OPNsense.Nut.account.mon_pas
SHUTDOWNCMD "/sbin/shutdown -p +0"
POWERDOWNFLAG /etc/killpower
{% endif %}
+{% if helpers.exists('OPNsense.Nut.netclient.enable') and OPNsense.Nut.netclient.enable == '1' %}
+MONITOR {{ OPNsense.Nut.netclient.name }}@{{ OPNsense.Nut.netclient.address }} 1 {{ OPNsense.Nut.netclient.user }} {{ OPNsense.Nut.netclient.password }} slave
+SHUTDOWNCMD "/sbin/shutdown -p +0"
+POWERDOWNFLAG /etc/killpower
+{% endif %}