|
|
| (2 intermediate revisions by 2 users not shown) |
| Line 25: |
Line 25: |
| needs a new battery every four years, under optimal operating | | needs a new battery every four years, under optimal operating |
| conditions. | | conditions. |
|
| |
| The end of ConfigExample book says:
| |
|
| |
| Joe's server will still be allright
| |
| if power drops off in the night.
| |
| That 8 year old pack
| |
| of battery backup
| |
| will easily handle th connection lost
| |
|
| |
|
| = Components of NUT Software = | | = Components of NUT Software = |
| Line 140: |
Line 132: |
| # declarations. upsd.users | | # declarations. upsd.users |
| users."nut-admin" = { | | users."nut-admin" = { |
| passwordFile = "${../resources/ups-passwd.txt}"; | | # A file that contains just the password. |
| | passwordFile = "/etc/nixos/ups-passwd.txt"; |
| upsmon = "primary"; | | upsmon = "primary"; |
| }; | | }; |
| Line 155: |
Line 148: |
| powerValue = 1; | | powerValue = 1; |
| user = "nut-admin"; | | user = "nut-admin"; |
| passwordFile = "${../resources/ups-passwd.txt}"; | | passwordFile = "/etc/nixos/ups-passwd.txt"; |
| type = "primary"; | | type = "primary"; |
| }; | | }; |
| Line 212: |
Line 205: |
| }; | | }; |
| </syntaxhighlight> | | </syntaxhighlight> |
|
| |
| = Delay UPS Shutdown =
| |
|
| |
| As part of the system shutdown process, there needs to be an action to
| |
| send a message to the UPS to tell it that some time later, it too will
| |
| shut down. Note that the UPS does not shutdown at the same time as the
| |
| system it protects. The UPS shutdown is delayed. By default the delay
| |
| is 20 seconds. The absence of AC power to the protected system for a
| |
| sufficient time has the effect of resetting the BIOS options, and in
| |
| particular the option Restore power on AC return. This BIOS option
| |
| will be needed to restart the box.
| |
|
| |
| During the system shutdown, systemd service unit runs the command
| |
| <code>upsdrvctl shutdown</code>. This tells the UPS that it is to shut down
| |
| offdelay seconds later. The system powers down before offdelay seconds
| |
| have passed. Wall power returns before the UPS shuts down. Less than
| |
| offdelay seconds have now passed. The UPS continues it's shutdown
| |
| process.
| |
|
| |
| After offdelay seconds the UPS shuts down, disconnecting it's
| |
| outlets. The beeping stops. With some UPS units, there is an audible
| |
| clunk. An interval of ondelay minus offdelay seconds later: After ondelay
| |
| seconds the UPS turns itself on, and repowers it's outlets. The system
| |
| BIOS option Restore Power on AC return has hopefully been selected and
| |
| the system powers up.
| |
|
| |
| There is a danger that the system will take longer
| |
| than the default 20 seconds to shut down. If that were to happen, the UPS shutdown
| |
| would provoke a brutal system crash. We have adjusted offdelay above, to solve this issue.
| |
|
| |
|
| |
| <syntaxhighlight lang="nix">
| |
| # copied from ConfigExamples 3.0 book, Appendix B.2.
| |
| systemd.services.nut-delayed-ups-shutdown = {
| |
| enable = true;
| |
| environment = config.systemd.services.upsmon.environment;
| |
| description = "Initiate delayed UPS shutdown";
| |
| before = [ "umount.target" ];
| |
| wantedBy = [ "final.target" ];
| |
| serviceConfig = {
| |
| Type = "oneshot";
| |
| # need to use '-u root', or else permission denied
| |
| ExecStart = ''${pkgs.nut}/bin/upsdrvctl -u root shutdown'';
| |
| # must not use slice: if used, upsdrvctl will not run as a late
| |
| # shutdown service
| |
| # Slice = "";
| |
| };
| |
| unitConfig = {
| |
| ConditionPathExists = config.power.ups.upsmon.settings.POWERDOWNFLAG;
| |
| DefaultDependencies = "no";
| |
| };
| |
| };
| |
| </syntaxhighlight>
| |
|
| |
|
| |
| [[Category:Hardware]] | | [[Category:Hardware]] |