diff options
author | Mathijs Kwik <mathijs@bluescreen303.nl> | 2012-12-26 23:49:22 +0100 |
---|---|---|
committer | Mathijs Kwik <mathijs@bluescreen303.nl> | 2012-12-27 12:23:50 +0100 |
commit | 3456f3b2328eddee4e34c5807959bdd32efd70da (patch) | |
tree | 0ddd42baecc3e2b9cada6c4faffa18f64d6683e6 /modules/services/networking/gogoclient.nix | |
parent | f61f0c139b85766cff6bd40c304cdbf957ea2b27 (diff) | |
download | nixlib-3456f3b2328eddee4e34c5807959bdd32efd70da.tar nixlib-3456f3b2328eddee4e34c5807959bdd32efd70da.tar.gz nixlib-3456f3b2328eddee4e34c5807959bdd32efd70da.tar.bz2 nixlib-3456f3b2328eddee4e34c5807959bdd32efd70da.tar.lz nixlib-3456f3b2328eddee4e34c5807959bdd32efd70da.tar.xz nixlib-3456f3b2328eddee4e34c5807959bdd32efd70da.tar.zst nixlib-3456f3b2328eddee4e34c5807959bdd32efd70da.zip |
systemd: convert gogoclient job to service unit
Diffstat (limited to 'modules/services/networking/gogoclient.nix')
-rw-r--r-- | modules/services/networking/gogoclient.nix | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/modules/services/networking/gogoclient.nix b/modules/services/networking/gogoclient.nix index 593f2436a393..519c45a385a7 100644 --- a/modules/services/networking/gogoclient.nix +++ b/modules/services/networking/gogoclient.nix @@ -56,22 +56,36 @@ in config = mkIf cfg.enable { boot.kernelModules = [ "tun" ]; - # environment.systemPackages = [pkgs.gogoclient]; - networking.enableIPv6 = true; - jobs.gogoclient = { - name = "gogoclient"; + boot.systemd.services.gogoclient = { + description = "ipv6 tunnel"; - startOn = optionalString cfg.autorun "starting networking"; - stopOn = "stopping network-interfaces"; - preStart = '' - mkdir -p /var/lib/gogoc - chmod 700 /var/lib/gogoc - cat ${pkgs.gogoclient}/share/${pkgs.gogoclient.name}/gogoc.conf.sample | ${pkgs.gnused}/bin/sed -e "s|^userid=|&${cfg.username}|;s|^passwd=|&${if cfg.password == "" then "" else "$(cat ${cfg.password})"}|;s|^server=.*|server=${cfg.server}|;s|^auth_method=.*|auth_method=${if cfg.password == "" then "anonymous" else "any"}|;s|^#log_file=|log_file=1|" > /var/lib/gogoc/gogoc.conf + + after = [ "network.target" ]; + + preStart = let authMethod = if cfg.password == "" then "anonymous" else "any"; in + '' + mkdir -p -m 700 /var/lib/gogoc + cat ${pkgs.gogoclient}/share/${pkgs.gogoclient.name}/gogoc.conf.sample | \ + ${pkgs.gnused}/bin/sed \ + -e "s|^userid=|&${cfg.username}|" \ + -e "s|^passwd=|&${optionalString (cfg.password != "") "$(cat ${cfg.password})"}|" \ + -e "s|^server=.*|server=${cfg.server}|" \ + -e "s|^auth_method=.*|auth_method=${authMethod}|" \ + -e "s|^#log_file=|log_file=1|" > /var/lib/gogoc/gogoc.conf ''; - script = "cd /var/lib/gogoc; exec gogoc -y -f ./gogoc.conf"; - path = [pkgs.gogoclient]; + + serviceConfig.ExecStart = "${pkgs.gogoclient}/bin/gogoc -y -f /var/lib/gogoc/gogoc.conf"; + + restartTriggers = attrValues cfg; + + } // optionalAttrs cfg.autorun { + + wantedBy = [ "ip-up.target" ]; + + partOf = [ "ip-up.target" ]; + }; }; |