nixos-module/server/lxc-container: split container build and activation phases

This commit is contained in:
Astro 2021-11-18 16:58:32 +01:00
parent 9c63bd996f
commit f7dabd8e2d
1 changed files with 6 additions and 2 deletions

View File

@ -122,8 +122,12 @@ let
mkdir -p /var/lib/lxc/$c/rootfs/$d mkdir -p /var/lib/lxc/$c/rootfs/$d
done done
ln -fs $SYSTEM/init /var/lib/lxc/$c/rootfs/init ln -fs $SYSTEM/init /var/lib/lxc/$c/rootfs/init
done
set +e # Activate all the desired container after all of them are
# built
set +e
for c in $@; do
active=$(systemctl is-active lxc@$c) active=$(systemctl is-active lxc@$c)
if [[ "$active" = active ]] ; then if [[ "$active" = active ]] ; then
echo Activating $c echo Activating $c
@ -135,8 +139,8 @@ let
echo Starting $c echo Starting $c
systemctl start lxc@$c systemctl start lxc@$c
fi fi
set -e
done done
set -e
''; '';
enable-script = pkgs.writeScriptBin "enable-containers" '' enable-script = pkgs.writeScriptBin "enable-containers" ''