From 5c3ac4c9c100fe381591f8756fca3bd56b9ca9f7 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Wed, 4 Sep 2024 03:03:48 +0300 Subject: [PATCH] pikvm/kvmd#170: alternative implementation --- scripts/kvmd-bootconfig | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/scripts/kvmd-bootconfig b/scripts/kvmd-bootconfig index b4dc2280..09e95fc0 100755 --- a/scripts/kvmd-bootconfig +++ b/scripts/kvmd-bootconfig @@ -55,6 +55,39 @@ rw # ========== First boot configuration ========== +make_avahi_service() { + local _serial + _serial=$(tr -d '\0' < /proc/device-tree/serial-number || echo "0000000000000000") + local _model + _model=$(tr -d '\0' < /proc/device-tree/model || echo "Unknown model") + mkdir -p /etc/avahi/services + cat < /etc/avahi/services/pikvm.service + + + + pikvm-$_serial.local + + _pikvm._tcp + 443 + path=/ + protocol=https + description=PiKVM Web Server + serial=$_serial + model=$_model + + + _https._tcp + 443 + path=/ + protocol=https + description=PiKVM Web Server + serial=$_serial + model=$_model + + +end_of_file +} + if [ -n "$FIRSTBOOT$FIRST_BOOT" ]; then ( \ (umount /etc/machine-id || true) \ @@ -90,6 +123,8 @@ if [ -n "$FIRSTBOOT$FIRST_BOOT" ]; then unset disk part npart label fi + make_avahi_service + # fc-cache is required for installed X server # shellcheck disable=SC2015 which fc-cache && fc-cache || true