diff options
author | Tristan Helmich <tristan.helmich@gmail.com> | 2017-04-21 10:55:11 +0200 |
---|---|---|
committer | Graham Christensen <graham@grahamc.com> | 2017-04-25 13:18:54 -0400 |
commit | 50ad243f7802c09788441fb0099626387fddb2db (patch) | |
tree | 615a71548aaa9020049a0013078a82916b917e1f | |
parent | b6714f524b6c4ed04ccf35f96132a1f4511fedcb (diff) | |
download | nixlib-50ad243f7802c09788441fb0099626387fddb2db.tar nixlib-50ad243f7802c09788441fb0099626387fddb2db.tar.gz nixlib-50ad243f7802c09788441fb0099626387fddb2db.tar.bz2 nixlib-50ad243f7802c09788441fb0099626387fddb2db.tar.lz nixlib-50ad243f7802c09788441fb0099626387fddb2db.tar.xz nixlib-50ad243f7802c09788441fb0099626387fddb2db.tar.zst nixlib-50ad243f7802c09788441fb0099626387fddb2db.zip |
openvpn service: source up/down scripts
source the up/down scripts instead of executing them to avoid loosing access to special variables like $1
-rw-r--r-- | nixos/modules/services/networking/openvpn.nix | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/openvpn.nix b/nixos/modules/services/networking/openvpn.nix index 3fbf5a9f0227..1e99a2b4450c 100644 --- a/nixos/modules/services/networking/openvpn.nix +++ b/nixos/modules/services/networking/openvpn.nix @@ -28,9 +28,10 @@ let fi done - ${cfg.up} ${optionalString cfg.updateResolvConf "${pkgs.update-resolv-conf}/libexec/openvpn/update-resolv-conf"} + + ${optionalString (cfg.up != "") "source ${userSuppliedUpScript}"} ''; downScript = '' @@ -38,6 +39,15 @@ let export PATH=${path} ${optionalString cfg.updateResolvConf "${pkgs.update-resolv-conf}/libexec/openvpn/update-resolv-conf"} + + ${optionalString (cfg.down != "") "source ${userSuppliedDownScript}"} + ''; + + userSuppliedUpScript = pkgs.writeScript "openvpn-${name}-userSuppliedUpScript" '' + ${cfg.up} + ''; + + userSuppliedDownScript = pkgs.writeScript "openvpn-${name}-userSuppliedDownScript" '' ${cfg.down} ''; @@ -133,7 +143,7 @@ in default = ""; type = types.lines; description = '' - Shell commands executed when the instance is starting. + Shell script sourced by NixOS generated script when the instance is starting. ''; }; @@ -141,7 +151,7 @@ in default = ""; type = types.lines; description = '' - Shell commands executed when the instance is shutting down. + Shell script sourced by NixOS generated script when the instance is shutting down. ''; }; |