diff --git a/root/etc/e-smith/events/actions/nut-config-drivers b/root/etc/e-smith/events/actions/nut-config-drivers index 550fa8e..b9e49b6 100644 --- a/root/etc/e-smith/events/actions/nut-config-drivers +++ b/root/etc/e-smith/events/actions/nut-config-drivers @@ -5,7 +5,7 @@ # then traditionnal services2adjust # enumerate / configure drivers -/usr/libexec/nut-driver-enumerator.sh +/usr/libexec/nut-driver-enumerator.sh 2>/dev/null event=$1 @@ -17,6 +17,7 @@ if [[ $i == "bootstrap-console-save" ]] ; then exit 0 fi +# if disabled stop them if [[ $(/sbin/e-smith/config getprop nut status || echo "disabled") == "disabled" ]] ; then # if disabled stop them for OUTPUT in $(/sbin/e-smith/config keys|grep nut-driver) @@ -26,6 +27,17 @@ if [[ $(/sbin/e-smith/config getprop nut status || echo "disabled") == "disabled exit 0 fi +# if netclient stop them +if [[ $(/sbin/e-smith/config getprop nut Mode || echo "netclient") == "netclient" ]] ; then + # if disabled stop them + for OUTPUT in $(/sbin/e-smith/config keys|grep nut-driver) + do + /usr/bin/systemctl stop $OUTPUT 2>/dev/null + done + exit 0 +fi + + # if we are there we want to restart / start them for OUTPUT in $(/sbin/e-smith/config keys|grep nut-driver) do diff --git a/root/etc/e-smith/templates/etc/ups/ups.conf/UPS b/root/etc/e-smith/templates/etc/ups/ups.conf/UPS index f42a18c..0dfa1ff 100644 --- a/root/etc/e-smith/templates/etc/ups/ups.conf/UPS +++ b/root/etc/e-smith/templates/etc/ups/ups.conf/UPS @@ -1,22 +1,24 @@ { my @upses = grep(/^nut-driver\@[a-zA-Z0-9_-]+$/, $DB->keys); foreach my $ups ( sort {$a cmp $b} @upses ) - { - my $nnut = ${$ups}; - 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}; - $OUT .= "[$name]\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 $nnut = ${$ups}; + my $status = $nnut{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}; + $OUT .= "[$name]\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"; - } } diff --git a/root/usr/share/smanager/lib/SrvMngr/Controller/Nutups-Custom.pm b/root/usr/share/smanager/lib/SrvMngr/Controller/Nutups-Custom.pm index 53151dc..99bb223 100644 --- a/root/usr/share/smanager/lib/SrvMngr/Controller/Nutups-Custom.pm +++ b/root/usr/share/smanager/lib/SrvMngr/Controller/Nutups-Custom.pm @@ -247,7 +247,7 @@ sub get_model_options { sub get_ups_status { my $c = shift; $cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); - my $nutmode = $cdb->get_prop('nut', 'Mode','standalone'); + 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'){ diff --git a/root/usr/share/smanager/themes/default/templates/partials/_nut_STATUS.html.ep b/root/usr/share/smanager/themes/default/templates/partials/_nut_STATUS.html.ep index 9886b6a..0ef52b8 100644 --- a/root/usr/share/smanager/themes/default/templates/partials/_nut_STATUS.html.ep +++ b/root/usr/share/smanager/themes/default/templates/partials/_nut_STATUS.html.ep @@ -45,6 +45,12 @@
--> + + %=l('nut_Nut_mode') + + %= $nut_data->{Nutmode} +
+ % if ($nut_data->{Nutmode} eq "nutserver") {