Posted on 12-14-2020 03:13 PM
Ok, Let me preface this by first stating that scripting is NOT my strong point.
I'm attempting to install AWS CLI version 2 for all users per the instructions on:
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html#cliv2-mac-install-cmd
Attempting to run the commands via policy result in an exit code 127. I've found a few posts about AWSCLI version 1, but none of the solutions seem to work. Any suggestions?
Posted on 12-15-2020 11:41 PM
@rpayne Could you post your script, please?
Posted on 12-16-2020 12:23 AM
@rpayne Just put a rough script based on the AWS info.
#!/bin/bash
# download the AWSCLIV2.pkg to tmp folder and return the http_code
response=$(/usr/bin/curl --silent --write-out "%{http_code}" "https://awscli.amazonaws.com/AWSCLIV2.pkg" --output /tmp/AWSCLIV2.pkg)
checkForV1() {
# https://docs.aws.amazon.com/cli/latest/userguide/install-macos.html#install-macosos-bundled-uninstall
# Uninstall the AWS CLI version 1 bundled installer
# The bundled installer puts everything inside of the installation directory except the optional symlink, so to uninstall, you just need to delete those two items.
if [[ -d /usr/local/aws ]]; then
echo "AWD CLI version 1 found"
/bin/rm -rf /usr/local/aws
/bin/rm /usr/local/bin/aws
else
echo "AWD CLI version 1 not found"
fi
}
# check if the download was successful
if [[ $response -eq 200 ]]; then
echo "package downloaded"
# https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html
# Important
# AWS CLI versions 1 and 2 use the same aws command name. If you have both versions installed, your computer uses the first one found in your search path. If you previously installed AWS CLI version 1, we recommend that you do one of the following to use AWS CLI version 2:
# Recommended – Uninstall AWS CLI version 1 and use only AWS CLI version 2.
checkForV1
# install the package
/usr/sbin/installer -pkg /tmp/AWSCLIV2.pkg -target / || echo "Ops! Problem with the installer" ; exit 1
# clean up
/bin/rm /tmp/AWSCLIV2.pkg
else
echo "download error: $response"
# exit the curl download code so we can see in the Jamf reports where it is failing.
exit $response
fi
exit 0
Tested on 10.15.6 VM and looks OK
Posted on 05-25-2021 04:23 AM
@Mauricio Hey, thanks for the script.
I seem to be getting the following after it installs successfully.
Running script Install AWS CLI 2...
Script exit code: 1
Script result: package downloaded
AWD CLI version 1 not found
installer: Package name is AWS Command Line Interface
installer: Upgrading at base path /
installer: The upgrade was successful.
Error running script: return code was 1.
Posted on 05-25-2021 06:06 AM
@kissland Try to change the line of the installer.
from
/usr/sbin/installer -pkg /tmp/AWSCLIV2.pkg -target / || echo "Ops! Problem with the installer" ; exit 1
to
/usr/sbin/installer -pkg /tmp/AWSCLIV2.pkg -target /
You will be able to get the installer output in the log.
Hope that helps.
Regards
Posted on 05-25-2021 07:36 AM
@Mauricio Seems to work now, how can I check whether the $response returns anything? After running the script in terminal, when I run $response its just blank
Posted on 05-25-2021 11:08 PM
@kissland Not sure if I understand the question.
If you run the curl command in Terminal that variable will be available
If you run the script in the Terminal then the "package downloaded" is the clue that $response was 200, that variable is only available to the script.
Does it make sense?
Regards
Posted on 02-08-2024 07:21 AM
A lot has changed during this time, but just in case anyone goes to this post:
https://github.com/Installomator/Installomator <--- would be a good resource to use
awscli2)
# credit: Bilal Habib (@Pro4TLZZ)
name="AWSCLI"
type="pkg"
packageID="com.amazon.aws.cli2"
downloadURL="https://awscli.amazonaws.com/AWSCLIV2.pkg"
appNewVersion=$( curl -fs "https://raw.githubusercontent.com/aws/aws-cli/v2/CHANGELOG.rst" | grep -i "CHANGELOG" -a4 | grep "[0-9.]" )
expectedTeamID="94KV3E626L"
;;