Last active
September 16, 2024 13:59
-
-
Save scottj/ff343a1e9843fe1ecd5fc41b6ddaaef1 to your computer and use it in GitHub Desktop.
Update AWS CLI
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
#!/usr/bin/env bash | |
URL=https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip | |
AWS=/usr/local/aws-cli | |
BIN=/usr/local/bin | |
TMP=$(mktemp -d /tmp/update-awscli.XXXXXX) | |
ZIP=$TMP/awscli.zip | |
echo [+] Downloading $URL | |
curl -so $ZIP $URL | |
if [[ -e $ZIP ]]; then | |
echo [+] Extracting files | |
unzip -q $ZIP -d $TMP && rm $ZIP | |
echo [+] Comparing versions | |
if [[ -x $BIN/aws && -x $TMP/aws/dist/aws ]]; then | |
OLD=$($BIN/aws --version | cut -d\ -f1) | |
if [[ $OLD ]]; then | |
echo [+] Current Version: $OLD | |
fi | |
NEW=$($TMP/aws/dist/aws --version | cut -d\ -f1) | |
if [[ $OLD == $NEW ]]; then | |
echo [=] Already on the latest version | |
else | |
echo [+] Updated Version: $NEW | |
sudo $TMP/aws/install --bin-dir $BIN --install-dir $AWS --update | |
fi | |
else | |
echo [-] Error comparing files | |
fi | |
else | |
echo [-] Error downloading file | |
fi | |
echo [+] Cleaning up | |
rm -rf $TMP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment