Last active
February 19, 2018 16:12
-
-
Save seamyd/ba7d444d8d053ad144a17230e149e14d to your computer and use it in GitHub Desktop.
Spectre / Meltdown upgrade remote
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 | |
POSITIONAL=() | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" | |
case $key in | |
-r|--remote) | |
REMOTE="$2" | |
shift | |
shift | |
;; | |
-u|--user) | |
USER="$2" | |
shift | |
shift | |
;; | |
*) | |
POSITIONAL+=("$1") | |
shift | |
;; | |
esac | |
done | |
set -- "${POSITIONAL[@]}" | |
ssh -T "${USER}"@"${REMOTE}" << EOSSH | |
/usr/lib/update-notifier/apt-check 2>&1 | cut -d ';' -f 1,2 | |
sudo uname -a | |
sudo cat /etc/lsb-release | |
EOSSH | |
ssh -T "${USER}"@"${REMOTE}" "sudo bash -s" < ./spectre-meltdown-checker.sh | |
echo "Do you wish to update kernel?" | |
select yn in "Yes" "No"; do | |
case $yn in | |
Yes ) ssh -T "${USER}"@"${REMOTE}" "sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install linux-generic linux-headers-generic linux-image-generic"; break;; | |
No ) exit;; | |
esac | |
done | |
echo "Do you wish to reboot remote?" | |
select yn in "Yes" "No"; do | |
case $yn in | |
Yes ) ssh -T "${USER}"@"${REMOTE}" "sudo reboot now"; break;; | |
No ) exit;; | |
esac | |
done | |
((no_of_tries = 60)) | |
while [[ $no_of_tries -ne 0 ]] ; do | |
echo "Trying to reconnect..... $no_of_tries" | |
ping -c 1 -W 2 $REMOTE > /dev/null | |
rc=$? | |
if [[ $rc -eq 0 ]] ; then | |
sleep 5 | |
echo "Reconnected to $REMOTE" | |
((no_of_tries = 1)) | |
fi | |
((no_of_tries = no_of_tries - 1)) | |
done | |
ssh -T "${USER}"@"${REMOTE}" "sudo bash -s" < ./spectre-meltdown-checker.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The spectre-meltdown checker script can be found here:
https://github.com/speed47/spectre-meltdown-checker