-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall.sh
executable file
·83 lines (72 loc) · 2.3 KB
/
install.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
#!/bin/sh
set -e
if ! command -v tar >/dev/null; then
echo "Error: tar is required to install jsctl" 1>&2
exit 1
fi
if ! command -v curl >/dev/null; then
echo "Error: curl is required to install jsctl" 1>&2
exit 1
fi
if [ "$OS" = "Windows_NT" ]; then
if [ -z "$PROCESSOR_ARCHITEW6432" ]; then
arch="$PROCESSOR_ARCHITECTURE"
else
arch="$PROCESSOR_ARCHITEW6432"
fi
case $arch in
"AMD64") target="jsctl-windows-amd64" ;;
"ARM64") target="jsctl-windows-arm64" ;;
*)
echo "Error: Unsupported windows achitecture: ${arch}" 1>&2
exit 1 ;;
esac
target_file="jsctl.exe"
else
case $(uname -sm) in
"Darwin x86_64") target="jsctl-darwin-amd64" ;;
"Darwin arm64") target="jsctl-darwin-arm64" ;;
"Linux x86_64") target="jsctl-linux-amd64" ;;
"Linux aarch64") target="jsctl-linux-arm64" ;;
*)
echo "Error: Unsupported operating system or architecture: $(uname -sm)" 1>&2
exit 1 ;;
esac
target_file="jsctl"
fi
jsctl_uri="https://github.com/jetstack/jsctl/releases/latest/download/${target}.tar.gz"
jsctl_install="${JSCTL_INSTALL:-$HOME/.jsctl}"
bin_dir="$jsctl_install/bin"
bin="$bin_dir/$target_file"
if current_install=$( command -v jsctl ) && [ ! -x "$bin" ] && [ "$current_install" != "$bin" ]; then
echo "failed to install jsctl to \"$bin\"" >&2
echo "jsctl is already installed in another location: \"$current_install\"" >&2
exit 1
fi
if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
fi
curl --fail --location --progress-bar --output "$bin.tar.gz" "$jsctl_uri"
tar xfO "$bin.tar.gz" "$target/$target_file" > "$bin"
chmod +x "$bin"
rm "$bin.tar.gz"
echo "jsctl was installed successfully to $bin"
if command -v jsctl >/dev/null; then
echo "Run 'jsctl --help' to get started"
else
if [ "$SHELL" = "/bin/zsh" ] || [ "$ZSH_NAME" = "zsh" ]; then
shell_profile=".zshrc"
else
shell_profile=".bashrc"
fi
echo
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
echo " export JSCTL_INSTALL=\"$jsctl_install\""
echo " export PATH=\"\$JSCTL_INSTALL/bin:\$PATH\""
echo
echo "And run \"source $HOME/$shell_profile\" to update your current shell"
echo
echo "Run '$bin --help' to get started"
fi
echo
echo "Checkout https://platform.jetstack.io/documentation for more information"