make start command idempotent

This commit is contained in:
Maximilian Güntner
2020-06-25 22:33:20 +02:00
parent 8316fb6b55
commit bb278981d1

View File

@@ -23,8 +23,12 @@ let
requires = after;
serviceConfig = {
ExecStart = ''
${pkgs.docker}/bin/docker network create ${name}
ExecStart = pkgs.writeScript "docker-network-create-${name}" ''
#!${pkgs.runtimeShell} -e
set -x
if [[ -z "$(${pkgs.docker}/bin/docker network ls | grep ${name} | tr -d '\n')" ]]; then
${pkgs.docker}/bin/docker network create ${name}
fi
'';
ExecStop = ''
${pkgs.docker}/bin/docker network rm ${name}