* 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:
		| @@ -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; | ||||
| 				} | ||||
| 			} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user