-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·93 lines (76 loc) · 2.64 KB
/
install.sh
File metadata and controls
executable file
·93 lines (76 loc) · 2.64 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
#!/bin/sh
set -e
main() {
cronx_install="${CRONX_INSTALL:-$HOME/.cronx}"
bin_dir="$cronx_install/bin"
bin_suffix=""
if [ "$OS" = "Windows_NT" ]; then # WSL or Git Bash or Cygwin
bin_suffix=".exe"
target="win-amd64"
else
case $(uname -sm) in
"Darwin x86_64") target="mac-amd64" ;;
"Darwin arm64") target="mac-arm64" ;;
"Linux aarch64")
target="linux-arm64"
;;
"Linux x86_64")
target="linux-amd64"
;;
*)
target="linux-amd64"
esac
fi
if ! command -v unzip >/dev/null; then
echo "Error: unzip is required to install and upgrade cronx!" 1>&2
exit 1
fi
cronx_uri="https://github.com/polyseam/cronx/releases/latest/download/cronx-${target}.tar.gz"
exe="$bin_dir/cronx"
if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
fi
curl --fail --location --progress-bar --output "$exe.tar.gz" "$cronx_uri"
tar -xzf "$exe.tar.gz" -C "$bin_dir"
chmod +x "$exe"
rm "$exe.tar.gz"
echo "cronx was downloaded successfully to $exe"
# set shell profile for user shell
case "$SHELL" in
/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".profile" ;;
esac
# if $cronx_install is not in $PATH
if ! command -v cronx >/dev/null; then
# if $cronx_install is not in $shell_profile
if ! grep -q "$bin_dir" "$HOME/$shell_profile"; then
echo "adding $bin_dir to \$PATH"
command printf '\nexport PATH="%s:$PATH"' "$bin_dir" >>"$HOME/$shell_profile"
fi
fi
# if $shell_profile is .zshrc exit because sourcing it will cause an error
if [ "$shell_profile" = ".zshrc" ]; then
echo "finalizing installation..."
# running 'cronx --help' will save the user wait time on first run
$exe --help
echo
echo "cronx was installed successfully! Please restart your terminal."
echo "Need some help? Join our Discord https://cndi.run/di?utm_id=5119"
echo
exit 0
fi
# source $shell_profile
if [ -f "$HOME/$shell_profile" ]; then
echo "sourcing $HOME/$shell_profile"
. "$HOME/$shell_profile"
echo "finalizing installation..."
# running 'cronx --help' will save the user wait time on first run
$exe --help
echo
echo "cronx was installed successfully! Please restart your terminal."
echo "Need some help? Join our Discord https://cndi.run/di?utm_id=5119"
echo
exit 0
fi
}
main "$@"