Last active
October 4, 2023 07:26
-
-
Save JoshSalway/594108f4d388c733806d112af90b0695 to your computer and use it in GitHub Desktop.
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/zsh | |
install_aws_cli () { | |
echo "Downloading AWS CLI..." | |
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" | |
echo "Installing AWS CLI..." | |
sudo installer -pkg AWSCLIV2.pkg -target / | |
rm -f AWSCLIV2.pkg | |
echo "Package file deleted successfully!" | |
echo "AWS CLI installed successfully!" | |
} | |
echo "Checking current AWS CLI version..." | |
if ! command -v aws &> /dev/null; then | |
echo "AWS CLI not installed. Installing now..." | |
install_aws_cli | |
else | |
current_version=$(aws --version 2>&1 | grep -oE 'aws-cli/[0-9]+\.[0-9]+\.[0-9]+' | cut -d'/' -f2) | |
echo "Current AWS CLI version: $current_version" | |
echo "Checking for the latest version..." | |
latest_version=$(curl -s https://raw.githubusercontent.com/aws/aws-cli/v2/CHANGELOG.rst | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n 1) | |
echo "Latest AWS CLI version: $latest_version" | |
if [[ "$latest_version" != "$current_version" ]]; then | |
echo "Upgrading AWS CLI..." | |
install_aws_cli | |
else | |
echo "AWS CLI is already up to date. No upgrade necessary." | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output: