forked from terraform-linters/tflint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_linux.sh
executable file
·84 lines (73 loc) · 2.05 KB
/
install_linux.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash -e
processor=$(uname -m)
if [ "$processor" == "x86_64" ]; then
arch="amd64"
else
arch="386"
fi
case "$(uname -s)" in
Darwin*)
os="darwin_${arch}"
;;
MINGW64*)
os="windows_${arch}"
;;
MSYS_NT*)
os="windows_${arch}"
;;
*)
os="linux_${arch}"
;;
esac
echo "os=$os"
echo -e "\n\n===================================================="
get_latest_release() {
curl --silent "https://api.github.com/repos/terraform-linters/tflint/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
if [[ -z "${TFLINT_VERSION}" ]]; then
echo "Looking up the latest version ..."
version=$(get_latest_release)
else
version=${TFLINT_VERSION}
fi
echo "Downloading TFLint $version"
curl -L -o /tmp/tflint.zip "https://github.com/terraform-linters/tflint/releases/download/${version}/tflint_${os}.zip"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Failed to download tflint_${os}.zip"
exit $retVal
else
echo "Download was successfully"
fi
echo -e "\n\n===================================================="
echo "Unpacking /tmp/tflint.zip ..."
unzip -u /tmp/tflint.zip -d /tmp/
if [[ $os == "windows"* ]]; then
echo "Installing /tmp/tflint to /bin..."
mv /tmp/tflint /bin/
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Failed to install tflint"
exit $retVal
else
echo "tflint installed at /bin/ successfully"
fi
else
echo "Installing /tmp/tflint to /usr/local/bin..."
sudo mkdir -p /usr/local/bin
sudo install -b -c -v /tmp/tflint /usr/local/bin/
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Failed to install tflint"
exit $retVal
else
echo "tflint installed at /usr/local/bin/ successfully"
fi
fi
echo "Cleaning /tmp/tflint.zip and /tmp/tflint ..."
rm /tmp/tflint.zip /tmp/tflint
echo -e "\n\n===================================================="
echo "Current tflint version"
tflint -v