-
Notifications
You must be signed in to change notification settings - Fork 407
Expand file tree
/
Copy pathinstall_linux.sh
More file actions
executable file
·100 lines (85 loc) · 2.66 KB
/
Copy pathinstall_linux.sh
File metadata and controls
executable file
·100 lines (85 loc) · 2.66 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
set -e
set -o pipefail
echo "===================================================="
echo "WARNING!"
echo
echo "This automated installation script will be removed"
echo "on Sep 1, 2026. To mitigate supply chain risks,"
echo "please do not run any unpinned downloaded scripts."
echo "===================================================="
echo
get_machine_arch () {
machine_arch=""
case $(uname -m) in
i386) machine_arch="386" ;;
i686) machine_arch="386" ;;
x86_64) machine_arch="amd64" ;;
arm64|aarch64) machine_arch="arm64" ;;
esac
echo $machine_arch
}
arch=$(get_machine_arch)
echo "arch=$arch"
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===================================================="
download_path=$(mktemp -d -t tflint.XXXXXXXXXX)
download_zip="${download_path}/tflint.zip"
download_executable="${download_path}/tflint"
if [ -z "${TFLINT_VERSION}" ] || [ "${TFLINT_VERSION}" == "latest" ]; then
echo "Downloading latest TFLint version"
download_url="https://github.com/terraform-linters/tflint/releases/latest/download/tflint_${os}.zip"
else
echo "Downloading TFLint $TFLINT_VERSION"
download_url="https://github.com/terraform-linters/tflint/releases/download/${TFLINT_VERSION}/tflint_${os}.zip"
fi
curl --fail -sS -L -o "${download_zip}" "${download_url}"
echo "Downloaded successfully"
echo -e "\n\n===================================================="
echo "Unpacking ${download_zip} ..."
unzip -o "${download_zip}" -d "${download_path}"
if [[ $os == "windows"* ]]; then
dest="${TFLINT_INSTALL_PATH:-/bin}/"
echo "Installing ${download_executable} to ${dest} ..."
mv "${download_executable}" "$dest"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Failed to install tflint"
exit $retVal
else
echo "tflint installed at ${dest} successfully"
fi
else
dest="${TFLINT_INSTALL_PATH:-/usr/local/bin}/"
echo "Installing ${download_executable} to ${dest} ..."
if [[ -w "$dest" ]]; then SUDO=""; else
# current user does not have write access to install directory
SUDO="sudo";
fi
$SUDO mkdir -p "$dest"
$SUDO install -c -v "${download_executable}" "$dest"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "Failed to install tflint"
exit $retVal
fi
fi
echo "Cleaning temporary downloaded files directory ${download_path} ..."
rm -rf "${download_path}"
echo -e "\n\n===================================================="
echo "Current tflint version"
"${dest}/tflint" -v