This commit is contained in:
2023-12-20 16:32:38 +01:00
commit 02bbcc3878
4 changed files with 66 additions and 0 deletions

20
update-lxc-contaier.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
for i in $(lxc list type=container -c ns --format csv); do
echo $(date) "- Updating ${i%,*} container..."
if [ "${i#*,}" == "STOPPED" ]; then
echo $(date) "- Start container"
lxc start ${i%,*}
sleep 5
else
echo $(date) "- Container is already started"
fi
lxc exec ${i%,*} -- sh -c "apt update"
sleep 5
lxc exec ${i%,*} -- sh -c "apt upgrade -y"
sleep 5
if [ "${i#*,}" == "STOPPED" ]; then
echo $(date) "- Stop container"
lxc stop ${i%,*}
fi
done