-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
107 lines (85 loc) · 2.62 KB
/
Copy pathinstall.sh
File metadata and controls
107 lines (85 loc) · 2.62 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
#!/bin/bash
set -euo pipefail
uninstall() {
echo "Uninstalling flash..."
if command -v pipx >/dev/null 2>&1; then
echo "Uninstalling flash via pipx..."
pipx uninstall flash || echo "flash is not installed via pipx."
else
echo "pipx is not installed. Cannot uninstall flash via pipx."
fi
}
if [ "${1:-}" == "--uninstall" ]; then
uninstall
exit 0
fi
REPO_URL="https://github.com/Natuworkguy/Flash"
TEMP_DIR="$(mktemp -d)"
REPO_DIR="$TEMP_DIR/flash"
git clone "$REPO_URL" "$REPO_DIR" || {
echo "Failed to clone repository. Please check your internet connection and try again.";
exit 1;
}
if [ ! -d "$REPO_DIR" ]; then
echo "Repository directory $REPO_DIR does not exist after cloning."
exit 1
fi
cd "$REPO_DIR"
cleanup() {
echo "Cleaning up..."
rm -rf "$TEMP_DIR"
}
trap cleanup EXIT INT TERM
detect_python() {
if command -v python3 >/dev/null 2>&1; then
echo "Detected python command: python3"
PYTHON=python3
elif command -v python >/dev/null 2>&1; then
echo "Detected python command: python"
PYTHON=python
else
echo "Python is not installed. Please install Python 3."
exit 1
fi
}
detect_python
if ! command -v pipx >/dev/null 2>&1; then
echo "pipx is not installed. Installing pipx..."
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update || true
if ! sudo apt-get install -y pipx; then
echo "Failed to install pipx via apt."
exit 1
fi
elif command -v brew >/dev/null 2>&1; then
if ! brew install pipx; then
echo "Failed to install pipx via brew."
exit 1
fi
elif $PYTHON -m pip --version >/dev/null 2>&1; then
if ! $PYTHON -m pip install --user pipx; then
echo "Failed to install pipx via pip."
exit 1
fi
else
echo "Could not install pipx automatically."
echo "If you are on MacOS, ensure brew is installed."
echo "Install it manually: https://pipx.pypa.io/latest/how-to/install-pipx.html"
exit 1
fi
fi
pipx ensurepath --force
# Install (or reinstall, if already present) flash from this repo
pipx install --force "$REPO_DIR"
PIPX_BIN_DIR="$(pipx environment --value PIPX_BIN_DIR 2>/dev/null || echo "$HOME/.local/bin")"
echo ""
echo "=== flash installed via pipx. ==="
case ":$PATH:" in
*":$PIPX_BIN_DIR:"*)
;;
*)
echo "$PIPX_BIN_DIR is not on your PATH yet."
echo "Run this in your current shell, or open a new terminal:"
echo " export PATH=\"$PIPX_BIN_DIR:\$PATH\""
;;
esac