From 8e654849a088d7e2843233e90a0994829de638d0 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Wed, 18 Jun 2025 09:45:56 +0200 Subject: Updated the scripts to use common fonctions --- board/bluetooth.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++------ board/common.sh | 6 ++++++ board/mpd.sh | 8 ++++---- board/network.sh | 2 +- 4 files changed, 64 insertions(+), 11 deletions(-) (limited to 'board') 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" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +__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 -- cgit v1.2.3