-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup_broo
executable file
·469 lines (372 loc) · 15.3 KB
/
setup_broo
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
#!/bin/bash
##############################################################################
# This setup script must be run before running Broo the first time.
# Copyright (C) 2021 Siddh Raman Pant
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# The online repository can be found at <https://github.com/siddhpant/broo>.
##############################################################################
# Exit on errors.
set -euo pipefail
install_dependencies() {
# Installs all the required dependencies.
if [[ ! $(command -v apt) ]]; then
echo "No apt found."
read -n1 -p "Have you installed all the dependencies? (y/n): " yn
echo
case $yn in
y|Y)
echo "Cool! Going ahead."
return
;;
n|N)
echo "Then install them! Look at the README of repo."
return 1
;;
*)
echo "Huh?? Look at the README of repo."
echo "Assuming you didn't, as you can't even reply properly."
return 1
;;
esac
fi
dep_installed=false
mumble_installed=true
if [[ ! $(command -v mumble) ]]; then
mumble_installed=false
echo -e "
Mumble not found in the system.
If you want, I can build Mumble from source for you.
Otherwise I will go the normal package manager route.
Giving this option because upstream has improved support for
PipeWire, performance, and bug fixes, and also because distro
repos are outdated (as of 2022/02/27). I will also install the
required dependencies.
1. Install latest stable release. (Recommended)
2. Install latest master branch. (Not recommended)
3. Don't build from source.
" | cut -c 13- | tail -n +2
read -n1 -p "Enter your choice (1/2/3): " choice
echo
case $choice in
1|2)
repo_url="https://github.com/mumble-voip/mumble.git"
if [[ $choice == 1 ]]; then
latest=$(
git ls-remote --tags $repo_url |
cut --delimiter='/' --fields=3 |
tail -n1
)
to_clone="--depth 1 --branch $latest $repo_url"
else
to_clone="--depth 1 $repo_url"
fi
echo -e "\nEntering...\n"
(
set -x
sudo apt update
sudo apt install -y \
build-essential \
cmake \
checkinstall \
pkg-config \
qt6-base-dev \
qtchooser \
qt6-base-dev-tools \
qt6-tools-dev \
qt6-tools-dev-tools \
libqt6svg6-dev \
libboost-dev \
libssl-dev \
libprotobuf-dev \
protobuf-compiler \
libprotoc-dev \
libcap-dev \
libxi-dev \
libasound2-dev \
libogg-dev \
libsndfile1-dev \
opus-tools \
libspeechd-dev \
libavahi-compat-libdnssd-dev \
libzeroc-ice-dev \
libpoco-dev \
avahi-daemon \
iproute2
cd /tmp
rm -rf mumble_broo
git clone $to_clone mumble_broo
cd mumble_broo
git submodule update --init --recursive --depth 1
mkdir build && cd build
num_proc=$(nproc)
export CMAKE_BUILD_PARALLEL_LEVEL=$num_proc
# Example: release_id = "1.6". But it may also be longer,
# like "1.5.0~2021-11-11~ge54798cbd~snapshot".
release_id=$(python "../scripts/mumble-version.py")
if [[ $choice == 1 ]]; then
version=$(git describe --tags) # Example: "v1.5.517".
version="${version:1}" # Remove leading "v".
else
# Example: version = "1.6~git27e9552".
version="$release_id~git$(git rev-parse --short HEAD)"
fi
# Append "+broo" to signify we built the package.
version+="+broo" # Example: "1.6~git27e9552+broo".
echo "Mumble (built from source)" > description-pak
cmake \
-DBUILD_NUMBER=0 \
-DRELEASE_ID=$release_id \
-DCMAKE_UNITY_BUILD=ON \
-Doptimize=ON \
-Dpackaging=ON \
-Dlto=ON \
-Dpipewire=ON \
-Dpulseaudio=ON \
-Dalsa=OFF \
-Dcoreaudio=OFF \
-Djackaudio=OFF \
-Doss=OFF \
-Dportaudio=OFF \
-Dplugins=OFF \
-Doverlay=OFF \
-Doverlay-xcompile=OFF \
-Dcrash-report=OFF \
-Dtranslations=OFF \
-Dwasapi=OFF \
-Dxboxinput=OFF \
-Dgkey=OFF \
..
# Normally, we will have make WITHOUT install and have
# checkinstall create a package which will then be used
# to install. But checkinstall has a long-standing bug
# (#717778 on debbugs) so it is unable to create package
# for files not existing.
# So we will install using make, then create packages using
# checkinstall (which for some reason cannot access files
# without sudo), and then install that package, so that the
# package manager can uninstall mumble later successfully.
sudo make -j$num_proc install
sudo checkinstall \
--install=no \
--showinstall=no \
--pkgname=mumble \
--pkgversion=$version \
--pkgrelease=$release_id \
--nodoc \
--default \
make install
sudo apt-get install ./mumble*.deb
sudo systemctl disable mumble-server || true
cd /tmp
# Need sudo due to checkinstall sudo.
sudo rm -rf mumble_broo
)
echo -e "\nDone!"
dep_installed=true
mumble_installed=true
;;
3)
echo -e "Okay, not building Mumble from source.\n"
;;
*)
echo -e "Huh?? Defaulting to not building.\n"
;;
esac
fi
if [[ "$dep_installed" == "false" ]]; then
read -n1 -p "Do you want to install / update dependencies? (y/n): " yn
echo
case $yn in
y|Y)
(
set -x
sudo apt update
sudo apt install -y \
avahi-daemon \
iproute2
if [[ "$mumble_installed" == "false" ]]; then
sudo apt install -y mumble mumble-server
fi
sudo systemctl disable mumble-server || true
)
;;
n|N)
echo "Okay. Assuming you have installed all the dependencies!"
;;
*)
echo "Huh?? Assuming you have installed all the dependencies."
;;
esac
fi
} # End of install_dependencies()
check_mumble() {
# Check whether mumble is installed.
if [[ ! $(command -v mumble) ]]; then
echo "Mumble not found! Did you correctly install it?"
exit 1
elif [[ ! $(command -v mumble-server || command -v murmurd) ]]; then
echo "Mumble server not found! Did you correctly install it?"
exit 1
fi
} # End of check_mumble()
set_up_mumble() {
# Sets up Mumble for quick use later.
# Purge any existing and config.
rm -rf ~/.cache/broo
rm -rf ~/.config/broo
mkdir ~/.config/broo
# Set password for new / unregistered connections.
pass="a"
pass_confirm="b"
echo
read -n1 -p "Do you want to set password for new connections? (y/n): " yn
echo
case $yn in
y|Y)
while [[ "$pass" != "$pass_confirm" ]]; do
printf "Note: Password is saved **unencrypted**, and should "
echo "not contain double quotes (\")."
read -sp "Enter password: " pass; echo
read -sp "Enter password again: " pass_confirm; echo
if [[ "$pass" != "$pass_confirm" ]]; then
echo -e "\nPassword doesn't match!\n"
fi
done
;;
n|N) ;;
*) echo "Huh?? Defaulting to no password." ;;
esac
# Ask if logging is needed.
logfile=
read -n1 -p "Do you want to enable Mumble server logging? (y/n): " yn
echo
case $yn in
y|Y) echo "Log will be stored in ~/.cache/broo/murmur.log"
mkdir ~/.cache/broo
logfile=~/.cache/broo/murmur.log
;;
n|N) ;;
*) echo "Huh?? Defaulting to no logging." ;;
esac
# Create the murmur.ini file.
murmur_config_path="$HOME/.config/broo/murmur.ini"
echo "Assuming your UID won't change in future."
echo -e "; Generated by Broo, for Broo! ;-)
bonjour=true
bandwidth=558000 ; Max possible BW, see Mumble source on GitHub.
registerName=Broo
database=$HOME/.config/broo/murmur.sqlite
logfile=\"$logfile\"
logdays=-1 ; Don't store logs in the database.
password=\"$pass\"
welcometext=\"\" ; Why even welcome ourselves? :-P
" | awk '{$1=$1};1' > $murmur_config_path
# Tell user to use the Mumble GUI for configuring it once.
echo -e "
Gotta configure the Mumble client from GUI for that sweet low latency.
Once Mumble starts, do the following:
- Connect to the server on 127.0.0.1 (if it isn't there, add it).
- Right click on your user and make sure it is muted.
- Right click on your user and click on 'Register' to register it.
- Go to Configure -> Audio Wizard and go through the steps.
- Go to Configure -> Certificate Wizard and go through the steps.
- Then open settings (Configure -> Settings).
- In the 'Audio Input' screen, disable all types of audio processing.
- Turn off anything which can cause app sound, like audio and mute cue.
- If you want, you can proceed to change other settings at your will.
- After you are done, close Mumble and come back here.
This is a one time setup process, so don't skip it!
" | awk '{$1=$1};1'
read -n1 -p "Press any key to start Mumble..."
# Start the server.
if [[ $(command -v mumble-server) ]]; then
nohup mumble-server -ini $murmur_config_path -fg &>/dev/null 2>&1 &
else
nohup murmurd -ini $murmur_config_path -fg &>/dev/null 2>&1 &
fi
murmur_pid=$!
sleep 3 # Give time for it to set up.
# Start the GUI.
mumble >/dev/null 2>&1
# Stop the server.
kill $murmur_pid
echo -e "Done setting up Mumble!\n"
} # End of set_up_mumble()
copy_broo() {
echo "Setting up the 'broo' command..."
mkdir -p $HOME/.local/bin
cp broo $HOME/.local/bin
chmod a+x $HOME/.local/bin/broo
if [[ ! ":$PATH:" == *"$HOME/.local/bin:"* ]]; then
echo "Please add ~/.local/bin to your path before running Broo!"
fi
echo -e "Done setting up the 'broo' command!\n"
}
test_broo() {
echo "Testing whether broo works offscreen..."
line="--------------------------------------------------------------------"
echo $line
set +e
timeout 30 $HOME/.local/bin/broo -s # 30 seconds are more than enough.
exit_status=$?
set -e
if [[ $exit_status -eq 0 ]]; then
echo
$HOME/.local/bin/broo -c
echo $line
echo "Test successful - Broo works successsfully as it was intended!"
elif [[ $exit_status -eq 124 ]]; then
$HOME/.local/bin/broo -q
echo -e "
Timed out!
Broo probably was stuck during initialisation. If you did the
mumble certificate setup correctly (if not sure please do again),
# then it might be that a rare QT (or mumble?) problem affecting
your system, wherein we cannot connect to the server when using
the offscreen platform.
Running broo will show the mumble app instead of silently running
and handling it for you. Please do not close it while using broo.
This behaviour can be stopped by removing the 'no_offscreen' file
from $HOME/.config/broo/.
" | awk '{$1=$1};1'
echo "This file is created to disable offscreen run of mumble." \
> $HOME/.config/broo/no_offscreen
echo $line
elif [[ $exit_status -eq 125 ]]; then
echo $line
echo "The 'timeout' command failed! Consider checking coreutils."
exit 1
else
echo $line
echo "An unknown problem encountered. Check the output or logs."
exit 1
fi
}
# Script will start executing from here when run from terminal.
echo -e "Setting up Broo...\n"
install_dependencies
check_mumble
set_up_mumble
copy_broo
test_broo
echo -e "
Now set up the mobile app.
- For Android: get the Mumla app from F-Droid.
- For iOS: get the Official Mumble app from App Store.
After installing the app, open its settings and do the following:
- Set the 'Input Sample Rate' to its highest value.
- Set 'Input Quality' to its highest value.
- Set 'Audio per packet' to 10ms or 20ms (whichever results in higher
quality when transmitting voice; use 10ms if both have same quality).
" | awk '{$1=$1};1'
echo -e "We are done! Start Broo with the 'broo' command anytime!"
# End of file.