forked from wallix/awless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getawless.sh
executable file
·60 lines (47 loc) · 1.44 KB
/
getawless.sh
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
#!/bin/bash
set -e
# Download latest awless binary from Github
ARCH_UNAME=`uname -m`
if [[ "$ARCH_UNAME" == "x86_64" ]]; then
ARCH="amd64"
else
ARCH="386"
fi
EXT="tar.gz"
if [[ "$OSTYPE" == "linux-gnu" ]]; then
OS="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="darwin"
elif [[ "$OSTYPE" == "win32" ]] || [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] ; then
OS="windows"
EXT="zip"
else
echo "No awless binary available for OS '$OSTYPE'. You may want to use go to install awless with 'go get -u github.com/wallix/awless'"
exit
fi
LATEST_VERSION=`curl -fs https://updates.awless.io | grep -oE "v[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"`
FILENAME=awless-$OS-$ARCH.$EXT
DOWNLOAD_URL="https://github.com/wallix/awless/releases/download/$LATEST_VERSION/$FILENAME"
echo "Downloading awless from $DOWNLOAD_URL"
if ! curl --fail -o $FILENAME -L $DOWNLOAD_URL; then
exit
fi
echo ""
echo "extracting $FILENAME to ./awless"
if [[ "$OS" == "windows" ]]; then
echo 'y' | unzip $FILENAME 2>&1 > /dev/null
else
tar -xzf $FILENAME
fi
echo "removing $FILENAME"
rm $FILENAME
chmod +x ./awless
echo ""
echo "awless successfully installed to ./awless"
echo ""
echo "don't forget to add it to your path, with, for example, 'sudo mv awless /usr/local/bin/' "
echo ""
echo "then, for autocompletion, run:"
echo " [bash] echo 'source <(awless completion bash)' >> ~/.bashrc"
echo " OR"
echo " [zsh] echo 'source <(awless completion zsh)' >> ~/.zshrc"