Skip to content

Instantly share code, notes, and snippets.

@Elycin
Last active April 18, 2022 08:54
Show Gist options
  • Save Elycin/994cee6f0dd287901f06c2768e7cefd2 to your computer and use it in GitHub Desktop.
Save Elycin/994cee6f0dd287901f06c2768e7cefd2 to your computer and use it in GitHub Desktop.
Proxmox updater
#!/usr/bin/env bash
function update_container {
if command -v apt-get &> /dev/null
then
echo "apt-get detected"
apt-get update
apt-get upgrade -y
apt-get autoremove -y
apt-get clean
exit
fi
if command -v dnf &> /dev/null
then
echo "dandified yum detected"
dnf upgrade -y
exit
fi
if command -v apk &> /dev/null
then
echo "alpine linux detected"
apk update
exit
fi
}
function host {
for i in $(pct list | awk '/[0-9]/{print $1}' ); do pct exec $i -- wget -O /tmp/file.sh https://gist.githubusercontent.com/Elycin/994cee6f0dd287901f06c2768e7cefd2/raw/caedbdad7532e352b6297950921234c5eb88ae31/update.sh; done;
for i in $(pct list | awk '/[0-9]/{print $1}' ); do pct exec $i -- bash /tmp/file.sh; done;
}
if [ -d "/etc/pve" ]
then
echo "Proxmox host detected, running download command on each container."
host
else
echo "Container detected, running update sequence."
update_container
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment