-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstall.sh
More file actions
120 lines (106 loc) · 4.58 KB
/
Copy pathinstall.sh
File metadata and controls
120 lines (106 loc) · 4.58 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
#!/usr/bin/env bash
set -e
ascii_art="\n\e[1;32m\
┌───────┐ ┌───┐ ┌─┐ ┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐\n\
═╘═╕∙ ·╒═╛═│∙ │═│∙│═╘═╕∙ ╒═╛═│∙╒═════╛═╘═╕∙ ╒═╛═│∙ ╒═╕∙│\n\
░░▒│ │▒░░│ │█│ │ ▓▓│ │░▓▓│ └─────┐ ▓▓│ │░▓ │ │▓└─┘\n\
░░▒│ │▒░▒│ │▓│ │░░░│ │▓██╘═══╕ ∙│░░░│ │▓█░│ │░┌─┐\n\
░░▒│ │▒░▓│ └─┘ │▒▒▒│ │░▒▓┌───┘ │▒▒▒│ │░▒▒│ │░│ │\n\
═══│∙ ·│═══│∙ ∙│═┌─┘∙ └─┐═│∙ ∙│═┌─┘∙ └─┐═│∙ ╘═╛∙│\n\
╘═══╛ ╘═══════╛ ╘═══════╛ ╘═══════╛ ╘═══════╛ ╘═══════╛\e[0m\n"
echo -e "$ascii_art"
REPO_OWNER="Dark-Kernel"
REPO_NAME="tuisic"
RELEASE_API="https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest"
RELEASE_URL="https://github.com/$REPO_OWNER/$REPO_NAME/releases/latest/download"
# --- DETECT OS & ARCH ---
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
if [[ $OS == "darwin" ]]; then
case $ARCH in
x86_64) PLATFORM="macos-x64";;
arm64) PLATFORM="macos-arm64";;
*)
echo -e "\e[91mSorry, Mac architecture $ARCH is not supported by tuisic binary releases.\e[0m"
unsupported=1
;;
esac
elif [[ $OS == "linux" ]]; then
case $ARCH in
x86_64*) PLATFORM="linux-x64";;
*)
echo -e "\e[91mSorry, Linux architecture $ARCH is not supported by tuisic binary releases.\e[0m"
unsupported=1
;;
esac
elif grep -qEi "(Microsoft|WSL)" /proc/version 2>/dev/null; then
PLATFORM="linux-x64"
OS="linux"
else
echo -e "\e[91mSorry, your OS ($OS $ARCH) is not supported by tuisic binary releases.\e[0m"
unsupported=1
fi
if [[ "$unsupported" == "1" ]]; then
echo -e "\n\e[1;33mYou can build tuisic from source:\e[0m"
echo " git clone https://github.com/${REPO_OWNER}/${REPO_NAME}.git"
echo " cd ${REPO_NAME} && mkdir build && cd build"
echo " cmake .. -DCMAKE_BUILD_TYPE=Release"
echo " make -j\$(nproc)"
echo " sudo make install"
exit 11
fi
BINARY="tuisic-$PLATFORM"
TMPDIR="$(mktemp -d)"
INSTALL_PATH="/usr/local/bin/tuisic"
# Check write permissions for default, fallback to ~/.local/bin
if [ ! -w "$(dirname "$INSTALL_PATH")" ]; then
INSTALL_PATH="$HOME/.local/bin/tuisic"
mkdir -p "$HOME/.local/bin"
echo "No sudo. Will install to $INSTALL_PATH" >&2
fi
BIN_URL="$RELEASE_URL/$BINARY"
echo -e "\nFetching latest $BINARY from $BIN_URL ...\n"
# Download binary
if ! curl -fsSL -o "$TMPDIR/$BINARY" "$BIN_URL"; then
echo -e "\e[91mDownload failed. Please check your internet connection, or see https://github.com/$REPO_OWNER/$REPO_NAME/releases for latest binaries.\e[0m"
rm -rf "$TMPDIR"
exit 2
fi
chmod +x "$TMPDIR/$BINARY"
mv "$TMPDIR/$BINARY" "$INSTALL_PATH"
echo -e "\e[32mInstalled tuisic to $INSTALL_PATH\e[0m\n"
# ---- Runtime dependency check (Linux) ----
if [[ $OS == "linux" ]]; then
deps_ok=true
for lib in libfmt.so libmpv.so libcurl.so libpulse.so; do
if ! ldconfig -p 2>/dev/null | grep -q "$lib"; then
echo -e "\e[33mWarning: $lib not found — tuisic may fail to run.\e[0m"
deps_ok=false
fi
done
if [[ "$deps_ok" == "false" ]]; then
echo -e "\n\e[33mOn Debian/Ubuntu, install missing libraries:\e[0m"
echo " sudo apt-get install libfmt-dev libmpv-dev libcurl4-openssl-dev libpulse-dev"
echo -e "\e[33mOn Fedora/RHEL:\e[0m"
echo " sudo dnf install fmt-devel mpv-libs-devel libcurl-devel pulseaudio-libs-devel"
fi
fi
# Suggest adding to PATH if needed
case ":$PATH:" in
*:"$HOME/.local/bin":*) ;; # already in path
*)
if [[ "$INSTALL_PATH" == "$HOME/.local/bin/tuisic" ]]; then
echo -e "\nTo use 'tuisic', add '$HOME/.local/bin' to your PATH:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
fi
;;
esac
# Show version
if "$INSTALL_PATH" --version 2>/dev/null; then
"$INSTALL_PATH" --version
else
echo "Run 'tuisic --version' to verify installation." >&2
fi
echo -e "\n\e[1;32mInstall complete. Enjoy tuisic!\e[0m\n"
rm -rf "$TMPDIR"
exit 0