Skip to content

Instantly share code, notes, and snippets.

@Gestas
Last active November 27, 2022 18:40
Show Gist options
  • Save Gestas/4c673119f1a1550b7f7d0d5fd6e224f6 to your computer and use it in GitHub Desktop.
Save Gestas/4c673119f1a1550b7f7d0d5fd6e224f6 to your computer and use it in GitHub Desktop.
Ubuntu full update
#! /bin/bash
# Update an Ubuntu instance
set -e
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as sudo/root"
exit 1
fi
do_apt () {
if ! command -v apt &> /dev/null
then
echo '"apt" not found, skipping "update, upgrade, autoremove"'
return
else
echo "Running apt..."
apt update
apt upgrade
apt autoremove
fi
}
do_snap () {
if ! command -v snap &> /dev/null
then
echo '"snap" not found, skipping "snap refresh"'
return
else
echo "Running snap..."
snap refresh
fi
}
do_flatpak () {
if ! command -v flatpak &> /dev/null
then
echo '"flatpak" not found, skipping "flatpak update"'
return
else
echo "Running flatpak..."
flatpak update
fi
}
do_fwupdmgr () {
if ! command -v fwupdmgr &> /dev/null
then
echo '"fwupdmgr" not found, skipping "get-updates, update"'
return
else
echo "Running fwupdmgr..."
fwupdmgr get-updates
fwupdmgr update
fi
}
do_apt
do_snap
do_flatpak
do_fwupdmgr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment