Skip to content

Instantly share code, notes, and snippets.

@jadwigo
Last active October 31, 2023 06:56
Show Gist options
  • Save jadwigo/439ae1d2414ac3c14d47d1fa43fbf2ca to your computer and use it in GitHub Desktop.
Save jadwigo/439ae1d2414ac3c14d47d1fa43fbf2ca to your computer and use it in GitHub Desktop.
Ubuntu autoupdates (nala)
#!/bin/sh
echo "== Check required programs =="
if ! [ -x "$(command -v nala)" ]; then
echo 'Error: NALA is not installed. Please install it with "apt install nala"' >&2
exit 1
fi
if ! [ -x "$(command -v snap)" ]; then
echo 'Error: SNAP is not installed. Please install it with "nala install snap"' >&2
exit 1
fi
if ! [ -x "$(command -v flatpak)" ]; then
echo 'Error: FLATPAK is not installed. Please add it with "nala install flatpak' >&2
exit 1
fi
echo "== refreshing software sources =="
# apt update
nala update
echo "== upgradable packages =="
# apt list --upgradable
nala list --upgradable
echo "== running upgrades with nala =="
nala upgrade -y
echo "== cleaning up old stuff =="
nala autoremove -y
echo "== show snaps that can be updated =="
snap refresh --list
echo "== snap refresh =="
snap refresh
echo "== flatpak updates =="
flatpak update -y
echo "== display system information =="
neofetch
echo "== check if reboot is needed =="
if [ -f /var/run/reboot-required ]
then
cat /var/run/reboot-required
fi
echo "== autoupdate script complete =="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment