-
Notifications
You must be signed in to change notification settings - Fork 10
/
install.sh
executable file
·65 lines (55 loc) · 1.82 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
#!/bin/sh
# Copyright (c) 2023-2024 Zerops s.r.o. All rights reserved. MIT license.
set -e
case $(uname -sm) in
"Darwin x86_64") target="darwin-amd64" ;;
"Darwin arm64") target="darwin-arm64" ;;
"Linux i386") target="linux-i386" ;;
*) target="linux-amd64" ;;
esac
if [ $# -eq 0 ]; then
zcli_uri="https://github.com/zeropsio/zcli/releases/latest/download/zcli-${target}"
else
zcli_uri="https://github.com/zeropsio/zcli/releases/download/${1}/zcli-${target}"
fi
bin_dir="$HOME/.local/bin"
bin_path="$bin_dir/zcli"
bin_dir_existed=1
if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
bin_dir_existed=0
# By default `~/.local/bin` isn't included in PATH if it doesn't exist
# First try `.bash_profile`. It doesn't exist by default, but if it does, `.profile` is ignored by bash
if [ "$(uname -s)" = "Linux" ]; then
if [ -f "$HOME/.bash_profile" ]; then
. "$HOME/.bash_profile"
elif [ -f "$HOME/.profile" ]; then
. "$HOME/.profile"
fi
fi
fi
curl --fail --location --progress-bar --output "$bin_path" "$zcli_uri"
chmod +x "$bin_path"
echo
echo "zCLI was installed successfully to '$bin_path'"
if command -v zcli >/dev/null; then
echo "Run 'zcli --help' to get started"
if [ "$bin_dir_existed" = 0 ]; then
echo "ℹ️ You may need to relaunch your shell."
fi
else
if [ "$(uname -s)" = "Darwin" ]; then
echo 'Add following line to the `/etc/paths` file and relaunch your shell.';
echo " $HOME/.local/bin"
echo
echo 'You can do so by running:'
echo "sudo sh -c 'echo \"$HOME/.local/bin\" >> /etc/paths'"
else
echo "Manually add the directory to your '$HOME/.profile' (or similar) and relaunch your shell."
echo ' export PATH="$HOME/.local/bin:$PATH"'
fi
echo
echo "Run '$bin_path --help' to get started"
fi
echo
echo "Stuck? Join our Discord https://discord.com/invite/WDvCZ54"