blob: d41d75a8a88e91db88731efc841f81cfd1700049 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#!/usr/bin/env bash
#
# This script is duplicated in aws.org notes
#
[[ uname != "Darwin" ]] && echo "OSX Only"; exit 1
set -x
INSTALL_DIR=${HOME}/.local
BIN_DIR=${HOME}/bin
create_choices_file(){
cat<<EOF > /tmp/awschoices.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>choiceAttribute</key>
<string>customLocation</string>
<key>attributeSetting</key>
<string>${INSTALL_DIR}</string>
<key>choiceIdentifier</key>
<string>default</string>
</dict>
</array>
</plist>
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
|