Skip to content

Instantly share code, notes, and snippets.

@frafra
Created May 15, 2015 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frafra/7a72d35a3f52fcebf12b to your computer and use it in GitHub Desktop.
Save frafra/7a72d35a3f52fcebf12b to your computer and use it in GitHub Desktop.
Seren autocalling local hosts using zeroconf/avahi
#!/usr/bin/bash
service="_seren._udp"
# Select a random host
host=$(avahi-browse -d local $service -tpr | grep ";$service;" | grep -e '^=;' | sort -R | head -n1)
avahi-publish -s "Seren for $(hostname)" $service 8110 &
pid=$!
if [ -z "$service" ]
then
seren -a
else
hostname=$(echo $host | cut -d\; -f7)
seren -ac $hostname
fi
kill $pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment