nixos-module/server/lxc-containers: switch back to using ConditionPathExists
much more graceful to systemd
This commit is contained in:
parent
aa5c7377c7
commit
93d312c26c
|
@ -176,22 +176,10 @@ in
|
||||||
systemd.services."lxc@" = {
|
systemd.services."lxc@" = {
|
||||||
description = "LXC container '%i'";
|
description = "LXC container '%i'";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
|
unitConfig.ConditionPathExists = "/var/lib/lxc/%i/rootfs/init";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
ExecStart =
|
ExecStart = "${pkgs.lxc}/bin/lxc-start -F -C -n %i";
|
||||||
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";
|
|
||||||
ExecStop = "${pkgs.lxc}/bin/lxc-stop -n %i";
|
ExecStop = "${pkgs.lxc}/bin/lxc-stop -n %i";
|
||||||
ExecReload =
|
ExecReload =
|
||||||
let
|
let
|
||||||
|
|
Loading…
Reference in New Issue