nixos/openvpn: use writeShellScript

Previously the upScript would fail with

Syntax error: "(" unexpected (expecting "done")

on line 7 if /bin/sh is not bash.

Changed files
+2 -4
nixos
modules
services
networking
+2 -4
nixos/modules/services/networking/openvpn.nix
···
path = makeBinPath (getAttr "openvpn-${name}" config.systemd.services).path;
upScript = ''
-
#! /bin/sh
export PATH=${path}
# For convenience in client scripts, extract the remote domain
···
'';
downScript = ''
-
#! /bin/sh
export PATH=${path}
${optionalString cfg.updateResolvConf
"${pkgs.update-resolv-conf}/libexec/openvpn/update-resolv-conf"}
···
${optionalString (cfg.up != "" || cfg.down != "" || cfg.updateResolvConf) "script-security 2"}
${cfg.config}
${optionalString (cfg.up != "" || cfg.updateResolvConf)
-
"up ${pkgs.writeScript "openvpn-${name}-up" upScript}"}
${optionalString (cfg.down != "" || cfg.updateResolvConf)
-
"down ${pkgs.writeScript "openvpn-${name}-down" downScript}"}
${optionalString (cfg.authUserPass != null)
"auth-user-pass ${pkgs.writeText "openvpn-credentials-${name}" ''
${cfg.authUserPass.username}
···
path = makeBinPath (getAttr "openvpn-${name}" config.systemd.services).path;
upScript = ''
export PATH=${path}
# For convenience in client scripts, extract the remote domain
···
'';
downScript = ''
export PATH=${path}
${optionalString cfg.updateResolvConf
"${pkgs.update-resolv-conf}/libexec/openvpn/update-resolv-conf"}
···
${optionalString (cfg.up != "" || cfg.down != "" || cfg.updateResolvConf) "script-security 2"}
${cfg.config}
${optionalString (cfg.up != "" || cfg.updateResolvConf)
+
"up ${pkgs.writeShellScript "openvpn-${name}-up" upScript}"}
${optionalString (cfg.down != "" || cfg.updateResolvConf)
+
"down ${pkgs.writeShellScript "openvpn-${name}-down" downScript}"}
${optionalString (cfg.authUserPass != null)
"auth-user-pass ${pkgs.writeText "openvpn-credentials-${name}" ''
${cfg.authUserPass.username}