diff --git a/nixos/modules/services/networking/openvpn.nix b/nixos/modules/services/networking/openvpn.nix index fba6d5e48f92..56b1f6f5ab8f 100644 --- a/nixos/modules/services/networking/openvpn.nix +++ b/nixos/modules/services/networking/openvpn.nix @@ -73,8 +73,9 @@ let openvpn-restart = { wantedBy = [ "sleep.target" ]; path = [ pkgs.procps ]; - script = "pkill --signal SIGHUP --exact openvpn"; - #SIGHUP makes openvpn process to self-exit and then it got restarted by systemd because of Restart=always + script = let + unitNames = map (n: "openvpn-${n}.service") (builtins.attrNames cfg.servers); + in "systemctl try-restart ${lib.escapeShellArgs unitNames}"; description = "Sends a signal to OpenVPN process to trigger a restart after return from sleep"; }; };