From cfa7e66a1f178a25fdcecb190718ca70a793a567 Mon Sep 17 00:00:00 2001 From: Benoit S Date: Sat, 6 Feb 2021 14:41:42 +0900 Subject: [PATCH] Add lxd-containers-upgrade script --- files/lxd-containers-upgrade.sh | 16 ++++++++++++++++ setup-base.py | 9 +++++++++ 2 files changed, 25 insertions(+) create mode 100644 files/lxd-containers-upgrade.sh diff --git a/files/lxd-containers-upgrade.sh b/files/lxd-containers-upgrade.sh new file mode 100644 index 0000000..deef739 --- /dev/null +++ b/files/lxd-containers-upgrade.sh @@ -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 diff --git a/setup-base.py b/setup-base.py index f033d77..c30c0b1 100644 --- a/setup-base.py +++ b/setup-base.py @@ -127,3 +127,12 @@ systemd.service( 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', +) +