From fb1d46efc650099bdc9536991ec905405d791fef Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 21 May 2024 14:57:15 -0600 Subject: add aws cli tools installer --- scripts/bin/_aws_cli_installer_upgrader.sh | 76 ++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 scripts/bin/_aws_cli_installer_upgrader.sh (limited to 'scripts/bin') diff --git a/scripts/bin/_aws_cli_installer_upgrader.sh b/scripts/bin/_aws_cli_installer_upgrader.sh new file mode 100755 index 0000000..5aeb125 --- /dev/null +++ b/scripts/bin/_aws_cli_installer_upgrader.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash + +# +# This script is duplicated in aws.org notes +# + +set -x + +INSTALL_DIR=${HOME}/.local +BIN_DIR=${HOME}/bin + +create_choices_file(){ + cat< /tmp/awschoices.xml + + + + + + choiceAttribute + customLocation + attributeSetting + ${INSTALL_DIR} + choiceIdentifier + default + + + +EOF +} + +cleanup_choices_file(){ + rm /tmp/awschoices.xml +} +install_awscli() { + curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "/tmp/AWSCLIV2.pkg" \ + && installer -pkg /tmp/AWSCLIV2.pkg \ + -target CurrentUserHomeDirectory \ + -applyChoiceChangesXML /tmp/awschoices.xml \ + && ln -sf ${INSTALL_DIR}/aws-cli/aws ${BIN_DIR}/aws \ + && ln -sf ${INSTALL_DIR}/aws-cli/aws_completer ${BIN_DIR}/aws_completer + + rm /tmp/AWSCLIV2.pkg +} +install_samcli() { + curl -L "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-macos-arm64.pkg" -o "/tmp/AWS_SAM_CLI.pkg" \ + && installer -pkg /tmp/AWS_SAM_CLI.pkg \ + -target CurrentUserHomeDirectory \ + -applyChoiceChangesXML /tmp/awschoices.xml \ + && ln -sf ${INSTALL_DIR}/aws-sam-cli/sam ${BIN_DIR}/sam + + rm /tmp/AWS_SAM_CLI.pkg +} + + +create_choices_file + +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + --sam) + install_samcli + shift # past argument + ;; + --cli) + install_awscli + shift # past argument + ;; + *) + echo -e "Skipping unknown argument: $1." + shift + ;; + esac +done + +cleanup_choices_file -- cgit v1.2.1