kvmd
kvmd copied to clipboard
Enable Avahi
Summary
This PR introduces support for Avahi ZeroConf. With this implementation, the PiKVM will show up in Nautilus/Dolphin under Network or in Finder on Mac.
Details
The implementation allows for auto-discovery and unique identification of the PiKVM without relying on dynamic information such as MAC address, IP address, or HTTPS certificate. This feature is particularly useful for adding devices to Home Assistant.
ZeroConf Data
The ZeroConf data broadcasts the following _pikvm._tcp
registration:
The same data is also replicated with the _https._tcp
registration.
Benefits
- Auto-discovery: Simplifies the process of finding PiKVM devices on the network.
- Unique Identification: Each PiKVM is uniquely identifiable without relying on changing network information.
- Home Assistant Integration: Facilitates the addition of PiKVM devices to Home Assistant, enhancing smart home automation capabilities.
Script Flow
-
Retrieve Serial and Model Numbers: The script reads the serial number from
/proc/device-tree/serial-number
and the model number from/proc/device-tree/model
. -
Generate Avahi Configuration: The script defines the new Avahi service configuration, including HTTP and HTTPS services with associated TXT records for serial and model numbers.
-
Compute Configuration Hashes: The script computes the MD5 hash of the current and new configurations to determine if updates are necessary.
-
Update Avahi Service File: If the configuration has changed, the script writes the new configuration to the Avahi service file.
-
Install and Start Avahi: The script checks if Avahi is installed, installs it if necessary, and ensures the Avahi daemon is enabled and started, if not disabled by the user.