3
0
Fork 0
forked from mirrors/nixpkgs

Allow services to specify a pre-stop script

This commit is contained in:
Eelco Dolstra 2013-11-26 18:24:55 +01:00
parent 2b1f212494
commit 14cd8bc248
2 changed files with 14 additions and 0 deletions

View file

@ -210,6 +210,14 @@ in rec {
'';
};
preStop = mkOption {
type = types.lines;
default = "";
description = ''
Shell commands executed to stop the service.
'';
};
postStop = mkOption {
type = types.lines;
default = "";

View file

@ -190,6 +190,12 @@ let
${config.postStart}
'';
})
(mkIf (config.preStop != "")
{ serviceConfig.ExecStop = makeJobScript "${name}-pre-stop" ''
#! ${pkgs.stdenv.shell} -e
${config.preStop}
'';
})
(mkIf (config.postStop != "")
{ serviceConfig.ExecStopPost = makeJobScript "${name}-post-stop" ''
#! ${pkgs.stdenv.shell} -e