nixos-module/server/lxc-containers: switch back to using ConditionPathExists

much more graceful to systemd
This commit is contained in:
Astro 2021-05-01 03:07:28 +02:00
parent aa5c7377c7
commit 93d312c26c
1 changed files with 2 additions and 14 deletions

View File

@ -176,22 +176,10 @@ in
systemd.services."lxc@" = {
description = "LXC container '%i'";
after = [ "network.target" ];
unitConfig.ConditionPathExists = "/var/lib/lxc/%i/rootfs/init";
serviceConfig = {
Type = "simple";
ExecStart =
let
script = pkgs.writeScript "start-lxc-container.sh" ''
#! ${pkgs.runtimeShell} -e
if [ ! -e /var/lib/lxc/$1/rootfs ]; then
echo "Container $1 does not exist. Run: build-container $1"
exit 1
fi
exec ${pkgs.lxc}/bin/lxc-start -F -C -n $1
'';
in
"${script} %i";
ExecStart = "${pkgs.lxc}/bin/lxc-start -F -C -n %i";
ExecStop = "${pkgs.lxc}/bin/lxc-stop -n %i";
ExecReload =
let