Last active
August 29, 2015 13:57
-
-
Save n-st/9689820 to your computer and use it in GitHub Desktop.
Quickly update multiple remote Debian/Ubuntu systems.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Uncomment the next line to start any pending updates automatically: | |
#yes="--yes" | |
for host in host1 host2 # etc. | |
do | |
echo -e "\e[0;33m$host\e[0m" | |
ssh "$host" -t " | |
# Update package index if it's older than 24 hours. | |
test \$((\$(date +%s) - \$(stat -c %Y /var/cache/apt))) -gt $((24*60*60)) && sudo apt-get update; | |
# Simulate an update to check if something would be installed. If so, start a real update. | |
apt-get -s dist-upgrade | grep -E '[1-9]' -q && sudo apt-get dist-upgrade $yes" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment