aboutsummaryrefslogtreecommitdiff
path: root/adu-upgrade
diff options
context:
space:
mode:
authorAdam Spragg <adam@spra.gg>2022-03-16 15:05:09 +0000
committerAdam Spragg <adam@spra.gg>2022-03-16 15:05:09 +0000
commit4c4291d40daf4eb235faf89c7832f6c389607ce8 (patch)
treeb42beac501f834703a6a5b95e46c344b29886a62 /adu-upgrade
parentb673da10dbaab2a5109ca292c23260c0f643a3f5 (diff)
Exit scripts early if there's nothing to do
Diffstat (limited to 'adu-upgrade')
-rwxr-xr-xadu-upgrade7
1 files changed, 7 insertions, 0 deletions
diff --git a/adu-upgrade b/adu-upgrade
index d12b57f..81f6e90 100755
--- a/adu-upgrade
+++ b/adu-upgrade
@@ -34,6 +34,13 @@ fi
# the update script to avoid reboot loops in case the update fails."
rm -f -- "${UPDATE_SYMLINK}"
+upgrades=$(apt -qq list --upgradeable 2>/dev/null | wc -l)
+if [ "$upgrades" -eq 0 ]; then
+ echo "Nothing to do? Rebooting..."
+ systemctl reboot
+ exit 0
+fi
+
# Do the update
apt-get upgrade -y --no-download --ignore-missing