install-ubuntu-awscli.sh 907 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. # This script must be run as root
  8. if [[ $EUID -ne 0 ]]
  9. then
  10. echo "This script must be run as root (sudo)"
  11. exit 1
  12. fi
  13. #
  14. # Install curl if its not installed
  15. #
  16. curl --version >/dev/null 2>&1
  17. if [ $? -ne 0 ]
  18. then
  19. echo "Installing curl"
  20. apt-get install curl -y
  21. fi
  22. #
  23. # Setup AWS CLI if needed
  24. #
  25. aws --version >/dev/null 2>&1
  26. if [ $? -ne 0 ]
  27. then
  28. echo Setting up AWS CLI
  29. curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
  30. unzip awscliv2.zip
  31. ./aws/install
  32. rm -rf ./aws
  33. else
  34. AWS_CLI_VERSION=$(aws --version | awk '{print $1}' | awk -F/ '{print $2}')
  35. echo AWS CLI \(version $AWS_CLI_VERSION\) already installed
  36. fi