diff options
author | Maxim Devaev <[email protected]> | 2024-09-04 03:03:48 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2024-09-04 03:03:48 +0300 |
commit | 5c3ac4c9c100fe381591f8756fca3bd56b9ca9f7 (patch) | |
tree | 54a9479a55df19c62921a8c3bd9ba54e3364b6c3 | |
parent | fb9d860cf2594797aefff817c04e8c0f26712bf6 (diff) |
pikvm/kvmd#170: alternative implementation
-rwxr-xr-x | scripts/kvmd-bootconfig | 35 |
1 files changed, 35 insertions, 0 deletions
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 <<end_of_file > /etc/avahi/services/pikvm.service +<?xml version="1.0" standalone='no'?> +<!DOCTYPE service-group SYSTEM "avahi-service.dtd"> +<service-group> + <name replace-wildcards="yes">pikvm-$_serial.local</name> + <service> + <type>_pikvm._tcp</type> + <port>443</port> + <txt-record>path=/</txt-record> + <txt-record>protocol=https</txt-record> + <txt-record>description=PiKVM Web Server</txt-record> + <txt-record>serial=$_serial</txt-record> + <txt-record>model=$_model</txt-record> + </service> + <service> + <type>_https._tcp</type> + <port>443</port> + <txt-record>path=/</txt-record> + <txt-record>protocol=https</txt-record> + <txt-record>description=PiKVM Web Server</txt-record> + <txt-record>serial=$_serial</txt-record> + <txt-record>model=$_model</txt-record> + </service> +</service-group> +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 |