-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·113 lines (102 loc) · 3.07 KB
/
install.sh
File metadata and controls
executable file
·113 lines (102 loc) · 3.07 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
#!/bin/sh
set -eu
os="$(uname -s)"
as_root() {
if [ "$(id -u)" -eq 0 ]; then
"$@"
return
fi
if command -v sudo >/dev/null 2>&1; then
sudo "$@"
return
fi
echo "This installer needs root privileges to install system packages."
echo "Install sudo or rerun as root."
exit 1
}
install_node() {
case "$os" in
Darwin)
if ! command -v brew >/dev/null 2>&1; then
echo "Homebrew is required for the macOS installer."
echo "Install it from https://brew.sh, then rerun this script."
exit 1
fi
brew install node || brew upgrade node
;;
Linux)
if command -v apt-get >/dev/null 2>&1; then
as_root apt-get update
as_root apt-get install -y nodejs npm
elif command -v dnf >/dev/null 2>&1; then
as_root dnf install -y nodejs npm
elif command -v pacman >/dev/null 2>&1; then
as_root pacman -S --needed --noconfirm nodejs npm
else
echo "No supported Linux package manager found."
echo "Install Node.js 18+ and npm, then rerun this script."
exit 1
fi
;;
*)
echo "Unsupported OS: $os"
echo "Use npm instead: npm install -g claudefm"
exit 1
;;
esac
}
install_playback_dependencies() {
case "$os" in
Darwin)
if ! command -v brew >/dev/null 2>&1; then
echo "Homebrew is required for the macOS installer."
echo "Install it from https://brew.sh, then rerun this script."
exit 1
fi
brew install yt-dlp mpv
;;
Linux)
if command -v apt-get >/dev/null 2>&1; then
as_root apt-get update
as_root apt-get install -y yt-dlp mpv
elif command -v dnf >/dev/null 2>&1; then
as_root dnf install -y yt-dlp mpv
elif command -v pacman >/dev/null 2>&1; then
as_root pacman -S --needed --noconfirm yt-dlp mpv
else
echo "No supported Linux package manager found."
echo "Install yt-dlp and mpv manually, then rerun claudefm doctor."
exit 1
fi
;;
*)
echo "Unsupported OS: $os"
echo "Install yt-dlp and mpv manually, then run: npm install -g claudefm"
exit 1
;;
esac
}
if ! command -v npm >/dev/null 2>&1; then
echo "npm was not found. Installing Node.js and npm..."
install_node
fi
node_major="$(node -p "Number(process.versions.node.split('.')[0])" 2>/dev/null || echo 0)"
if [ "$node_major" -lt 18 ]; then
echo "Node.js 18 or newer is required. Installing or upgrading Node.js..."
install_node
node_major="$(node -p "Number(process.versions.node.split('.')[0])" 2>/dev/null || echo 0)"
if [ "$node_major" -lt 18 ]; then
echo "Node.js is still older than 18 after package-manager install."
echo "Install Node.js 18+ from https://nodejs.org, then rerun this script."
exit 1
fi
fi
echo "Installing claudefm..."
if ! npm install -g claudefm; then
echo "Retrying claudefm install with elevated permissions..."
as_root npm install -g claudefm
fi
echo "Installing playback dependencies..."
install_playback_dependencies
echo "Checking setup..."
claudefm doctor