aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/bluetooth.sh59
-rw-r--r--board/common.sh6
-rw-r--r--board/mpd.sh8
-rw-r--r--board/network.sh2
4 files changed, 64 insertions, 11 deletions
diff --git a/board/bluetooth.sh b/board/bluetooth.sh
index 960468a..c1af995 100644
--- a/board/bluetooth.sh
+++ b/board/bluetooth.sh
@@ -16,7 +16,10 @@ PairableTimeout = 0
AutoEnable=true
__EOF__
+# Accept any code from any connexion
+echo "* *" > "${TARGET_DIR}/etc/bluetooth/pins"
+# Run the Bluetooth agent
cat << __EOF__ > "${TARGET_DIR}/etc/systemd/system/bt-agent.service"
[Unit]
Description=Bluetooth Agent
@@ -26,18 +29,62 @@ Requires=bluetooth.service
[Service]
Type=simple
ExecStartPre=bt-adapter --set Discoverable 1
-# see https://github.com/RPi-Distro/repo/issues/291
#ExecStart=bt-agent -c NoInputNoOutput
-ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bt-agent --capability=DisplayOnly'
-# Restart the service each 60s
-WatchdogSec=60
-RestartSec=60
-Restart=always
+ExecStart=bt-agent -p /etc/bluetooth/pins
+## Restart the service each 60s
+#WatchdogSec=60
+#RestartSec=60
+#Restart=always
[Install]
WantedBy=multi-user.target
__EOF__
+enable_service "bt-agent.service"
+
+create_missing_dir "/etc/dbus-1/system.d/"
+cat << __EOF__ > "${TARGET_DIR}/etc/dbus-1/system.d/bluetooth.conf"
+<!-- This configuration file specifies the required security policies
+ for Bluetooth core daemon to work. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+
+ <!-- ../system.conf have denied everything, so we just punch some holes -->
+
+ <policy user="root">
+ <allow own="org.bluez"/>
+ <allow send_destination="org.bluez"/>
+ <allow send_interface="org.bluez.AdvertisementMonitor1"/>
+ <allow send_interface="org.bluez.Agent1"/>
+ <allow send_interface="org.bluez.MediaEndpoint1"/>
+ <allow send_interface="org.bluez.MediaPlayer1"/>
+ <allow send_interface="org.bluez.Profile1"/>
+ <allow send_interface="org.bluez.GattCharacteristic1"/>
+ <allow send_interface="org.bluez.GattDescriptor1"/>
+ <allow send_interface="org.bluez.LEAdvertisement1"/>
+ <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
+ <allow send_interface="org.freedesktop.DBus.Properties"/>
+ <allow send_interface="org.mpris.MediaPlayer2.Player"/>
+ </policy>
+
+ <!-- allow users of bluetooth group to communicate -->
+ <policy group="bluetooth">
+ <allow send_destination="org.bluez"/>
+ </policy>
+
+ <policy context="default">
+ <allow send_destination="org.bluez"/>
+ </policy>
+
+</busconfig>
+__EOF__
+
+# Set permission to 755 in the directory /var/lib/bluetooth/ (prevent a
+# permission error)
+sed --in-place "s/0555/0755/" ${TARGET_DIR}/usr/lib/systemd/system/bluetooth.service
+
## The same for the bluetooth, as bluetoothd keep a track for each paired device
create_missing_dir "/var/lib/bluetooth/"
#if ! grep -qE '/var/lib/bluetooth' "${TARGET_DIR}/etc/fstab"; then
diff --git a/board/common.sh b/board/common.sh
index 6e05d2a..1026c11 100644
--- a/board/common.sh
+++ b/board/common.sh
@@ -1,4 +1,5 @@
create_missing_dir() {
+ echo "creating directory ${TARGET_DIR}/$1"
test -d "${TARGET_DIR}/$1" || mkdir -p "${TARGET_DIR}/$1"
}
@@ -15,3 +16,8 @@ tmpfs $1 tmpfs rw 0 0
__EOF__
fi
}
+
+# Enable a systemd service
+enable_service() {
+ ln -sf /etc/systemd/system/$1 "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/$1"
+}
diff --git a/board/mpd.sh b/board/mpd.sh
index d99161c..319d7a2 100644
--- a/board/mpd.sh
+++ b/board/mpd.sh
@@ -59,7 +59,8 @@ WantedBy=multi-user.target
__EOF__
# Create the link to the system configuration
-ln -sf /etc/systemd/system/playlists.service "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/playlists.service"
+#ln -sf /etc/systemd/system/playlists.service "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/playlists.service"
+enable_service "playlists.service"
cat << __EOF__ > "${TARGET_DIR}/etc/systemd/system/rss_playlists.service"
[Unit]
@@ -89,6 +90,5 @@ RandomizedDelaySec=15m
WantedBy=timers.target
__EOF__
-ln -sf /etc/systemd/system/rss_playlists.service "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/rss_playlists.service"
-
-ln -sf /etc/systemd/system/rss_playlists.timer "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/rss_playlists.timer"
+enable_service "rss_playlists.service"
+enable_service "rss_playlists.timer"
diff --git a/board/network.sh b/board/network.sh
index 65a5640..9c4ee85 100644
--- a/board/network.sh
+++ b/board/network.sh
@@ -19,7 +19,7 @@ DHCP=yes
__EOF__
# Create the link to interface wlan0 directly in the system configuration
- ln -sf /usr/lib/systemd/system/wpa_supplicant@.service "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service"
+ enable_service "wpa_supplicant@wlan0.service"
fi