11 Commits

Author SHA1 Message Date
John Crisp
848f2bbfc0 Remove errant backticks 2025-07-07 17:12:20 +02:00
1962b616ec * Mon Jul 07 2025 Brian Read <brianr@koozali.org> 11.0.0-19.sme
- Changes from JC (thanks) and also make sure descriptions fit in with Master->Primary and Slave->Secondary [SME: 13069]
  Also write descriptive paragraph as no-one else has!
  Also also, incorporate newly auditted lex file
2025-07-07 09:21:35 +01:00
7e4ab54b55 * Fri Jun 13 2025 Brian Read <brianr@koozali.org> 11.0.0-18.sme
- Adjust call from Custom to be emtpy hash not hashref [SME: 13042]
2025-06-13 15:51:19 +01:00
32cfcf5ed3 * Fri Jun 13 2025 Brian Read <brianr@koozali.org> 11.0.0-17.sme
- Fix return from function in Nutups-custom [SME: 13042]
- Check Seconds left for zero before dividing by 60
2025-06-13 11:46:19 +01:00
f58cc8a22f * Fri Jun 13 2025 Brian Read <brianr@koozali.org> 11.0.0-16.sme
- Change Navigation weighting for SM2 [SME: 12996]
2025-06-13 05:51:55 +01:00
e13529e660 * Wed Jun 11 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-15.sme
- open db flat file using UTF8 [SME: 13035]
2025-06-11 13:48:23 -04:00
abb67327c6 * Mon Jun 02 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-14.sme
- fix typo preventing netserver enabling [SME: 13021]
2025-06-02 22:37:42 -04:00
2465aaab22 * Wed May 28 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-13.sme
- filter out nut* services from syslog (use journalctl) [SME: 13013]
2025-05-28 00:28:41 -04:00
8bdde34a82 * Wed May 28 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-12.sme
- fix [SME: ]
2025-05-28 00:24:11 -04:00
830b29b569 * Sat May 24 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-11.sme
- fix issue with standalone and netserver mode [SME: 13012]
2025-05-24 16:09:49 -04:00
e235701fe2 * Sun May 18 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-10.sme
- add pollinterval setting [SME: 13006]
- update config for Nut 2.8.2 [SME: 12657]
2025-05-18 01:01:00 -04:00
13 changed files with 248 additions and 228 deletions

View File

@@ -15,11 +15,11 @@ foreach (qw(bootstrap-console-save console-save smeserver-nutUPS-update nut-conf
templates2events("/etc/ups/upsd.conf", $_);
}
event_link("nut-config", "post-upgrade" , "4");
event_link("nut-config", "post-upgrade" , "04");
event_link("nut-config-drivers", "post-upgrade", "50");
my $event= "nut-conf";
event_link("nut-config", $event, "4");
event_link("nut-config", $event, "04");
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\@ups");
@@ -34,6 +34,7 @@ safe_symlink("try-restart", "root/etc/e-smith/events/$event/services2adjust/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("nut-config", $event, "4");
templates2events("/etc/rsyslog.conf", $event);
event_link("nut-config", $event, "04");
event_link("nut-config-drivers", $event, "50");
event_link("systemd-default", $event, "88");

View File

@@ -23,7 +23,7 @@ fi
# nut is enabled
# we set services depending on Mode
Mode=$(/sbin/e-smith/config getprop nut Mode || echo "standelone")
Mode=$(/sbin/e-smith/config getprop nut Mode || echo "standalone")
if [[ $Mode == "netserver" ]] ; then
/sbin/e-smith/config setprop nut-server status enabled
/sbin/e-smith/config setprop nut access private

View File

@@ -0,0 +1,5 @@
#nut / UPS we only use journalctl
:programname, isequal, "nut-monitor" stop
:programname, isequal, "nut-server" stop
:programname, startswith, "nut-driver" stop

View File

@@ -3,5 +3,5 @@ MODE={
return "none" unless ( ($nut{"status"}||"disabled") eq "enabled");
# if Master no => netclient
# if Master yes => standalone or netserver
$nut{mode} || "standalone";
$nut{Mode} || "standalone";
}

View File

@@ -1,16 +1,20 @@
{
my $poll = $nut{pollInterval} || '2';
if ($poll ne '2') {
$OUT .= "pollinterval = $poll\n";
}
my @upses = grep(/^nut-driver\@[a-zA-Z0-9_-]+$/, $DB->keys);
foreach my $ups ( sort {$a cmp $b} @upses )
{
my $nnut = ${$ups};
my $status = $nnut{status} || "disabled";
my $status = ${"$ups"}{status} || "disabled";
next if $status eq "disabled";
my ($name )= $ups =~ /^nut-driver\@(.*)$/ ;
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};
my $model = ${"$ups"}{Model} || "usbhid-ups";
my $device = ${"$ups"}{Device} || "auto"; #"/var/lib/ups/hiddev0";
my $type = ${"$ups"}{Type};
my $mfr = ${"$ups"}{mfr};
my $mdl = ${"$ups"}{mdl};
$OUT .= "[$name]\n";
$OUT .= "\tdriver = $model\n";
if ($model eq 'genericups')

View File

@@ -7,22 +7,12 @@
#
use esmith::util;
use esmith::util::network;
use esmith::ConfigDB;
use esmith::HostsDB;
use esmith::AccountsDB;
use esmith::NetworksDB;
use esmith::DomainsDB;
use esmith::ConfigDB::UTF8;
use constant FALSE => 0;
use constant TRUE => 1;
#The most common ones
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
#our $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
#our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
#our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
#our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
our $cdb;
# Validation routines - parameters for each panel
@@ -76,7 +66,7 @@ my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
sub get_data_for_panel_STATUS {
# Return a hash with the fields required which will be loaded into the shared data
my $c = shift;
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
$cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my %ret = (
#'Data1'=>'Data for STATUS', #Example
# fields from Inputs in STATUS $fields['STATUS']
@@ -92,7 +82,7 @@ my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
sub get_data_for_panel_CONFIG {
# Return a hash with the fields required which will be loaded into the shared data
my $c = shift;
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
$cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my %ret = (
'Data1'=>'Data for CONFIG', #Example
'localip'=>$cdb->get_value('LocalIP'),
@@ -126,16 +116,16 @@ my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my $c = shift;
my $selected = shift; #Parameter is name of selected row.
my $is_new_record = shift; #Indicates new record required (defaults)
my %ret = {};
return $ret;
my %ret = ();
return %ret;
}
sub get_selected_CONFIG {
my $c = shift;
my $selected = shift; #Parameter is name of selected row.
my $is_new_record = shift; #Indicates new record required (defaults)
my %ret = {};
return $ret;
my %ret = ();
return %ret;
}
@@ -159,7 +149,7 @@ my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my $c = shift;
my $prefix_data = shift; #Data hash as parameter
my $ret = "";
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
$cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my $db = $cdb; #maybe one of the others
my $dbkey = 'nut';
my $driverkey = 'nut-driver@ups';
@@ -246,14 +236,17 @@ sub get_model_options {
sub get_ups_status {
my $c = shift;
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
$cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
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 'netclient'){
return $c->get_status_from_device($cdb->get_prop('nut','ClientUPS'));
} else {
return $c->get_status_from_device($cdb->get_prop('nut','MasterUPS'));
# TODO: could enumerate all the upses using
# my @upses = grep(/^nut-driver\@[a-zA-Z0-9_-]+$/, $DB->keys);
# we will only use the default first one for the moment nut-driver@ups for ups named "ups"
return $c->get_status_from_device("ups");
}
}
@@ -286,4 +279,4 @@ sub get_status_from_device {
}
1;
1;

View File

@@ -5,7 +5,7 @@ package SrvMngr::Controller::Nutups;
#----------------------------------------------------------------------
# heading : System
# description : NutUPS configuration
# navigation : 4000 700
# navigation : 4000 900
#
# name : nutups, method : get, url : /nutups, ctlact : Nutups#main
# name : nutupsu, method : post, url : /nutupsu, ctlact : Nutups#do_update
@@ -36,11 +36,7 @@ use Data::Dumper;
use esmith::util;
use esmith::util::network;
use esmith::ConfigDB;
use esmith::AccountsDB;
use esmith::NetworksDB;
use esmith::HostsDB;
use esmith::DomainsDB;
use esmith::ConfigDB::UTF8;
@@ -60,14 +56,7 @@ sub main {
my $c = shift;
$c->app->log->info( $c->log_req );
#The most common ones
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my $cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my %nut_data = ();
my $title = $c->l('nut_NutUPS_configuration');
my $modul = '';
@@ -111,15 +100,8 @@ sub do_update {
my $c = shift;
$c->app->log->info($c->log_req);
my $modul = '';
#The most common ones - you might want to comment out any not used.
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my $modul = '';
my $cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my %nut_data = ();
my $title = $c->l('nut_NutUPS_configuration');
@@ -220,14 +202,7 @@ sub do_display {
my ($c,$trt) = @_;
$c->app->log->info($c->log_req);
#The most common ones - you might want to comment out any not used.
my $cdb = esmith::ConfigDB->open() || die("Couldn't open config db");
my $adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db");
my $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
my $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
my $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my $cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
my %nut_data = ();
my $title = $c->l('nut_NutUPS_configuration');
my $modul = "";
@@ -309,4 +284,4 @@ sub do_display {
);
$c->render(template => "nutups");
}
1;
1;

View File

@@ -1,30 +1,29 @@
#
# Generated by SM2Gen version: SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-01-20 16:21:33
#
'nut_UPS_Generic_Model' => 'UPS Generic Model',
'nut_UPS_Model' => 'UPS Model',
'nut_Manage_Nutups-config_settings:' => 'Manage Nutups-config settings',
'nut_Descriptive_paragraph' => 'Descriptive paragraph',
'nut_MasterUPS_UPSNAME@IP' => 'UPS name@localhost',
'nut_SlaveUPS_UPSNAME@IP' => 'Slave->Master UPSNAME@IP',
'nut_MasterUPS_Password' => 'Local server password',
'nut_SlaveUPS_Password' => 'Slaves Password ->Server',
'nut_Nut_status' => 'Nut status',
'nut_Configure_NutUPS' => 'Configure NutUPS',
'nut_APPLY' => 'Apply',
'nut_ClientUPS_Password' => 'Client UPS password',
'nut_ClientUPS_Username' => 'Client UPS username',
'nut_CONFIG_panel_action_was_successful' => 'CONFIG panel action was successful',
'nut_UPS_Generic_Type' => 'UPS Generic Type',
'nut_Status_(from_upsc)' => 'Status (from running upsc)',
'nut_Configure_NutUPS' => 'Configure NutUPS',
'nut_Descriptive_paragraph' => 'You can use your UPS connected directly to your server in a standalone mode or you can act as a Primary whereby other servers can also react to the status of your connected UPS, or you can connect to another server as a Secondary and react to the status of the UPS connected to that server.',
'nut_Error_Status_Report' => 'Error Status Report',
'nut_if_Net_Server' => 'Net Server details',
'nut_if_genericups' => 'Generic UPS details',
'nut_if_Net_Client' => 'Net Client details',
'nut_STATUS_panel_action_was_successful' => 'STATUS panel action was successful',
'nut_if_Net_Server' => 'Net Server details',
'nut_Manage_Nutups-config_settings:' => 'Manage Nutups configuration settings',
'nut_MasterUPS_Password' => 'Local server password',
'nut_MasterUPS_UPSNAME@IP' => 'UPS name@localhost',
'nut_Nut_mode' => 'Nut mode',
'nut_Status_Report' => 'Status Report',
'nut_Nut_status' => 'Nut status',
'nut_NutUPS_configuration' => 'NutUPS configuration',
'nut_APPLY' => 'Apply',
'nut_Save' => 'Save',
'nut_SlaveUPS_Password' => 'Secondary->Primary ->Server',
'nut_SlaveUPS_UPSNAME@IP' => 'Secondary->Primary UPSNAME@IP',
'nut_SlaveUPS_User' => 'Secondary UPS user',
'nut_Status_(from_upsc)' => 'Status (from running upsc)',
'nut_Status_of_the_controlled_UPS' => 'Status of the controlled UPS',
'nut_STATUS_panel_action_was_successful' => 'STATUS panel action was successful',
'nut_Status_Report' => 'Status Report',
'nut_UPS_Device' => 'UPS Device',
'nut_UPS_Generic_Manufacturer' => 'UPS Generic Manufacturer',
'nut_Status_of_the_controlled_UPS' => 'Status of the controlled UPS',
'nut_Save' => 'Save',
'nut_status_is_disabled' => 'Nut disabled',
'nut_UPS_Generic_Model' => 'UPS Generic Model',
'nut_UPS_Generic_Type' => 'UPS Generic Type',
'nut_UPS_Model' => 'UPS Model',

View File

@@ -1,13 +1,16 @@
$(document).ready(function() {
function toggleUPSClasses() {
var selectedOption = $('#Nutmode_select').val();
var upsModelValue = $('#UPS_Model_select').val().toLowerCase(); // Get the current value from UPS_Model
$('.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
$('.generics').toggle(selectedOption !== 'netclient' && upsModelValue === 'genericups' );
// Enable/Disable inputs based on the selected option
$('.masterups input').prop('disabled', !(selectedOption === 'netserver' || selectedOption === 'standalone'));
$('.slaveups input').prop('disabled', selectedOption !== 'netclient');
$('.generics input').prop('disabled', selectedOption === 'netclient');
}
function toggleGenerics() {

View File

@@ -1,139 +1,136 @@
%#
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-01-20 16:21:33
%# Generated by SM2Gen version:0.9(20Jan2025) Chameleon version:4.5.4 On Python:3.12.3 at 2025-01-20 16:21:33
%#
<div id="Nutups-CONFIG" class="partial Nutups-CONFIG">
<script>
window.onload = function() {
SelectInput();
};
</script>
% if (config->{debug} == 1) {
<pre>
%= dumper $nut_data
</pre>
% }
% my $btn = l('nut_APPLY');
%= 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.
<script>
window.onload = function() {
SelectInput();
};
</script>
% if (config->{debug} == 1) {
<pre>
%= dumper $nut_data
</pre>
% }
% my $btn = l('nut_APPLY');
%= 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.
<h2 class='subh2'><%=l('nut_Manage_Nutups-config_settings:')%></h2>
<p><span class=label>
%=l('nut_Nut_status')
</span><span class=data>
%# my @status_options = [['Disabled' => 'disabled'], ['Enabled' => 'enabled']];
%# param 'status' => $nut_data->{status} unless param 'status';
<h2 class='subh2'><%=l('nut_Manage_Nutups-config_settings:')%></h2>
% my @status_options = selected_field([['Disabled' => 'disabled'], ['Enabled' => 'enabled']], $nut_data->{status});
%= select_field 'status' => @status_options, class => 'input', id => 'status_select'
<br></span> </p>
<p><span class=label>
%=l('nut_Nut_mode')
</span><span class=data>
% my @Nutmode_options = [['Standalone' => 'standalone'], ['Net Server' => 'netserver'], ['Net Client ' => 'netclient']];
% param 'Nutmode' => $nut_data->{Nutmode} unless param 'Nutmode';
%= select_field 'Nutmode' => @Nutmode_options, class => 'input', id => 'Nutmode_select'
<br></span> </p>
<div class=masterups>
<h2 class='subh3'><%=l('nut_if_Net_Server')%></h2>
<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_Nut_status')
</span><span class=data>
%# my @status_options = [['Disabled' => 'disabled'], ['Enabled' => 'enabled']];
%# param 'status' => $nut_data->{status} unless param 'status';
<p><span class='label'>
%=l('nut_SlaveUPS_User')
</span><span class=data>
%= 'upssecondary'
</span></p>
% my @status_options = selected_field([['Disabled' => 'disabled'], ['Enabled' => 'enabled']], $nut_data->{status});
%= select_field 'status' => @status_options, class => 'input', id => 'status_select'
<br></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')
</span><span class=data>
% my @UPS_Model_options = $c->get_model_options();
% param 'UPS_Model' => $nut_data->{UPS_Model} unless param 'UPS_Model';
%= select_field 'UPS_Model' => \@UPS_Model_options, class => 'input', id => 'UPS_Model_select'
<br></span> </p>
<p><span class=label>
%=l('nut_UPS_Device')
</span><span class=data>
% param 'UPS_Device' => $nut_data->{UPS_Device} unless param 'UPS_Device';
%= text_field 'UPS_Device', size => '50', class => 'textinput UPS_Device' , pattern=>'.*' , placeholder=>'auto (for usb)'
<br></span></p>
</div>
<div class=slaveups>
<h2 class='subh4'><%=l('nut_if_Net_Client')%></h2>
<p><span class=label>
%=l('nut_SlaveUPS_UPSNAME@IP')
</span><span class=data>
% param 'ClientUPS_Name' => $nut_data->{ClientUPS_Name} unless param 'ClientUPS_Name';
%= text_field 'ClientUPS_Name', size => '50', class => 'textinput ClientUPS_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_Nut_mode')
</span><span class=data>
% my @Nutmode_options = [['Standalone' => 'standalone'], ['Net Server' => 'netserver'], ['Net Client ' => 'netclient']];
% param 'Nutmode' => $nut_data->{Nutmode} unless param 'Nutmode';
%= select_field 'Nutmode' => @Nutmode_options, class => 'input', id => 'Nutmode_select'
<br></span> </p>
<p><span class='label'>
%=l('nut_ClientUPS_Password')
</span><span class=data>
% param 'ClientUPS_Pass' => $nut_data->{ClientUPS_Pass} unless param 'ClientUPS_Pass';
%=password_field 'ClientUPS_Pass', class => 'pass4 sme-password', autocomplete => 'off'
</span></p>
</div>
<div class=generics>
` <h2 class='subh5'><%=l('nut_if_genericups')%></h2>
<p><span class=label>
%=l('nut_UPS_Generic_Type')
</span><span class=data>
% param 'UPS_gen_Type' => $nut_data->{UPS_gen_Type} unless param 'UPS_gen_Type';
%= text_field 'UPS_gen_Type', size => '50', class => 'textinput UPS_gen_Type' , pattern=>'.*' , placeholder=>'UPS_gen_Type'
<br></span></p>
<p><span class=label>
%=l('nut_UPS_Generic_Manufacturer')
</span><span class=data>
% param 'UPS_gen_Mfr' => $nut_data->{UPS_gen_Mfr} unless param 'UPS_gen_Mfr';
%= text_field 'UPS_gen_Mfr', size => '50', class => 'textinput UPS_gen_Mfr' , pattern=>'.*' , placeholder=>'UPS_gen_Mfr'
<br></span></p>
<p><span class=label>
%=l('nut_UPS_Generic_Model')
</span><span class=data>
% param 'UPS_gen_Model' => $nut_data->{UPS_gen_Model} unless param 'UPS_gen_Model';
%= text_field 'UPS_gen_Model', size => '50', class => 'textinput UPS_gen_Model' , pattern=>'.*' , placeholder=>'UPS_gen_Model'
<br></span></p>
` </div>
<span class='data'>
%= submit_button l('nut_Save'), class => 'action subm12'
</span>
<div class=masterups>
<div class=secondaryups>
<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';
%= 'ups@'. $nut_data->{'localip'}
<br></span></p>
%# Probably finally by a submit.
%end
</div>
<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>
<div>
<h2><%= l ('nut_UPS_Device') %></h2>
<p><span class=label>
%=l('nut_UPS_Model')
</span><span class=data>
% my @UPS_Model_options = $c->get_model_options();
% param 'UPS_Model' => $nut_data->{UPS_Model} unless param 'UPS_Model';
%= select_field 'UPS_Model' => \@UPS_Model_options, class => 'input', id => 'UPS_Model_select'
<br></span> </p>
<p><span class=label>
%=l('nut_UPS_Device')
</span><span class=data>
% param 'UPS_Device' => $nut_data->{UPS_Device} unless param 'UPS_Device';
%= text_field 'UPS_Device', size => '50', class => 'textinput UPS_Device' , pattern=>'.*' , placeholder=>'auto (for usb)'
<br></span></p>
</div>
</div>
<div class=slaveups>
<h2 class='subh4'><%=l('nut_if_Net_Client')%></h2>
<p><span class=label>
%=l('nut_SlaveUPS_UPSNAME@IP')
</span><span class=data>
% param 'ClientUPS_Name' => $nut_data->{ClientUPS_Name} unless param 'ClientUPS_Name';
%= text_field 'ClientUPS_Name', size => '50', class => 'textinput ClientUPS_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_ClientUPS_Password')
</span><span class=data>
% param 'ClientUPS_Pass' => $nut_data->{ClientUPS_Pass} unless param 'ClientUPS_Pass';
%=password_field 'ClientUPS_Pass', class => 'pass4 sme-password', autocomplete => 'off'
</span></p>
</div>
<div class=generics>
<h2 class='subh5'><%=l('nut_if_genericups')%></h2>
<p><span class=label>
%=l('nut_UPS_Generic_Type')
</span><span class=data>
% param 'UPS_gen_Type' => $nut_data->{UPS_gen_Type} unless param 'UPS_gen_Type';
%= text_field 'UPS_gen_Type', size => '50', class => 'textinput UPS_gen_Type' , pattern=>'.*' , placeholder=>'UPS_gen_Type'
<br></span></p>
<p><span class=label>
%=l('nut_UPS_Generic_Manufacturer')
</span><span class=data>
% param 'UPS_gen_Mfr' => $nut_data->{UPS_gen_Mfr} unless param 'UPS_gen_Mfr';
%= text_field 'UPS_gen_Mfr', size => '50', class => 'textinput UPS_gen_Mfr' , pattern=>'.*' , placeholder=>'UPS_gen_Mfr'
<br></span></p>
<p><span class=label>
%=l('nut_UPS_Generic_Model')
</span><span class=data>
% param 'UPS_gen_Model' => $nut_data->{UPS_gen_Model} unless param 'UPS_gen_Model';
%= text_field 'UPS_gen_Model', size => '50', class => 'textinput UPS_gen_Model' , pattern=>'.*' , placeholder=>'UPS_gen_Model'
<br></span></p>
</div>
<span class='data'>
%= submit_button l('nut_Save'), class => 'action subm12'
</span>
%# Probably finally by a submit.
%end
</div>

View File

@@ -35,6 +35,8 @@
<p class='paragraph para1'>
%=l('nut_Descriptive_paragraph')
</p>
<br />
<!--
<span class=label>
@@ -78,4 +80,4 @@
%# Probably finally by a submit.
%end
</div>
</div>

View File

@@ -16,7 +16,17 @@
<h2>Battery Status</h2>
<table>
<tr><td>Charge:</td><td><%= $nut_data->{'ups_data'}->{'battery.charge'} %>%</td></tr>
<tr><td>Runtime:</td><td><%= sprintf("%.2f", $nut_data->{'ups_data'}->{'battery.runtime'} / 60) %> minutes</td></tr>
%#<tr><td>Runtime:</td><td><%= sprintf("%.2f", $nut_data->{'ups_data'}->{'battery.runtime'} / 60) %> minutes</td></tr>
<td>Runtime:</td>
<td>
<%
my $runtime = $nut_data->{'ups_data'}->{'battery.runtime'};
my $runtime_minutes = (defined $runtime && $runtime =~ /^\d+(\.\d+)?$/)
? sprintf("%.2f", $runtime / 60)
: 'N/A';
%>
<%= $runtime_minutes %> minutes
</td>
<tr><td>Voltage:</td><td><%= $nut_data->{'ups_data'}->{'battery.voltage'} %>V</td></tr>
<tr><td>Type:</td><td><%= $nut_data->{'ups_data'}->{'battery.type'} %></td></tr>
</table>

View File

@@ -4,7 +4,7 @@ Summary: SME server - nut UPS interaction module
%define name smeserver-nutUPS
Name: %{name}
%define version 11.0.0
%define release 9
%define release 20
Version: %{version}
Release: %{release}%{?dist}
License: GPL
@@ -26,12 +26,43 @@ A module which configures the Network UPS Tools suite for operation with
the SME server software.
%changelog
* Mon Jul 07 2025 John Crisp <jcrisp@safeandsoundit.co.uk> 11.0.0-20.sme
- Remove errant backticks
- Add div to section to enhance formatting in Net Server mode
* Mon Jul 07 2025 Brian Read <brianr@koozali.org> 11.0.0-19.sme
- Changes from JC (thanks) and also make sure descriptions fit in with Master->Primary and Slave->Secondary [SME: 13069]
Also write descriptive paragraph as no-one else has!
Also also, incorporate newly auditted lex file
* Fri Jun 13 2025 Brian Read <brianr@koozali.org> 11.0.0-18.sme
- Adjust call from Custom to be emtpy hash not hashref [SME: 13042]
* Fri Jun 13 2025 Brian Read <brianr@koozali.org> 11.0.0-17.sme
- Fix return from function in Nutups-custom [SME: 13042]
- Check Seconds left for zero before dividing by 60 [SME: 13042]
* Fri Jun 13 2025 Brian Read <brianr@koozali.org> 11.0.0-16.sme
- Change Navigation weighting for SM2 [SME: 12996]
* Wed Jun 11 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-15.sme
- open db flat file using UTF8 [SME: 13035]
* Mon Jun 02 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-14.sme
- fix typo preventing netserver enabling [SME: 13021]
* Wed May 28 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-13.sme
- filter out nut* services from syslog (use journalctl) [SME: 13013]
* Sat May 24 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-11.sme
- fix issue with standalone and netserver mode [SME: 13012]
* Sun May 18 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-10.sme
- add pollinterval setting [SME: 13006]
- update config for Nut 2.8.2 [SME: 12657]
* 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]
@@ -108,9 +139,9 @@ the SME server software.
* Thu Jan 22 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 2.4.0-3.sme
- Remove obsolete directives {ACL,ACCEPT,REJECT} and switch to LISTEN
- in /etc/ups/upsd.conf
in /etc/ups/upsd.conf
- Allow NUT in /etc/hosts.allow and in /etc/services [SME: 8793]
- Code change from Daniel B.<daniel@firewall-services.com>
Code change from Daniel B.<daniel@firewall-services.com>
* Thu Jan 31 2013 Shad L. Lords <slords@mail.com> 2.4.0-2.sme
- Obsolete el5 packages that used to be required [SME: 7273]