-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·86 lines (73 loc) · 2.45 KB
/
install.sh
File metadata and controls
executable file
·86 lines (73 loc) · 2.45 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
#!/usr/bin/env bash
# One-click installer for deepinspect-cli.
#
# Usage (from a local clone):
# ./install.sh
#
# Usage (remote one-liner):
# curl -fsSL https://raw.githubusercontent.com/switchontech/deepinspect-cli/main/install.sh | bash
set -euo pipefail
REPO_URL="${DEEPINSPECT_CLI_REPO:-https://github.com/switchontech/deepinspect-cli.git}"
CLI_DIR="${DEEPINSPECT_CLI_DIR:-$HOME/.deepinspect-cli}"
BRANCH="${DEEPINSPECT_CLI_BRANCH:-main}"
say() { printf '\033[36m›\033[0m %s\n' "$*"; }
ok() { printf '\033[32m✓\033[0m %s\n' "$*"; }
err() { printf '\033[31m✗\033[0m %s\n' "$*" >&2; }
if [[ "$(uname -s)" != "Linux" ]]; then
err "deepinspect-cli supports Linux only. Detected: $(uname -s)."
exit 1
fi
need() {
if ! command -v "$1" >/dev/null 2>&1; then
err "Required binary '$1' not found on PATH. Install it and retry."
exit 1
fi
}
need git
need node
need npm
NODE_MAJOR=$(node --version | sed -E 's/^v([0-9]+).*/\1/')
if (( NODE_MAJOR < 18 )); then
err "Node.js >= 18 required (found $(node --version))."
exit 1
fi
# Clone or update the CLI repo into a stable location
if [[ -d "$CLI_DIR/.git" ]]; then
say "Updating existing clone at $CLI_DIR"
git -C "$CLI_DIR" fetch --all --prune
git -C "$CLI_DIR" checkout "$BRANCH"
git -C "$CLI_DIR" pull --ff-only
else
say "Cloning $REPO_URL into $CLI_DIR"
git clone --branch "$BRANCH" "$REPO_URL" "$CLI_DIR"
fi
say "Installing npm dependencies"
(cd "$CLI_DIR" && npm install --omit=dev --no-audit --no-fund)
# Install the `deepinspect` binary on PATH.
BIN_SRC="$CLI_DIR/bin/deepinspect.js"
chmod +x "$BIN_SRC"
install_link() {
local target_dir="$1"
local link="$target_dir/deepinspect"
mkdir -p "$target_dir"
ln -sf "$BIN_SRC" "$link"
ok "Linked $link → $BIN_SRC"
}
if [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then
install_link "$HOME/.local/bin"
elif [[ -w "/usr/local/bin" ]]; then
install_link "/usr/local/bin"
elif command -v sudo >/dev/null 2>&1; then
say "Linking into /usr/local/bin (needs sudo)"
sudo ln -sf "$BIN_SRC" /usr/local/bin/deepinspect
ok "Linked /usr/local/bin/deepinspect → $BIN_SRC"
else
install_link "$HOME/.local/bin"
say "Add to your shell rc: export PATH=\"\$HOME/.local/bin:\$PATH\""
fi
ok "deepinspect-cli installed."
echo
echo "Next steps:"
echo " deepinspect install # clones local-training-app (default branch: develop)"
echo " deepinspect start # start the app"
echo " deepinspect doctor # diagnose issues"