Add lxd-containers-upgrade script

This commit is contained in:
Benoit S 2021-02-06 14:41:42 +09:00
parent 7aa1de4c27
commit cfa7e66a1f
2 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
for i in $(lxc list --format csv -c n); do
lxc snapshot "$i"
if lxc exec "$i" -- which apt >/dev/null 2>&1; then
echo "Upgrading Debian/Ubuntu $i"
lxc exec "$i" -- apt update
lxc exec "$i" -- apt upgrade -y
fi
if lxc exec "$i" -- which pacman >/dev/null 2>&1; then
echo "Upgrading ArchLinux $i"
lxc exec "$i" -- sudo -u benpro yay -Sc --noconfirm
lxc exec "$i" -- sudo -u benpro yay -Syu --noconfirm
fi
done

View file

@ -127,3 +127,12 @@ systemd.service(
enabled=True, enabled=True,
) )
files.put(
name='Add lxd-containers-upgrade.sh',
src='files/lxd-containers-upgrade.sh',
dest='/usr/local/bin/lxd-containers-upgrade.sh',
user='root',
group='root',
mode='700',
)