···7373 openvpn-restart = {
7474 wantedBy = [ "sleep.target" ];
7575 path = [ pkgs.procps ];
7676- script = "pkill --signal SIGHUP --exact openvpn";
7777- #SIGHUP makes openvpn process to self-exit and then it got restarted by systemd because of Restart=always
7676+ script = let
7777+ unitNames = map (n: "openvpn-${n}.service") (builtins.attrNames cfg.servers);
7878+ in "systemctl try-restart ${lib.escapeShellArgs unitNames}";
7879 description = "Sends a signal to OpenVPN process to trigger a restart after return from sleep";
7980 };
8081 };