From 2378308576ae0e501dd6291ae53ea9694b6a5bdb Mon Sep 17 00:00:00 2001 From: Brian Read Date: Fri, 14 Feb 2025 18:57:07 +0000 Subject: [PATCH 1/3] Make copySM2 a bit more generic --- copySM2.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/copySM2.sh b/copySM2.sh index e0d949b..1d52876 100755 --- a/copySM2.sh +++ b/copySM2.sh @@ -5,7 +5,10 @@ if [ $# -ne 3 ]; then exit 1 fi export REMOTE=/home/brianr/$1/usr/share/smanager -cd ~/clients/SM2/SM2Gen/venv/Targets/$3 +mkdir -p $REMOTE +export LOCAL=~/clients/SM2/SM2Gen/venv +export SME11IP=$1.thereadclan.me.uk +cd $LOCAL/Targets/$3 echo `pwd` # controller file name is just capitalised cont_file=$(echo "$3" | awk '{ @@ -30,7 +33,7 @@ find . -maxdepth 1 -type f -name "[!_]*\.ep" | xargs -I% bash -c 'cp -fv % $REM mkdir -p $REMOTE/lib/SrvMngr/I18N/Modules/$3 cp -fv *.lex $REMOTE/lib/SrvMngr/I18N/Modules/$3 rm -f $REMOTE/lib/SrvMngr/I18N/Modules/$3/*.pm -ssh -p 1234 root@$1.thereadclan.me.uk 'signal-event smanager-refresh' +ssh -p 1234 root@$SME11IP 'signal-event smanager-refresh' exit 0 From 8ff23b4775eddbf93d30eab4dddbc66d570e187e Mon Sep 17 00:00:00 2001 From: Brian Read Date: Fri, 14 Feb 2025 19:37:39 +0000 Subject: [PATCH 2/3] Fix config change and add js to copySM2 --- Targets/Nutups/_nut_CONFIG.html.ep | 4 ++-- Targets/Nutups/_nut_STATUS.html.ep | 4 ++-- Targets/Nutups/nutups.html.ep | 4 ++-- copySM2.sh | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Targets/Nutups/_nut_CONFIG.html.ep b/Targets/Nutups/_nut_CONFIG.html.ep index b84e179..7360067 100644 --- a/Targets/Nutups/_nut_CONFIG.html.ep +++ b/Targets/Nutups/_nut_CONFIG.html.ep @@ -7,7 +7,7 @@ SelectInput(); }; - % if ($config->{debug} == 1) { + % if (config->{debug} == 1) {
 			%= dumper $nut_data
 		
@@ -133,4 +133,4 @@ %# Probably finally by a submit. %end - \ No newline at end of file + diff --git a/Targets/Nutups/_nut_STATUS.html.ep b/Targets/Nutups/_nut_STATUS.html.ep index e03c415..e8ea7aa 100644 --- a/Targets/Nutups/_nut_STATUS.html.ep +++ b/Targets/Nutups/_nut_STATUS.html.ep @@ -7,7 +7,7 @@ SelectInput(); }; - % if ($config->{debug} == 1) { + % if (config->{debug} == 1) {
 			%= dumper $nut_data
 		
@@ -45,4 +45,4 @@ %# Probably finally by a submit. %end - \ No newline at end of file + diff --git a/Targets/Nutups/nutups.html.ep b/Targets/Nutups/nutups.html.ep index e4e3871..e15eade 100644 --- a/Targets/Nutups/nutups.html.ep +++ b/Targets/Nutups/nutups.html.ep @@ -8,7 +8,7 @@ %= javascript '/js/nutups.js'
- % if ($config->{debug} == 1) { + % if (config->{debug} == 1) {
 		%= dumper $c->current_route
 		%= dumper $nut_data->{trt}
@@ -55,4 +55,4 @@
 
 
 
-%end \ No newline at end of file +%end diff --git a/copySM2.sh b/copySM2.sh index 1d52876..ebb1e31 100755 --- a/copySM2.sh +++ b/copySM2.sh @@ -24,10 +24,11 @@ echo $cont_file #fi mkdir -p $REMOTE/lib/SrvMngr/Controller mkdir -p $REMOTE/themes/default/templates/partials/ -mkdir -p $REMOTE/lib/SrvMngr/I18N/Modules/Nfsshare -mkdir -p $REMOTE/themes/default/templates/ +mkdir -p $REMOTE/themes/default/public/css +mkdir -p $REMOTE/themes/default/public/js cp -fv *.pm $REMOTE/lib/SrvMngr/Controller cp -fv *.css $REMOTE/themes/default/public/css +cp -fv *.js $REMOTE/themes/default/public/js cp -fv _$2*.html.ep $REMOTE/themes/default/templates/partials/ find . -maxdepth 1 -type f -name "[!_]*\.ep" | xargs -I% bash -c 'cp -fv % $REMOTE/themes/default/templates/' mkdir -p $REMOTE/lib/SrvMngr/I18N/Modules/$3 From 75aaf422042b2af06071fd64175eb15f6c4ae92b Mon Sep 17 00:00:00 2001 From: Brian Read Date: Fri, 14 Feb 2025 20:02:08 +0000 Subject: [PATCH 3/3] Setup to extract device types for dropdown --- Targets/Nutups/Nutups-Custom.pm | 12 ++++++------ Targets/Nutups/spec.nutUPS | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 Targets/Nutups/spec.nutUPS diff --git a/Targets/Nutups/Nutups-Custom.pm b/Targets/Nutups/Nutups-Custom.pm index 090d007..1b443b3 100644 --- a/Targets/Nutups/Nutups-Custom.pm +++ b/Targets/Nutups/Nutups-Custom.pm @@ -147,10 +147,10 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); my $prefix_data = shift; #Data hash as parameter my $ret = ""; my $db = $cdb; #maybe one of the others - my $dbkey = 'ChangeThis'; + my $dbkey = 'nut'; # 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: status e.g. $db->set_prop($dbkey,'status',$c->param('status'),type=>'service')) + if (!$db->set_prop($dbkey,'status',$c->param('status'),type=>'service')) {$ret .= 'Perform/save failed for status';} if (! TRUE) #copy or perform with value: Nutmode e.g. $db->set_prop($dbkey,'Nutmode',$c->param('Nutmode'),type=>'service')) {$ret .= 'Perform/save failed for Nutmode';} @@ -191,11 +191,11 @@ sub get_model_options { return ['Error occurred']; } - # Remove "/usr/sbin" from the front of each line - s{^/usr/sbin}{} for @output; + # Remove "/usr/sbin/" from the front of each line + s{^/usr/sbin/}{} for @output; # Trim whitespace from each element and return the array chomp(@output); # Remove newline characters from each line - return ["fred","Art"] #@output; # Return the array of modified output lines + return @output; # Return the array of modified output lines } -1; \ No newline at end of file +1; diff --git a/Targets/Nutups/spec.nutUPS b/Targets/Nutups/spec.nutUPS new file mode 100644 index 0000000..e103f91 --- /dev/null +++ b/Targets/Nutups/spec.nutUPS @@ -0,0 +1,27 @@ +main page = status +config page: +-nut status : enable/disabled + + nut mode : standalone|netserver|netclient + if netclient mode + +ask for SlaveUPS "UPSNAME@IP" and SlavePass "" +set Master as no when saving + + if standalone or netserver + +either use default value for NUT device, or allow to set them +${nut-driver@UPS }{Model} usbhid-ups you can use a drop-down listing all the device rpm -ql nut|grep /usr/sbin +${nut-driver@UPS }{Device} auto +only if Model genericups: +${nut-driver@UPS }{Type} +${nut-driver@UPS }{mfr} +${nut-driver@UPS }{mdl} +on saving set nut{Master} to yes if mode standalone or netserver +if mode=netserver set nut{access} to private otherwise set as localhost +run signal-event nut-conf + +if enabled the status page could return upsc UPS@localhost, or if slave upsc UPSNAME@IP +if netclient set nut-monitor status to enabled and set status disabled to nut-server and all existing nut-driver@* ( we can set multiple via cli, so a loop would be great there) +if standalone|netserver then enable all nut related service if nut enabled +if nut disabled then set all related services to disabled