Skip to content

Commit

Permalink
#908 AWS CLI integration for MacOS, bugfixes for Windows and Linux (#909
Browse files Browse the repository at this point in the history
)
  • Loading branch information
CREITZ25 authored Oct 14, 2022
1 parent 8e5a026 commit 6d15e58
Showing 1 changed file with 38 additions and 17 deletions.
55 changes: 38 additions & 17 deletions scripts/src/main/resources/scripts/command/aws
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,29 @@ source "$(dirname "${0}")"/../functions
# Call aws with specified arguments.
function doRun() {
doSetup silent
doRunCommand "aws ${*}"
findAws
doRunCommand "'${AWS}' ${*}"
}


# OS independent check if aws is installed.
function doIsAwsInstalled() {
function findAws() {
AWS="aws"
AWS_INSTALLED="no"
if command -v aws &> /dev/null
then
return
else
return 255
then
AWS_INSTALLED="yes"
elif doIsWindows
then
local aws_win
aws_win="${PROGRAMFILES}"
aws_win="$(cygpath "${aws_win}")"
aws_win="${aws_win}/Amazon/AWSCLIV2/aws"
if [ -f "${aws_win}" ]
then
AWS="${aws_win}"
AWS_INSTALLED="yes"
fi
fi
}

Expand All @@ -45,17 +57,23 @@ function doPackageInstall()
powershell.exe -Command "Start-Process msiexec.exe -verb runas -Wait -ArgumentList '/I ${windows_path_to_package}\aws-${version}-windows.msi /quiet'"
elif doIsMacOs
then
doFail "Sorry, AWS CLI installation support is not yet implemented for your OS. Please install manually or help devonfw-ide to support it for your OS by contributing a pull-request."
doEcho "Installing AWS for MacOS..."
sudo installer -pkg "${path_to_package}"/aws-"${version}"-mac.pkg -target /
else
doEcho "Installating AWS for Linux..."
doRunCommand "sudo ${path_to_package}/install"
if [ -L "/usr/local/bin/aws" ]
then
doRunCommand "sudo ${path_to_package}/install -u"
else
doRunCommand "sudo ${path_to_package}/install"
fi
fi
doRunCommand "rm -rf ${path_to_package}"
}

function doSetup() {

if [[ $(command -v aws) != "/c/Program Files/Amazon/AWSCLIV2/aws" ]] || [ "${1}" != "silent" ]
local ERR=""
findAws
if [[ ${AWS_INSTALLED} != "yes" ]] || [[ "${1}" != "silent" ]]
then
# Get leatest release
if [ -z "${AWS_VERSION}" ]
Expand All @@ -64,28 +82,31 @@ function doSetup() {
AWS_VERSION=$(curl "https://github.com/aws/aws-cli/tags" | awk -F'tags/' '/archive/ { print $2}' | sort -r | head -1 | awk -F'.zip' '{print $1}')
fi

doInstall "-" "${DEVON_IDE_HOME}/updates/install/aws" "aws" "${AWS_VERSION}"
if [ "${?}" = 0 ]
doInstall "-" "${DEVON_IDE_HOME}/updates/install/aws" "aws" "${AWS_VERSION}"
ERR="${?}"
if [ "${ERR}" = "0" ]
then
doPackageInstall "${DEVON_IDE_HOME}/updates/install/aws" "${AWS_VERSION}"
doPackageInstall "${DEVON_IDE_HOME}/updates/install/aws" "${AWS_VERSION}"
fi
doRunCommand "rm -rf ${DEVON_IDE_HOME}/updates/install/aws"

if [ "${1}" != "silent" ] && ! doIsQuiet
then
doEcho "logon again to test aws with \"aws --version\""
fi
fi
fi
}


# CLI
case ${1} in
case ${1} in
"help" | "-h")
echo "Setup or run AWS CLI (command-line interface for Amazon-Web-Services)."
echo
echo "Arguments:"
echo " setup install aws on your machine."
echo " «args» call aws with the specified arguments. Call aws --help for details or use aws directly as preferred."
echo " «args» call aws with the specified arguments. Call aws --help for details or use aws directly as preferred."
echo
;;
"setup" | "s" | "")
doSetup
Expand Down

0 comments on commit 6d15e58

Please sign in to comment.