|
|
@ -42,6 +42,29 @@ function prepare_lxd { |
|
|
|
fi |
|
|
|
|
|
|
|
sudo /opt/miaou-bash/tools/idem_apt_install lxd btrfs-progs |
|
|
|
|
|
|
|
sudo tee /etc/systemd/system/lxd-containers-restart-on-failure.service &>/dev/null <<EOF |
|
|
|
[Unit] |
|
|
|
Description=restart lxd containers when no dhclient |
|
|
|
After=lxd.service lxd-containers.service |
|
|
|
Requires=lxd.socket |
|
|
|
StartLimitInterval=60 |
|
|
|
StartLimitBurst=5 |
|
|
|
|
|
|
|
[Service] |
|
|
|
Type=exec |
|
|
|
|
|
|
|
ExecCondition=sh -c '[ \$(lxc list status=running -c4 -fcsv | wc -l) -gt 0 ]] && lxc list status=running -c4 -fcsv | grep -vq eth0' |
|
|
|
ExecStart=systemctl restart lxd-containers.service |
|
|
|
ExecStartPost=sh -c 'sleep 2 ; [ \$(lxc list status=running -c4 -fcsv | wc -l) -eq 0 ]] || lxc list status=running -c4 -fcsv | grep -q eth0' |
|
|
|
|
|
|
|
Restart=on-failure |
|
|
|
RestartSec=10 |
|
|
|
|
|
|
|
[Install] |
|
|
|
WantedBy=multi-user.target |
|
|
|
EOF |
|
|
|
sudo systemctl daemon-reload |
|
|
|
} |
|
|
|
|
|
|
|
function configure_lxd { |
|
|
|