aboutsummaryrefslogtreecommitdiff
path: root/board/post-build.sh
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-11-14 20:42:34 +0100
committerSébastien Dailly <sebastien@chimrod.com>2021-11-15 08:29:49 +0100
commit8f86f098b6ea868f8d98b4d26df8382dc4047c81 (patch)
tree1ef66b6243eb504b23d3739a47b923cc7d90f5c7 /board/post-build.sh
Inital commit
Diffstat (limited to 'board/post-build.sh')
-rwxr-xr-xboard/post-build.sh114
1 files changed, 114 insertions, 0 deletions
diff --git a/board/post-build.sh b/board/post-build.sh
new file mode 100755
index 0000000..6b1c86c
--- /dev/null
+++ b/board/post-build.sh
@@ -0,0 +1,114 @@
+#!/bin/sh
+
+set -u
+set -e
+
+. "${BR2_EXTERNAL_PIAUDIO_PATH}/board/common.sh"
+
+# Add a console on tty1
+if [ -e ${TARGET_DIR}/etc/inittab ]; then
+ grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \
+ sed -i '/GENERIC_SERIAL/a\
+tty1::respawn:/sbin/getty -L tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab
+fi
+
+# Put the whole system in readonly
+sed -ie '/^\/dev\/root/ s/rw 0 1/ro 0 0/' "${TARGET_DIR}/etc/fstab"
+
+###########################
+# #
+# Network configuration #
+# #
+###########################
+
+# Add default wpa_supplicant.conf if it exists
+if [ -f "$BR2_EXTERNAL_PIAUDIO_PATH/wpa_supplicant.conf" ]; then
+ create_missing_dir "/etc/wpa_supplicant/"
+ cat "$BR2_EXTERNAL_PIAUDIO_PATH/wpa_supplicant.conf" > "${TARGET_DIR}/etc/wpa_supplicant/wpa_supplicant-wlan0.conf"
+
+
+ cat << __EOF__ > "${TARGET_DIR}/etc/systemd/network/wireless.network"
+[Match]
+Name=wlan0
+
+[Network]
+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"
+
+fi
+
+##############################
+# #
+# Pulseaudio configuration #
+# #
+##############################
+
+# Create the directory where pulseaudio store its files and put it in tempfs
+create_missing_dir "/var/lib/pulse"
+if ! grep -qE '/var/lib/pulse' "${TARGET_DIR}/etc/fstab"; then
+ cat << __EOF__ >> "${TARGET_DIR}/etc/fstab"
+tmpfs /var/lib/pulse tmpfs rw 0 0
+__EOF__
+fi
+
+if ! grep -qE '^load-module module-native-protocol-tcp' "${TARGET_DIR}/etc/pulse/system.pa"; then
+ cat << __EOF__ >> "${TARGET_DIR}/etc/pulse/system.pa"
+load-module module-bluetooth-policy
+load-module module-bluetooth-discover
+load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/24;2a01:e35:8ac8:0e00::/64 auth-anonymous=1
+__EOF__
+fi
+
+#############################
+# #
+# Bluetooth configuration #
+# #
+#############################
+
+create_missing_dir "/etc/bluetooth/"
+cat << __EOF__ > "${TARGET_DIR}/etc/bluetooth/main.conf"
+[General]
+
+Class = 200428
+DiscoverableTimeout = 0
+PairableTimeout = 0
+
+[Policy]
+AutoEnable=true
+__EOF__
+
+
+cat << __EOF__ > "${TARGET_DIR}/etc/systemd/system/bt-agent.service"
+[Unit]
+Description=Bluetooth Agent
+After=bluetooth.service
+Requires=bluetooth.service
+
+[Service]
+Type=simple
+ExecStartPre=bt-adapter --set Discoverable 1
+ExecStart=bt-agent -c NoInputNoOutput
+RestartSec=5
+Restart=always
+KillSignal=SIGUSR1
+
+[Install]
+WantedBy=bluetooth.target
+__EOF__
+
+# 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
+ cat << __EOF__ >> "${TARGET_DIR}/etc/fstab"
+tmpfs /var/lib/bluetooth tmpfs rw 0 0
+__EOF__
+fi
+
+
+mkdir -p "${TARGET_DIR}"/etc/systemd/system/getty.target.wants
+# Add a console on ttyAMA0 and enable auto login
+ln -sf /usr/lib/systemd/system/serial-getty@.service "${TARGET_DIR}"/etc/systemd/system/getty.target.wants/serial-getty@ttyGS0.service
+sed '/^ExecStart=/ s/-o .-p -- ..u./--skip-login --noclear --noissue --login-options "-f root"/' -i "${TARGET_DIR}"/usr/lib/systemd/system/serial-getty@.service