pikvm/kvmd#170: alternative implementation

This commit is contained in:
Maxim Devaev 2024-09-04 03:03:48 +03:00
parent fb9d860cf2
commit 5c3ac4c9c1

View File

@ -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