-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
65 lines (57 loc) · 1.9 KB
/
install.sh
File metadata and controls
65 lines (57 loc) · 1.9 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
#!/bin/sh
# Based on Deno installer. Copyright 2019 the Deno authors. All rights reserved. MIT license.
# TODO(everyone): Keep this script simple and easily auditable.
set -e
if [ "$OS" = "Windows_NT" ]; then
target="windows"
echo "Windows is not supported at the moment, sorry" >&2
exit 1
else
case $(uname -sm) in
"Darwin x86_64")
target="macos"
;;
"Darwin arm64")
target="macos"
;;
*)
target="linux"
;;
esac
fi
if [ $# -eq 0 ]; then
SOURCE_URI="https://github.com/deepinfra/deepctl/releases/latest/download/deepctl-${target}"
else
SOURCE_URI="https://github.com/deepinfra/deepctl/releases/download/${1}/deepctl-${target}"
fi
EXE_NAME="${DEEPCTL_EXE_NAME:-deepctl}"
DEEPCTL_INSTALL="${DEEPCTL_INSTALL:-/usr/local/bin}"
EXE_TARGET="$DEEPCTL_INSTALL/$EXE_NAME"
if [ "${DEEPCTL_INSTALL#$HOME}" != "$DEEPCTL_INSTALL" ]; then
# assume subdirs of $HOME are writable without sudo
MAYSUDO="env --"
else
# assume everything outside $HOME requires sudo
echo
echo "You may be prompted for sudo password to write $EXE_TARGET"
echo "To change the install folder you can set \$DEEPCTL_INSTALL:"
echo " curl https://deepinfra.com/get.sh | DEEPCTL_INSTALL=another/dir sh"
echo
MAYSUDO="sudo"
fi
if [ ! -d "$DEEPCTL_INSTALL" ]; then
$MAYSUDO mkdir -p "$DEEPCTL_INSTALL"
fi
$MAYSUDO curl --fail --location --progress-bar --output "$EXE_TARGET" "$SOURCE_URI"
$MAYSUDO chmod +x "$EXE_TARGET"
echo "deepctl was installed successfully to $EXE_TARGET"
if ! command -v "$EXE_NAME" >/dev/null; then
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".bashrc" ;;
esac
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
echo " echo 'export PATH=\"$DEEPCTL_INSTALL:\$PATH\"' >> \$HOME/$shell_profile"
echo " export PATH=\"$DEEPCTL_INSTALL:\$PATH\""
fi
echo "Run '$EXE_NAME --help' to get started"