-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetup.sh
executable file
·113 lines (94 loc) · 2.31 KB
/
setup.sh
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/bash
pause() {
echo "Press Enter to proceed."
read
clear
}
repo_url="https://github.com/polarhive/jukebox/archive/refs/heads/main.tar.gz"
tarball="/tmp/jukebox-main.tar.gz"
extracted_dir="/tmp/jukebox-main"
venv_path="$HOME/.local/bin/jukebox-fm/.venv"
check_package() {
local pkg=$1
local pkg_name=$2
if ! command -v "$pkg" > /dev/null 2>&1; then
echo "Error: Please install $pkg_name using your package manager."
exit 1
fi
}
setup_venv() {
if [ ! -d "$venv_path" ]; then
echo "Creating virtual environment at $venv_path..."
python -m venv "$venv_path"
fi
source "$venv_path/bin/activate"
pip install --upgrade pip jukebox-fm
clear
}
download_repo() {
echo "Downloading the repository tarball to /tmp..."
curl -fsSL "$repo_url" -o "$tarball"
if [ $? -ne 0 ]; then
echo "Error: Failed to download tarball. Check your network connection."
exit 1
fi
echo "Extracting tarball to /tmp..."
mkdir -p "$extracted_dir"
tar -xzf "$tarball" -C /tmp
if [ $? -ne 0 ]; then
echo "Error: Failed to extract tarball."
exit 1
fi
clear
}
copy_config_files() {
local src_dir="$extracted_dir/docs/."
local dest_dir="$HOME"
cp -r "$src_dir" "$dest_dir"
if [ $? -ne 0 ]; then
echo "Error: Failed to copy configuration files. Check permissions and paths."
exit 1
fi
echo "Configuration files setup complete."
}
clear
echo "Setup starting!"
sleep 1
pause
echo "Checking required system packages..."
sleep 1
check_package "python" "Python"
check_package "mpc" "MPC"
check_package "mpd" "MPD"
check_package "ncmpcpp" "ncmpcpp"
check_package "ffmpeg" "FFmpeg"
pause
download_repo
setup_venv
echo "Virtual environment setup complete."
pause
copy_config_files
pause
if ! systemctl --user enable --now mpd; then
echo "Error: Failed to enable/start MPD. Ensure correct permissions and a valid systemd user environment."
exit 1
fi
echo "MPD service started successfully."
pause
echo "Running jukebox-fm..."
source "$venv_path/bin/activate"
if ! python -m jukebox_fm.jukebox; then
echo "Error: Failed to execute jukebox-fm."
exit 1
fi
clear
rm -rf "$tarball" "$extracted_dir"
echo "Setup completed successfully!"
sleep 1
clear
echo "Now opening: ncmpcpp"
sleep 1
echo "Remember to press 'Enter' to start playing and 'p' to pause."
sleep 4
ncmpcpp -q
echo "Goodbye!"