Fixes mDNS issue; when DHCP IP is present use this for mDNS and not the static fallback IP.
This commit is contained in:
@@ -12,6 +12,25 @@ if ! nmcli -g ipv4.addresses con show "Wired connection 1" 2>/dev/null | grep -q
|
||||
sudo nmcli con up "Wired connection 1"
|
||||
fi
|
||||
|
||||
# Configure Avahi to prefer DHCP address over static fallback for mDNS
|
||||
# Get the DHCP-assigned IP (first non-localhost, non-192.168.42.10 IP)
|
||||
DHCP_IP=$(ip -4 addr show eth0 2>/dev/null | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '^127\.' | grep -v "$(echo $FALLBACK_IP | sed 's/\/24//')" | head -n1)
|
||||
HOSTNAME=$(hostname)
|
||||
|
||||
if [ -n "$DHCP_IP" ]; then
|
||||
echo "DHCP address detected: $DHCP_IP, configuring Avahi to prefer it for mDNS"
|
||||
# Add entry to /etc/avahi/hosts to explicitly map hostname to DHCP IP
|
||||
sudo mkdir -p /etc/avahi
|
||||
echo "$DHCP_IP $HOSTNAME $HOSTNAME.local" | sudo tee /etc/avahi/hosts > /dev/null
|
||||
# Restart avahi to apply the hosts file
|
||||
sudo systemctl restart avahi-daemon
|
||||
else
|
||||
echo "No DHCP address detected, mDNS will use static fallback IP $FALLBACK_IP"
|
||||
# Remove hosts file to let Avahi advertise all IPs
|
||||
sudo rm -f /etc/avahi/hosts
|
||||
sudo systemctl restart avahi-daemon
|
||||
fi
|
||||
|
||||
# Copy system service file for frontend
|
||||
sudo cp /home/caster/bumble-auracast/src/service/auracast-frontend.service /etc/systemd/system/auracast-frontend.service
|
||||
|
||||
|
||||
Reference in New Issue
Block a user