Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·120 lines (102 loc) · 4.04 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·120 lines (102 loc) · 4.04 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/sh
set -eu
PROJECT_URL="https://github.com/ActivLayer/activlayer"
DEFAULT_SOURCE="$PROJECT_URL/archive/refs/heads/community-edition.zip"
SOURCE="${ACTIVLAYER_SOURCE:-$DEFAULT_SOURCE}"
INSTALL_ROOT="${ACTIVLAYER_INSTALL_ROOT:-$HOME/.local/share/activlayer}"
BIN_DIR="${ACTIVLAYER_BIN_DIR:-$HOME/.local/bin}"
PYTHON="${ACTIVLAYER_PYTHON:-python3}"
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
BOLD=$(printf '\033[1m')
VIOLET=$(printf '\033[35m')
CYAN=$(printf '\033[36m')
GREEN=$(printf '\033[32m')
DIM=$(printf '\033[2m')
RESET=$(printf '\033[0m')
else
BOLD=""
VIOLET=""
CYAN=""
GREEN=""
DIM=""
RESET=""
fi
fail() {
printf '\n%sInstallation failed%s\n %s\n' "$BOLD" "$RESET" "$1" >&2
exit 1
}
step() {
printf '%s%s[%s]%s %s\n' "$CYAN" "$BOLD" "$1" "$RESET" "$2"
}
printf '\n%s%sActivLayer%s %sCommunity Edition installer%s\n\n' \
"$VIOLET" "$BOLD" "$RESET" "$DIM" "$RESET"
step "1/4" "Checking Python runtime"
command -v "$PYTHON" >/dev/null 2>&1 || fail "Python 3.11 or newer is required."
"$PYTHON" -c '
import sys
if sys.version_info < (3, 11):
raise SystemExit("ActivLayer requires Python 3.11 or newer.")
' || fail "Python 3.11 or newer is required."
case "$INSTALL_ROOT" in
""|/|"$HOME") fail "Refusing unsafe installation directory: $INSTALL_ROOT" ;;
esac
PYTHON_VERSION=$("$PYTHON" -c 'import platform; print(platform.python_version())')
printf ' Python %s · %s\n' "$PYTHON_VERSION" "$PYTHON"
step "2/4" "Preparing isolated environment"
mkdir -p "$INSTALL_ROOT" "$BIN_DIR"
if [ ! -x "$INSTALL_ROOT/venv/bin/python" ]; then
"$PYTHON" -m venv "$INSTALL_ROOT/venv" || fail "Could not create the isolated environment."
fi
printf ' %s\n' "$INSTALL_ROOT/venv"
step "3/4" "Downloading and installing ActivLayer"
if [ "${ACTIVLAYER_VERBOSE:-0}" = "1" ]; then
"$INSTALL_ROOT/venv/bin/python" -m pip install \
--disable-pip-version-check \
--upgrade \
"$SOURCE" || fail "Package installation failed."
else
"$INSTALL_ROOT/venv/bin/python" -m pip install \
--disable-pip-version-check \
--quiet \
--upgrade \
"$SOURCE" || fail "Package installation failed. Set ACTIVLAYER_VERBOSE=1 for details."
fi
VERSION_OUTPUT=$("$INSTALL_ROOT/venv/bin/activlayer" --version) || \
fail "Installed command is not healthy."
step "4/4" "Exposing the activlayer command"
ln -sf "$INSTALL_ROOT/venv/bin/activlayer" "$BIN_DIR/activlayer"
case ":$PATH:" in
*":$BIN_DIR:"*)
PATH_NOTE="Ready in this terminal"
NEXT_COMMAND="activlayer --help"
;;
*)
case "${SHELL:-}" in
*/zsh) PROFILE="$HOME/.zprofile" ;;
*/bash)
if [ -f "$HOME/.bash_profile" ]; then
PROFILE="$HOME/.bash_profile"
else
PROFILE="$HOME/.profile"
fi
;;
*) PROFILE="$HOME/.profile" ;;
esac
PATH_LINE="export PATH=\"$BIN_DIR:\$PATH\""
if [ ! -f "$PROFILE" ] || ! grep -F "$PATH_LINE" "$PROFILE" >/dev/null 2>&1; then
printf '\n%s\n' "$PATH_LINE" >> "$PROFILE"
fi
PATH_NOTE="PATH updated in $PROFILE · open a new terminal once"
NEXT_COMMAND="activlayer --help"
;;
esac
printf '\n%s%s╭──────────────────────────────────────────────────────────╮%s\n' \
"$GREEN" "$BOLD" "$RESET"
printf '%s%s│ ✓ ActivLayer installed successfully │%s\n' \
"$GREEN" "$BOLD" "$RESET"
printf '%s%s╰──────────────────────────────────────────────────────────╯%s\n' \
"$GREEN" "$BOLD" "$RESET"
printf ' Version %s\n' "$VERSION_OUTPUT"
printf ' Command %s/activlayer\n' "$BIN_DIR"
printf ' Shell %s\n' "$PATH_NOTE"
printf '\n%sNext:%s %s%s%s\n\n' "$BOLD" "$RESET" "$VIOLET" "$NEXT_COMMAND" "$RESET"