forked from lukasjapan/bt-speaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·52 lines (45 loc) · 1.62 KB
/
install.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
#!/bin/bash +x
set -e
# This script has been tested with the "2017-11-29-raspbian-stretch-lite.img" image.
echo "Installing dependencies..."
apt-get update
apt-get --yes --force-yes install git bluez python python-gobject python-cffi python-dbus python-alsaaudio python-configparser sound-theme-freedesktop vorbis-tools
echo "done."
# Add btspeaker user if not exist already
echo
echo "Adding btspeaker user..."
id -u btspeaker &>/dev/null || useradd btspeaker -G audio
# Also add user to bluetooth group if it exists (required in debian stretch)
getent group bluetooth &>/dev/null && usermod -a -G bluetooth btspeaker
echo "done."
# Download bt-speaker to /opt (or update if already present)
echo
cd /opt
if [ -d bt-speaker ]; then
echo "Updating bt-speaker..."
cd bt-speaker && git pull && git checkout ${1:master}
else
echo "Downloading bt-speaker..."
git clone https://github.com/lukasjapan/bt-speaker.git
cd bt-speaker && git checkout ${1:master}
fi
echo "done."
# Prepare default config
mkdir -p /etc/bt_speaker/hooks
cp -n /opt/bt-speaker/config.ini.default /etc/bt_speaker/config.ini
cp -n /opt/bt-speaker/hooks.default/connect /etc/bt_speaker/hooks/connect
cp -n /opt/bt-speaker/hooks.default/disconnect /etc/bt_speaker/hooks/disconnect
# Install and start bt-speaker daemon
echo
echo "Registering and starting bt-speaker with systemd..."
systemctl enable /opt/bt-speaker/bt_speaker.service
if [ "`systemctl is-active bt_speaker`" != "active" ]; then
systemctl start bt_speaker
else
systemctl restart bt_speaker
fi
systemctl status bt_speaker --full --no-pager
echo "done."
# Finished
echo
echo "BT-Speaker has been installed."