This repository has been archived on 2025-02-14. You can view files and clone it, but cannot push or open issues or pull requests.
pyinfra-lxd/files/lxd-containers-upgrade.sh
2021-02-06 14:41:42 +09:00

16 lines
481 B
Bash

#!/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