softether: Fixed problems with using systemd services

authored by

Rick Yang and committed by
Rok Garbas
f8c3130e 5b8c8718

+17 -14
+17 -14
nixos/modules/services/networking/softether.nix
··· 61 61 dataDir = cfg.dataDir; 62 62 })) 63 63 ]; 64 - systemd.services.softether = { 65 - description = "SoftEther VPN services initial job"; 66 - after = [ "network-interfaces.target" ]; 67 - wantedBy = [ "multi-user.target" ]; 68 - preStart = '' 64 + systemd.services."softether-init" = { 65 + description = "SoftEther VPN services initial task"; 66 + wantedBy = [ "network-interfaces.target" ]; 67 + serviceConfig = { 68 + Type = "oneshot"; 69 + RemainAfterExit = false; 70 + }; 71 + script = '' 69 72 for d in vpnserver vpnbridge vpnclient vpncmd; do 70 73 if ! test -e ${cfg.dataDir}/$d; then 71 74 ${pkgs.coreutils}/bin/mkdir -m0700 -p ${cfg.dataDir}/$d ··· 81 84 (mkIf (cfg.vpnserver.enable) { 82 85 systemd.services.vpnserver = { 83 86 description = "SoftEther VPN Server"; 84 - after = [ "network-interfaces.target" ]; 85 - wantedBy = [ "multi-user.target" ]; 87 + after = [ "softether-init.service" ]; 88 + wantedBy = [ "network-interfaces.target" ]; 86 89 serviceConfig = { 90 + Type = "forking"; 87 91 ExecStart = "${pkg}/bin/vpnserver start"; 88 92 ExecStop = "${pkg}/bin/vpnserver stop"; 89 - Type = "forking"; 90 93 }; 91 94 preStart = '' 92 95 rm -rf ${cfg.dataDir}/vpnserver/vpnserver ··· 101 104 (mkIf (cfg.vpnbridge.enable) { 102 105 systemd.services.vpnbridge = { 103 106 description = "SoftEther VPN Bridge"; 104 - after = [ "network-interfaces.target" ]; 105 - wantedBy = [ "multi-user.target" ]; 107 + after = [ "softether-init.service" ]; 108 + wantedBy = [ "network-interfaces.target" ]; 106 109 serviceConfig = { 110 + Type = "forking"; 107 111 ExecStart = "${pkg}/bin/vpnbridge start"; 108 112 ExecStop = "${pkg}/bin/vpnbridge stop"; 109 - Type = "forking"; 110 113 }; 111 114 preStart = '' 112 115 rm -rf ${cfg.dataDir}/vpnbridge/vpnbridge ··· 121 124 (mkIf (cfg.vpnclient.enable) { 122 125 systemd.services.vpnclient = { 123 126 description = "SoftEther VPN Client"; 124 - after = [ "network-interfaces.target" ]; 125 - wantedBy = [ "multi-user.target" ]; 127 + after = [ "softether-init.service" ]; 128 + wantedBy = [ "network-interfaces.target" ]; 126 129 serviceConfig = { 130 + Type = "forking"; 127 131 ExecStart = "${pkg}/bin/vpnclient start"; 128 132 ExecStop = "${pkg}/bin/vpnclient stop"; 129 - Type = "forking"; 130 133 }; 131 134 preStart = '' 132 135 rm -rf ${cfg.dataDir}/vpnclient/vpnclient