Uninterruptible power supply: Difference between revisions
|  →Delay UPS Shutdown:  fix attrset |  →Delay UPS Shutdown:  do not use slice | ||
| Line 246: | Line 246: | ||
|    # copied from ConfigExamples 3.0 book, Appendix B.2. |    # copied from ConfigExamples 3.0 book, Appendix B.2. | ||
|    systemd.services.nut-delayed-ups-shutdown = { |    systemd.services.nut-delayed-ups-shutdown = { | ||
|      environment = config.systemd.services. |     enable = true; | ||
|      environment = config.systemd.services.upsmon.environment; | |||
|      description = "Initiate delayed UPS shutdown"; | |||
|     before = [ "umount.target" ]; | |||
|     wantedBy = [ "final.target" ]; | |||
|      serviceConfig = { |      serviceConfig = { | ||
|        Type = "oneshot"; |        Type = "oneshot"; | ||
|        ExecStart = ''${pkgs. |       # 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> | </syntaxhighlight> | ||