Generate more user-friendly script filenames

This is primarily important in journal entries.
This commit is contained in:
Eelco Dolstra 2012-10-15 16:01:30 -04:00
parent 6a9b855412
commit a4cad32c3d
2 changed files with 12 additions and 10 deletions

View File

@ -158,7 +158,9 @@ let
KillSignal=SIGHUP
'';
makeJobScript = name: content: "${pkgs.writeScriptBin name content}/bin/${name}";
makeJobScript = name: text:
let x = pkgs.writeTextFile { name = "unit-script"; executable = true; destination = "/bin/${name}"; inherit text; };
in "${x}/bin/${name}";
unitConfig = { name, config, ... }: {
config = {
@ -224,28 +226,28 @@ let
${optionalString (!def.restartIfChanged) "X-RestartIfChanged=false"}
${optionalString (def.preStart != "") ''
ExecStartPre=${makeJobScript "prestart.sh" ''
ExecStartPre=${makeJobScript "${name}-pre-start" ''
#! ${pkgs.stdenv.shell} -e
${def.preStart}
''}
''}
${optionalString (def.script != "") ''
ExecStart=${makeJobScript "start.sh" ''
ExecStart=${makeJobScript "${name}-start" ''
#! ${pkgs.stdenv.shell} -e
${def.script}
''}
''}
${optionalString (def.postStart != "") ''
ExecStartPost=${makeJobScript "poststart.sh" ''
ExecStartPost=${makeJobScript "${name}-post-start" ''
#! ${pkgs.stdenv.shell} -e
${def.postStart}
''}
''}
${optionalString (def.postStop != "") ''
ExecStopPost=${makeJobScript "poststop.sh" ''
ExecStopPost=${makeJobScript "${name}-post-stop" ''
#! ${pkgs.stdenv.shell} -e
${def.postStop}
''}

View File

@ -21,13 +21,13 @@ let
env = config.system.upstartEnvironment // job.environment;
preStartScript = makeJobScript "${job.name}-pre-start.sh"
preStartScript = makeJobScript "${job.name}-pre-start"
''
#! ${pkgs.stdenv.shell} -e
${job.preStart}
'';
startScript = makeJobScript "${job.name}-start.sh"
startScript = makeJobScript "${job.name}-start"
''
#! ${pkgs.stdenv.shell} -e
${if job.script != "" then job.script else ''
@ -35,19 +35,19 @@ let
''}
'';
postStartScript = makeJobScript "${job.name}-post-start.sh"
postStartScript = makeJobScript "${job.name}-post-start"
''
#! ${pkgs.stdenv.shell} -e
${job.postStart}
'';
preStopScript = makeJobScript "${job.name}-pre-stop.sh"
preStopScript = makeJobScript "${job.name}-pre-stop"
''
#! ${pkgs.stdenv.shell} -e
${job.preStop}
'';
postStopScript = makeJobScript "${job.name}-post-stop.sh"
postStopScript = makeJobScript "${job.name}-post-stop"
''
#! ${pkgs.stdenv.shell} -e
${job.postStop}