* Tue Mar 18 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-9.sme
- update config for Nut 2.8.2 [SME: 12657] TODO review master/slave mode TODO convert master/slave to primary/secondary TODO convert to new config data + migrate TODO event and action
This commit is contained in:
parent
30dcc4861f
commit
a768594f0f
28
createlinks
28
createlinks
@ -2,23 +2,33 @@
|
||||
|
||||
use esmith::Build::CreateLinks qw(:all);
|
||||
|
||||
my @events = qw(bootstrap-console-save console-save post-install post-upgrade smeserver-nutUPS-update);
|
||||
my @events = qw(bootstrap-console-save console-save post-install post-upgrade smeserver-nutUPS-update nut-conf);
|
||||
|
||||
templates2events("/etc/sysconfig/ups", @events);
|
||||
templates2events("/usr/lib/systemd/system/nut-server.service.d/50koozali.conf", @events);
|
||||
templates2events("/usr/lib/systemd/system/nut-monitor.service.d/50koozali.conf", @events);
|
||||
|
||||
foreach (qw(ups.conf upsd.users upsmon.conf upssched.conf))
|
||||
foreach (qw(nut.conf ups.conf upsd.users upsmon.conf upssched.conf))
|
||||
{
|
||||
templates2events("/etc/ups/$_", @events);
|
||||
}
|
||||
|
||||
foreach (qw(bootstrap-console-save console-save smeserver-nutUPS-update))
|
||||
foreach (qw(bootstrap-console-save console-save smeserver-nutUPS-update nut-conf))
|
||||
{
|
||||
templates2events("/etc/ups/upsd.conf", $_);
|
||||
}
|
||||
|
||||
my $event="smeserver-nutUPS-update";
|
||||
safe_symlink("try-restart", "root/etc/e-smith/events/$event/services2adjust/nut");
|
||||
my $event= "nut-conf";
|
||||
event_link("nut-config-drivers", $event, "50");
|
||||
event_link("systemd-default", $event, "88");
|
||||
safe_symlink("try-restart", "root/etc/e-smith/events/$event/services2adjust/nut-driver@NUT");
|
||||
safe_symlink("try-restart", "root/etc/e-smith/events/$event/services2adjust/nut-monitor");
|
||||
safe_symlink("try-restart", "root/etc/e-smith/events/$event/services2adjust/nut-server");
|
||||
safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/masq");
|
||||
templates2events("/etc/rc.d/init.d/masq", $event);
|
||||
|
||||
|
||||
$event="smeserver-nutUPS-update";
|
||||
safe_symlink("try-restart", "root/etc/e-smith/events/$event/services2adjust/nut-driver@NUT");
|
||||
safe_symlink("try-restart", "root/etc/e-smith/events/$event/services2adjust/nut-monitor");
|
||||
safe_symlink("try-restart", "root/etc/e-smith/events/$event/services2adjust/nut-server");
|
||||
templates2events("/etc/systemd/system-preset/49-koozali.preset", $event);
|
||||
event_link("systemd-default", $event, "06");
|
||||
event_link("nut-config-drivers", $event, "50");
|
||||
event_link("systemd-default", $event, "88");
|
||||
|
@ -0,0 +1 @@
|
||||
disabled
|
@ -0,0 +1 @@
|
||||
service
|
@ -0,0 +1 @@
|
||||
disabled
|
@ -0,0 +1 @@
|
||||
service
|
@ -0,0 +1 @@
|
||||
disabled
|
@ -0,0 +1 @@
|
||||
service
|
1
root/etc/e-smith/db/configuration/defaults/nut/TCPPort
Normal file
1
root/etc/e-smith/db/configuration/defaults/nut/TCPPort
Normal file
@ -0,0 +1 @@
|
||||
3493
|
@ -1 +1 @@
|
||||
service
|
||||
configuration
|
||||
|
@ -2,7 +2,21 @@
|
||||
use MIME::Base64 qw(encode_base64);
|
||||
|
||||
my $nutrec = $DB->get('nut') || $DB->new_record('nut', {type => 'service'});
|
||||
$nutrec->set_prop('MasterPass', sprintf("%15.0f", int( (1000000000000000) * rand() ))) if not $nutrec->prop('MasterPass');
|
||||
$nutrec->set_prop('SlavePass', sprintf("%15.0f", int( (1000000000000000) * rand() ))) if not $nutrec->prop('SlavePass');
|
||||
# migrate old
|
||||
$nutrec->set_prop('PrimaryPass',$DB->get_prop_and_delete('nut', MasterPass)) if (exists $nut{'MasterPass'});
|
||||
$nutrec->set_prop('SecondaryPass',$DB->get_prop_and_delete('nut', SlavePass)) if (exists $nut{'SlavePass'});
|
||||
|
||||
$nutrec->set_prop('PrimaryPass', sprintf("%15.0f", int( (1000000000000000) * rand() ))) if not $nutrec->prop('PrimaryPass');
|
||||
$nutrec->set_prop('SecondaryPass', sprintf("%15.0f", int( (1000000000000000) * rand() ))) if not $nutrec->prop('SecondaryPass');
|
||||
$nutrec->set_prop('AdminPass', sprintf("%15.0f", int( (1000000000000000) * rand() ))) if not $nutrec->prop('AdminPass');
|
||||
|
||||
# if $nut{SlaveUPS} defined we set and the target not existing ClientUPS ; then delete SlaveUPS
|
||||
# set ClientUser as upsslave (was the content before sme11) intended for smooth migration
|
||||
# set ClientPass as $nut{SlavePass}/{SecondaryPass}
|
||||
if ( $nut{'SlaveUPS'} ) {
|
||||
$nutrec->set_prop('ClientUPS',$DB->get_prop_and_delete('nut','SlaveUPS') ) if not $nut{'ClientUPS'};
|
||||
$nutrec->set_prop('ClientUser','upsslave');
|
||||
$nutrec->set_prop('ClientPass',$nutrec->prop('SecondaryPass'));
|
||||
}
|
||||
|
||||
}
|
||||
|
18
root/etc/e-smith/events/actions/nut-config-drivers
Normal file
18
root/etc/e-smith/events/actions/nut-config-drivers
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
#if MODE = netserver then access should be private
|
||||
#if MODE = netclient only enable monitor
|
||||
|
||||
# calling this script to configure unit and drivers
|
||||
if [[ $(config getprop nut status || echo "disabled") == "disabled" ]] ; then
|
||||
# disable server
|
||||
# leave monitor as is, we might want to monitor an external ups ?
|
||||
# get_all_by_prop filter nut-driver@ and foreach $UPS disabled
|
||||
exit 0;
|
||||
fi
|
||||
# nut is enabled
|
||||
# enable nut-monitor
|
||||
# enable nut-server "enable nut-server.service\n" if ($master eq 'yes');
|
||||
# get_all_by_prop filter nut-driver@ and foreach $UPS enable.
|
||||
|
||||
/usr/libexec/nut-driver-enumerator.sh
|
@ -1 +0,0 @@
|
||||
MODEL=upsdrvctl
|
@ -1 +0,0 @@
|
||||
SERVER={ $nut{Master} || 'yes' }
|
@ -1,16 +1,26 @@
|
||||
# nut UPS specific subservices
|
||||
{
|
||||
$nutstatus = $nut{status} || 'disabled';
|
||||
$master = $nut{Master} || 'yes';
|
||||
$mode = $nut{Mode} || 'standalone';
|
||||
my @upses = grep(/^nut-driver\@[a-zA-Z0-9_-]+$/, $DB->keys);
|
||||
|
||||
if ($nutstatus eq 'enabled') {
|
||||
$OUT .= "enable nut-server.service\n" if ($master eq 'yes');
|
||||
$OUT .= "disable nut-server.service\n" unless ($master eq 'yes');
|
||||
$OUT .= "enable nut-monitor.service\n";
|
||||
$OUT .= "enable nut-server.service\n" if ($mode ne 'netclient');
|
||||
$OUT .= "disable nut-server.service\n" unless ($mode eq 'netclient');
|
||||
$OUT .= "enable nut-monitor.service\n";
|
||||
foreach my $ups ( sort {$a cmp $b} @upses )
|
||||
{
|
||||
$OUT .= "enable $ups.service\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$OUT .= "disable nut-server.service\n";
|
||||
$OUT .= "disable nut-monitor.service\n";
|
||||
foreach my $ups ( sort {$a cmp $b} @upses )
|
||||
{
|
||||
$OUT .= "disable $ups.service\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
7
root/etc/e-smith/templates/etc/ups/nut.conf/10MODE
Normal file
7
root/etc/e-smith/templates/etc/ups/nut.conf/10MODE
Normal file
@ -0,0 +1,7 @@
|
||||
# mode could be none|standalone|netserver|netclient
|
||||
MODE={
|
||||
return "none" unless ( ($nut{"status"}||"disabled") eq "enabled");
|
||||
# if Master no => netclient
|
||||
# if Master yes => standalone or netserver
|
||||
$nut{mode} || "standalone";
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
|
||||
# Uncomment this to allow starting the `upsd` data server even if `ups.conf`
|
||||
# has no device sections configured at the moment. This environment variable
|
||||
# overrides the built-in "false" flag in `upsd`, and an optional same-named
|
||||
# default flag that can be set in `upsd.conf`. If you want a data server always
|
||||
# running, even if it initially has nothing to serve (may be live-reloaded
|
||||
# later, when devices become configured), this option is for you.
|
||||
#ALLOW_NO_DEVICE=true
|
||||
#export ALLOW_NO_DEVICE
|
||||
|
@ -0,0 +1,11 @@
|
||||
|
||||
# Uncomment this to allow starting the `upsd` data server even if not all
|
||||
# `LISTEN` directives can be honoured at the moment. This environment variable
|
||||
# overrides the built-in "false" flag in `upsd`, and an optional same-named
|
||||
# default flag that can be set in `upsd.conf`. If you want a data server always
|
||||
# running, even if it would potentially not serve all clients on every uptime,
|
||||
# this option is for you (note you would have to restart `upsd` to pick up the
|
||||
# `LISTEN`ed IP address if it appears later). Probably `LISTEN *` is better.
|
||||
#ALLOW_NOT_ALL_LISTENERS=true
|
||||
#export ALLOW_NOT_ALL_LISTENERS
|
||||
|
@ -0,0 +1,6 @@
|
||||
|
||||
# The optional 'UPSD_OPTIONS' allow to set upsd specific command-line options.
|
||||
# It is ignored when 'MODE' above indicates that no upsd should be running.
|
||||
# It may be redundant in comparison to options which can be set in `upsd.conf`.
|
||||
#UPSD_OPTIONS=
|
||||
|
@ -0,0 +1,6 @@
|
||||
|
||||
# The optional 'UPSMON_OPTIONS' allow to set upsmon specific command-line options.
|
||||
# It is ignored when 'MODE' above indicates that no upsmon should be running.
|
||||
# It may be redundant in comparison to options which can be set in `upsmon.conf`.
|
||||
#UPSMON_OPTIONS=
|
||||
|
@ -0,0 +1,9 @@
|
||||
|
||||
# If the optional 'POWEROFF_WAIT' is configured (to a value that can be handled
|
||||
# by `/bin/sleep` on the current system - typically an integer with the number
|
||||
# of seconds for a delay, but not always limited to that syntax), and the current
|
||||
# system which manages one or more UPS devices would not only command it to shut
|
||||
# down, but also try to avoid the "Power race". Caveats emptor, see NUT FAQ and
|
||||
# other docs for details.
|
||||
#POWEROFF_WAIT=3600
|
||||
|
@ -0,0 +1,8 @@
|
||||
|
||||
# The optional 'POWEROFF_QUIET' setting controls if the NUT shutdown integration
|
||||
# scripts or service units would emit messages about their activity (or lack
|
||||
# thereof). By default they may be verbose, to aid post-mortem troubleshooting
|
||||
# via logs or console captures.
|
||||
# Set to `true` to avoid that trove of information, if you consider it noise.
|
||||
#POWEROFF_QUIET=true
|
||||
|
@ -1,16 +1,21 @@
|
||||
{
|
||||
my $model = $nut{Model} || "usbhid-ups";
|
||||
my $device = $nut{Device} || "/var/lib/ups/hiddev0";
|
||||
my $type = $nut{Type};
|
||||
my $mfr = $nut{mfr};
|
||||
my $mdl = $nut{mdl};
|
||||
$OUT .= "[UPS]\n";
|
||||
$OUT .= "\tdriver = $model\n";
|
||||
if ($model eq 'genericups')
|
||||
{
|
||||
$OUT .= "\tupstype = $type\n" if defined $type;
|
||||
$OUT .= "\tmfr = $mfr\n" if defined $mfr;
|
||||
$OUT .= "\tmodel = $mdl\n" if defined $mdl;
|
||||
my @upses = grep(/^nut-driver\@[a-zA-Z0-9_-]+$/, $DB->keys);
|
||||
foreach my $ups ( sort {$a cmp $b} @upses )
|
||||
{
|
||||
my $nnut = ${$ups};
|
||||
my $model = $nnut{Model} || "usbhid-ups";
|
||||
my $device = $nnut{Device} || "auto"; #"/var/lib/ups/hiddev0";
|
||||
my $type = $nnut{Type};
|
||||
my $mfr = $nnut{mfr};
|
||||
my $mdl = $nnut{mdl};
|
||||
$OUT .= "[UPS]\n";
|
||||
$OUT .= "\tdriver = $model\n";
|
||||
if ($model eq 'genericups')
|
||||
{
|
||||
$OUT .= "\tupstype = $type\n" if defined $type;
|
||||
$OUT .= "\tmfr = $mfr\n" if defined $mfr;
|
||||
$OUT .= "\tmodel = $mdl\n" if defined $mdl;
|
||||
}
|
||||
$OUT .= "\tport = $device\n";
|
||||
}
|
||||
$OUT .= "\tport = $device\n";
|
||||
}
|
||||
|
@ -1,8 +1,18 @@
|
||||
[upsprimary]
|
||||
password = { $nut{PrimaryPass} }
|
||||
upsmon primary
|
||||
|
||||
[upssecondary]
|
||||
password = { $nut{SecondaryPass} }
|
||||
upsmon secondary
|
||||
{
|
||||
# we keep those two for backward compatibility pre SME11
|
||||
}
|
||||
[upsmaster]
|
||||
password = { $nut{MasterPass} }
|
||||
upsmon master
|
||||
password = { $nut{PrimaryPass} }
|
||||
upsmon primary
|
||||
|
||||
[upsslave]
|
||||
password = { $nut{SlavePass} }
|
||||
upsmon slave
|
||||
password = { $nut{SecondaryPass} }
|
||||
upsmon secondary
|
||||
|
||||
|
@ -1,7 +1,14 @@
|
||||
{
|
||||
if ( ($nut{Master} || 'yes') ne 'no' ) {
|
||||
$OUT = "MONITOR UPS\@localhost 1 upsmaster $nut{MasterPass} master";
|
||||
} else {
|
||||
$OUT = "MONITOR $nut{SlaveUPS} 1 upsslave $nut{SlavePass} slave";
|
||||
}
|
||||
if ( ($nut{Mode} || 'standalone') eq 'netclient' ) {
|
||||
$OUT = "MONITOR $nut{ClientUPS} 1 $nut{ClientUser} $nut{ClientPass} secondary";
|
||||
} else {
|
||||
my @upses = grep(/^nut-driver\@[a-zA-Z0-9_-]+$/, $DB->keys);
|
||||
my $size = scalar(@upses);
|
||||
foreach my $ups ( sort {$a cmp $b} @upses )
|
||||
{
|
||||
my ($upsname) = $ups =~ /^nut-driver\@([a-zA-Z0-9_-]+)$/ ;
|
||||
$OUT .= "MONITOR $upsname\@localhost 1 upsprimary $nut{PrimaryPass} primary";
|
||||
$OUT .= "\n" if --$size >=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
#------------------------------------------------------------
|
||||
# !!DO NOT MODIFY THIS FILE!!
|
||||
#
|
||||
# Manual changes will be lost when this file is regenerated.
|
||||
#
|
||||
# Please read the developer's guide, which is available
|
||||
# at http://www.contribs.org/development/
|
||||
#
|
||||
# Copyright (C) 1999-2006 Mitel Networks Corporation
|
||||
#------------------------------------------------------------
|
||||
|
||||
[Service]
|
||||
ExecStartPre=
|
||||
ExecStartPre=-/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-run.conf
|
@ -0,0 +1,4 @@
|
||||
[Service]
|
||||
ExecStartPre=/sbin/e-smith/service-status %N
|
||||
[Install]
|
||||
WantedBy= sme-server.target
|
@ -0,0 +1,4 @@
|
||||
[Service]
|
||||
ExecStartPre=/sbin/e-smith/service-status nut-monitor
|
||||
[Install]
|
||||
WantedBy=sme-server.target
|
@ -0,0 +1,4 @@
|
||||
[Service]
|
||||
ExecStartPre=/sbin/e-smith/service-status nut-server
|
||||
[Install]
|
||||
WantedBy=sme-server.target
|
@ -48,9 +48,12 @@ my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
if (! TRUE) #validate $c->param('status')
|
||||
{$ret .= 'Validation for status failed';}
|
||||
if (! TRUE) #validate $c->param('Nutmode')
|
||||
{$ret .= 'Validation for Nutmode failed';}
|
||||
{$ret .= 'Validation for Nutmode failed';}
|
||||
#do we want the Slave validated ? we should just display read only
|
||||
if (! TRUE) #validate $c->param('SlaveUPS_Name')
|
||||
{$ret .= 'Validation for SlaveUPS_Name failed';}
|
||||
{$ret .= 'Validation for SlaveUPS_Name failed';}
|
||||
if (! TRUE) #validate $c->param('ClientUPS_Name')
|
||||
{$ret .= 'Validation for ClientUPS_Name failed';}
|
||||
if (! TRUE) #validate $c->param('MasterUPS_Name')
|
||||
{$ret .= 'Validation for MasterUPS_Name failed';}
|
||||
if (! TRUE) #validate $c->param('UPS_Model')
|
||||
@ -88,13 +91,19 @@ my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my %ret = (
|
||||
'Data1'=>'Data for CONFIG', #Example
|
||||
'localip'=>$cdb->get_value('LocalIP'),
|
||||
# fields from Inputs in CONFIG $fields['CONFIG']
|
||||
'status'=>$cdb->get_prop('nut', 'status', 'disabled'),
|
||||
'Nutmode'=>$cdb->get_prop('nut', 'mode', 'standalone'),
|
||||
'SlaveUPS_Name'=>$cdb->get_prop('nut', 'SlaveUPS', 'ups@IPaddress'),
|
||||
'MasterUPS_Name'=>$cdb->get_prop('nut', 'MasterUPS', 'ups@localhost'),
|
||||
'UPS_Model'=>$cdb->get_prop('nut', 'Model', 'usbhid-ups'),
|
||||
'UPS_Device'=>$cdb->get_prop('nut', 'Device', 'auto'),
|
||||
#'SlaveUPS_Name'=>$cdb->get_prop('nut', 'SlaveUPS'),
|
||||
'ClientUPS_Name'=>$cdb->get_prop('nut', 'ClientUPS'),
|
||||
'ClientUPS_User'=>$cdb->get_prop('nut', 'ClientUser'),
|
||||
'ClientUPS_Pass'=>$cdb->get_prop('nut', 'ClientPass'),
|
||||
'SlaveUPS_Pass'=>$cdb->get_prop('nut', 'SlavePass'),
|
||||
'MasterUPS_Name'=>$cdb->get_prop('nut', 'MasterUPS'),
|
||||
# TODO migrate to nut-driver@ups entry
|
||||
'UPS_Model'=>$cdb->get_prop('nut', 'Model') || 'usbhid-ups',
|
||||
'UPS_Device'=>$cdb->get_prop('nut', 'Device')|| 'auto',
|
||||
'UPS_gen_Type'=>$cdb->get_prop('nut', 'Type', ''),
|
||||
'UPS_gen_Mfr'=>$cdb->get_prop('nut', 'mfr', ''),
|
||||
'UPS_gen_Model'=>$cdb->get_prop('nut', 'mdl', ''),
|
||||
@ -137,7 +146,7 @@ my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my $dbkey = 'ChangeThis';
|
||||
# To make it write to DB as comment, delete this (regex) string in each if statement "TRUE\) \#copy or perform with value: .* e.g."
|
||||
|
||||
if (! TRUE) #copy or perform with value: UPSStatus e.g. $db->set_prop($dbkey,'UPSStatus',$c->param('UPSStatus'),type=>'service'))
|
||||
if (! TRUE) #copy or perform with value: UPSStatus e.g. $db->set_prop($dbkey,'UPSStatus',$c->param('UPSStatus')))
|
||||
{$ret .= 'Perform/save failed for UPSStatus';}
|
||||
if ($ret eq "") {$ret = 'ok';}
|
||||
return $ret;
|
||||
@ -150,42 +159,61 @@ my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
|
||||
my $db = $cdb; #maybe one of the others
|
||||
my $dbkey = 'nut';
|
||||
my $driverkey = 'nut-driver@UPS';
|
||||
# To make it write to DB as comment, delete this (regex) string in each if statement "TRUE\) \#copy or perform with value: .* e.g."
|
||||
|
||||
if (!$db->set_prop($dbkey,'status',$c->param('status'),type=>'service'))
|
||||
if (!$db->set_prop($dbkey,'status',$c->param('status')))
|
||||
{$ret .= 'Perform/save failed for status';}
|
||||
if (!$db->set_prop($dbkey,'mode',$c->param('Nutmode'),type=>'service'))
|
||||
if (!$db->set_prop($dbkey,'mode',$c->param('Nutmode')))
|
||||
{$ret .= 'Perform/save failed for Nutmode';}
|
||||
if (! $db->set_prop($dbkey,'SlaveUPS',$c->param('SlaveUPS_Name'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for SlaveUPS_Name';}
|
||||
if (! $db->set_prop($dbkey,'MasterUPS',$c->param('MasterUPS_Name'),type=>'service'))
|
||||
# let only save info regarding the current mode
|
||||
|
||||
# if client mode
|
||||
if (! $db->set_prop($dbkey,'ClientUPS',$c->param('ClientUPS_Name')))
|
||||
{$ret .= 'Perform/save failed for ClientUPS_Name';}
|
||||
if (! $db->set_prop($dbkey,'MasterUPS',$c->param('MasterUPS_Name')))
|
||||
{$ret .= 'Perform/save failed for MasterUPS_Name';}
|
||||
if (! $db->set_prop($dbkey,'SlavePass',$c->param('SlaveUPS_Pass'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for SlaveUPS_Pass';}
|
||||
if (! $db->set_prop($dbkey,'MasterPass',$c->param('MasterUPS_Pass'),type=>'service'))
|
||||
{$ret .= 'Perform/save failed for MasterUPS_Pass';}
|
||||
if (! $db->set_prop($dbkey,'Model',$c->param('UPS_Model'),type=>'service'))
|
||||
if (! $db->set_prop($dbkey,'ClientUser',$c->param('ClientUPS_User')))
|
||||
{$ret .= 'Perform/save failed for ClientUPS_USer';}
|
||||
if (! $db->set_prop($dbkey,'ClientPass',$c->param('ClientUPS_Pass')))
|
||||
{$ret .= 'Perform/save failed for ClientUPS_Pass';}
|
||||
|
||||
# if not client mode
|
||||
if (! $db->set_prop($dbkey,'Model',$c->param('UPS_Model')))
|
||||
{$ret .= 'Perform/save failed for UPS_Model';}
|
||||
if (! $db->set_prop($dbkey,'Device',$c->param('UPS_Device'),type=>'service'))
|
||||
if (! $db->set_prop($dbkey,'Device',$c->param('UPS_Device')))
|
||||
{$ret .= 'Perform/save failed for UPS_Device';}
|
||||
if (! $db->set_prop($dbkey,'Type',$c->param('UPS_gen_Type'),type=>'service'))
|
||||
if (! $db->set_prop($dbkey,'Type',$c->param('UPS_gen_Type')))
|
||||
{$ret .= 'Perform/save failed for UPS_gen_Type';}
|
||||
if (! $db->set_prop($dbkey,'mfr',$c->param('UPS_gen_Mfr'),type=>'service'))
|
||||
if (! $db->set_prop($dbkey,'mfr',$c->param('UPS_gen_Mfr')))
|
||||
{$ret .= 'Perform/save failed for UPS_gen_Mfr';}
|
||||
if (! $db->set_prop($dbkey,'mdl',$c->param('UPS_gen_Model'),type=>'service'))
|
||||
if (! $db->set_prop($dbkey,'mdl',$c->param('UPS_gen_Model')))
|
||||
{$ret .= 'Perform/save failed for UPS_gen_Model';}
|
||||
|
||||
#changes from sme10 to sme11
|
||||
# slave/master is changed to secondary/primary (upstream) should bite the bullet rather sooner than latter
|
||||
# we move most properties from nut to nut-driver@UPS, nut-driver@UPS1 (we only handle nut-driver@UPS in panel)
|
||||
# we remove Master property (redundant)
|
||||
# we add mode property, we have 3 modes :
|
||||
# standalone uses primary pass
|
||||
# nethserver uses primary pass
|
||||
# netclient uses secondary pass
|
||||
|
||||
|
||||
#TODO check if still needed :
|
||||
|
||||
if ($ret eq "") {
|
||||
$ret = 'ok';
|
||||
#and set Master and access properties according to values
|
||||
if ($db->get_prop($dbkey,"mode",'standalone') eq 'netclient'){
|
||||
$db->set_prop($dbkey,'Master','no',type=>'service');
|
||||
$db->set_prop($dbkey,'Master','no');
|
||||
} else {
|
||||
$db->set_prop($dbkey,'Master','yes',type=>'service');
|
||||
$db->set_prop($dbkey,'Master','yes');
|
||||
}
|
||||
if ($db->get_prop($dbkey,"mode",'standalone') eq 'netserver'){
|
||||
$db->set_prop($dbkey,'access','private',type=>'service');
|
||||
$db->set_prop($dbkey,'access','private');
|
||||
} else {
|
||||
$db->set_prop($dbkey,'access','localhost',type=>'service');
|
||||
$db->set_prop($dbkey,'access','localhost');
|
||||
}
|
||||
#And run signal-event to apply templates for config files and start task.
|
||||
my @result = qx{/usr/sbin/e-smith/signal-event smeserver-nutUPS-update};
|
||||
@ -230,12 +258,10 @@ sub get_ups_status {
|
||||
my $nutmode = $cdb->get_prop('nut', 'mode','standalone');
|
||||
if ($cdb->get_prop('nut', 'status', 'disabled') eq 'disabled'){
|
||||
return $c->l('nut_status_is_disabled')
|
||||
} elsif ($nutmode eq 'standalone'){
|
||||
return $c->get_status_from_device($cdb->get_prop('nut','MasterUPS','ups@localhost'));
|
||||
} elsif ($nutmode eq 'netserver'){
|
||||
return $c->get_status_from_device($cdb->get_prop('nut','MasterUPS','ups@localhost'));
|
||||
} elsif ($nutmode eq 'netclient'){
|
||||
return $c->get_status_from_device($cdb->get_prop('nut','ClientUPS'));
|
||||
} else {
|
||||
return $c->get_status_from_device($cdb->get_prop('nut','SlaveUPS','apc@192.168.1.99'));
|
||||
return $c->get_status_from_device($cdb->get_prop('nut','MasterUPS'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,4 +294,4 @@ sub get_status_from_device {
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
1;
|
||||
|
@ -2,6 +2,7 @@ $(document).ready(function() {
|
||||
function toggleUPSClasses() {
|
||||
var selectedOption = $('#Nutmode_select').val();
|
||||
$('.masterups').toggle(selectedOption === 'netserver' || selectedOption === 'standalone'); // Show/Hide masterups based on Net Server or Standalone
|
||||
$('.secondaryups').toggle(selectedOption === 'netserver' ); // Show/Hide Secondary logins for net server
|
||||
$('.slaveups').toggle(selectedOption === 'netclient'); // Show/Hide slaveups based on Net Client
|
||||
|
||||
// Enable/Disable inputs based on the selected option
|
||||
@ -25,4 +26,4 @@ $(document).ready(function() {
|
||||
// Set the initial state based on current selections
|
||||
toggleGenerics();
|
||||
toggleUPSClasses();
|
||||
});
|
||||
});
|
||||
|
@ -13,7 +13,7 @@
|
||||
</pre>
|
||||
% }
|
||||
% my $btn = l('nut_APPLY');
|
||||
%= form_for "nutupsu" => (method => 'POST') => begin
|
||||
%= form_for "nutupsu" => (method => 'POST') => (autocomplete => "off" ) => begin
|
||||
% param 'trt' => $nut_data->{trt} unless param 'trt';
|
||||
%= hidden_field 'trt' => $nut_data->{trt}
|
||||
%# Inputs etc in here.
|
||||
@ -40,20 +40,28 @@
|
||||
|
||||
<div class=masterups>
|
||||
<h2 class='subh3'><%=l('nut_if_Net_Server')%></h2>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('nut_MasterUPS_UPSNAME@IP')
|
||||
</span><span class=data>
|
||||
% param 'MasterUPS_Name' => $nut_data->{MasterUPS_Name} unless param 'MasterUPS_Name';
|
||||
%= text_field 'MasterUPS_Name', size => '50', class => 'textinput MasterUPS_Name' , pattern=>'.*' , placeholder=>'ups@localhost'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('nut_MasterUPS_Password')
|
||||
</span><span class=data>
|
||||
% param 'MasterUPS_Password' => $nut_data->{MasterUPS_Password} unless param 'MasterUPS_Password';
|
||||
%=password_field 'MasterUPS_Password', class => 'pass6 sme-password'
|
||||
</span></p>
|
||||
|
||||
<div class=secondaryups>
|
||||
<p><span class=label>
|
||||
%=l('nut_MasterUPS_UPSNAME@IP')
|
||||
</span><span class=data>
|
||||
% param 'MasterUPS_Name' => $nut_data->{MasterUPS_Name} unless param 'MasterUPS_Name';
|
||||
%= 'ups@'. $nut_data->{'localip'}
|
||||
<br></span></p>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('nut_SlaveUPS_User')
|
||||
</span><span class=data>
|
||||
%= 'upssecondary'
|
||||
</span></p>
|
||||
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('nut_SlaveUPS_Password')
|
||||
</span><span class=data>
|
||||
<%= $nut_data->{'SlaveUPS_Pass'}%>
|
||||
</span></p>
|
||||
</div>
|
||||
|
||||
<p><span class=label>
|
||||
%=l('nut_UPS_Model')
|
||||
@ -77,14 +85,21 @@
|
||||
%=l('nut_SlaveUPS_UPSNAME@IP')
|
||||
</span><span class=data>
|
||||
% param 'SlaveUPS_Name' => $nut_data->{SlaveUPS_Name} unless param 'SlaveUPS_Name';
|
||||
%= text_field 'SlaveUPS_Name', size => '50', class => 'textinput SlaveUPS_Name' , pattern=>'.*' , placeholder=>'upsname@IP'
|
||||
%= text_field 'SlaveUPS_Name', size => '50', class => 'textinput SlaveUPS_Name' , pattern=>'.*' , placeholder=>'upsname@IP[:port]'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('nut_ClientUPS_Username')
|
||||
</span><span class=data>
|
||||
% param 'ClientUPS_User' => $nut_data->{ClientUPS_User} unless param 'ClientUPS_User';
|
||||
%=text_field 'ClientUPS_User', class => 'textinput'
|
||||
</span></p>
|
||||
|
||||
<p><span class='label'>
|
||||
%=l('nut_SlaveUPS_Password')
|
||||
%=l('nut_ClientUPS_Password')
|
||||
</span><span class=data>
|
||||
% param 'SlaveUPS_Password' => $nut_data->{SlaveUPS_Password} unless param 'SlaveUPS_Password';
|
||||
%=password_field 'SlaveUPS_Password', class => 'pass4 sme-password'
|
||||
% param 'ClientUPS_Pass' => $nut_data->{ClientUPS_Pass} unless param 'ClientUPS_Pass';
|
||||
%=password_field 'ClientUPS_Pass', class => 'pass4 sme-password', autocomplete => 'off'
|
||||
</span></p>
|
||||
</div>
|
||||
|
||||
@ -121,4 +136,4 @@
|
||||
|
||||
%# Probably finally by a submit.
|
||||
%end
|
||||
</div>
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@ Summary: SME server - nut UPS interaction module
|
||||
%define name smeserver-nutUPS
|
||||
Name: %{name}
|
||||
%define version 11.0.0
|
||||
%define release 8
|
||||
%define release 9
|
||||
Version: %{version}
|
||||
Release: %{release}%{?dist}
|
||||
License: GPL
|
||||
@ -12,7 +12,8 @@ Group: Networking/Daemons
|
||||
Source: %{name}-%{version}.tar.xz
|
||||
|
||||
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot
|
||||
Requires: nut nut-client
|
||||
Requires: nut >= 2.8.2
|
||||
Requires: nut-client
|
||||
Obsoletes: neon <= 0.25.5
|
||||
Requires: smeserver-lib >= 1.15.1-16
|
||||
BuildArchitectures: noarch
|
||||
@ -25,6 +26,13 @@ A module which configures the Network UPS Tools suite for operation with
|
||||
the SME server software.
|
||||
|
||||
%changelog
|
||||
* Tue Mar 18 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-9.sme
|
||||
- update config for Nut 2.8.2 [SME: 12657]
|
||||
TODO review master/slave mode
|
||||
TODO convert master/slave to primary/secondary
|
||||
TODO convert to new config data + migrate
|
||||
TODO event and action
|
||||
|
||||
* Wed Mar 05 2025 Brian Read <brianr@koozali.org> 11.0.0-8.sme
|
||||
- typo in lex file [SME: 12949]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user