From 88292fdf09960e9cb8e3c063a6b95ac4284222ec Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Wed, 6 Jan 2016 06:50:18 +0000 Subject: jobs -> systemd.services --- .../modules/services/network-filesystems/drbd.nix | 38 ++++++---------- .../network-filesystems/openafs-client/default.nix | 52 ++++++++++------------ 2 files changed, 37 insertions(+), 53 deletions(-) (limited to 'nixos/modules/services/network-filesystems') diff --git a/nixos/modules/services/network-filesystems/drbd.nix b/nixos/modules/services/network-filesystems/drbd.nix index 1bd67206444e..9896a93b1894 100644 --- a/nixos/modules/services/network-filesystems/drbd.nix +++ b/nixos/modules/services/network-filesystems/drbd.nix @@ -31,13 +31,13 @@ let cfg = config.services.drbd; in }; - + ###### implementation config = mkIf cfg.enable { - + environment.systemPackages = [ pkgs.drbd ]; - + services.udev.packages = [ pkgs.drbd ]; boot.kernelModules = [ "drbd" ]; @@ -52,26 +52,16 @@ let cfg = config.services.drbd; in target = "drbd.conf"; }; - jobs.drbd_up = - { name = "drbd-up"; - startOn = "stopped udevtrigger or ip-up"; - task = true; - script = - '' - ${pkgs.drbd}/sbin/drbdadm up all - ''; - }; - - jobs.drbd_down = - { name = "drbd-down"; - startOn = "starting shutdown"; - task = true; - script = - '' - ${pkgs.drbd}/sbin/drbdadm down all - ''; - }; - + systemd.services.drbd = { + after = [ "systemd-udev.settle.service" ]; + wants = [ "systemd-udev.settle.service" ]; + wantedBy = [ "ip-up.target" ]; + script = '' + ${pkgs.drbd}/sbin/drbdadm up all + ''; + serviceConfig.ExecStop = '' + ${pkgs.drbd}/sbin/drbdadm down all + ''; + }; }; - } diff --git a/nixos/modules/services/network-filesystems/openafs-client/default.nix b/nixos/modules/services/network-filesystems/openafs-client/default.nix index 0297da9e865f..7a44fc1ea5ec 100644 --- a/nixos/modules/services/network-filesystems/openafs-client/default.nix +++ b/nixos/modules/services/network-filesystems/openafs-client/default.nix @@ -72,34 +72,28 @@ in } ]; - jobs.openafsClient = - { name = "afsd"; - - description = "AFS client"; - - startOn = "started network-interfaces"; - stopOn = "stopping network-interfaces"; - - preStart = '' - mkdir -p -m 0755 /afs - mkdir -m 0700 -p ${cfg.cacheDirectory} - ${pkgs.module_init_tools}/sbin/insmod ${openafsPkgs}/lib/openafs/libafs-*.ko || true - ${openafsPkgs}/sbin/afsd -confdir ${afsConfig} -cachedir ${cfg.cacheDirectory} ${if cfg.sparse then "-dynroot-sparse" else "-dynroot"} -fakestat -afsdb - ${openafsPkgs}/bin/fs setcrypt ${if cfg.crypt then "on" else "off"} - ''; - - # Doing this in preStop, because after these commands AFS is basically - # stopped, so systemd has nothing to do, just noticing it. If done in - # postStop, then we get a hang + kernel oops, because AFS can't be - # stopped simply by sending signals to processes. - preStop = '' - ${pkgs.utillinux}/bin/umount /afs - ${openafsPkgs}/sbin/afsd -shutdown - ${pkgs.module_init_tools}/sbin/rmmod libafs - ''; - - }; - + systemd.services.afsd = { + description = "AFS client"; + wantedBy = [ "multi-user.target" ]; + after = [ "network-interfaces.target" ]; + + preStart = '' + mkdir -p -m 0755 /afs + mkdir -m 0700 -p ${cfg.cacheDirectory} + ${pkgs.module_init_tools}/sbin/insmod ${openafsPkgs}/lib/openafs/libafs-*.ko || true + ${openafsPkgs}/sbin/afsd -confdir ${afsConfig} -cachedir ${cfg.cacheDirectory} ${if cfg.sparse then "-dynroot-sparse" else "-dynroot"} -fakestat -afsdb + ${openafsPkgs}/bin/fs setcrypt ${if cfg.crypt then "on" else "off"} + ''; + + # Doing this in preStop, because after these commands AFS is basically + # stopped, so systemd has nothing to do, just noticing it. If done in + # postStop, then we get a hang + kernel oops, because AFS can't be + # stopped simply by sending signals to processes. + preStop = '' + ${pkgs.utillinux}/bin/umount /afs + ${openafsPkgs}/sbin/afsd -shutdown + ${pkgs.module_init_tools}/sbin/rmmod libafs + ''; + }; }; - } -- cgit 1.4.1