Skip to content

Instantly share code, notes, and snippets.

@ahoka ahoka/dnsmasq_inventory.sh
Last active Feb 17, 2016

Embed
What would you like to do?
#!/bin/sh
if [ "$1" = "--list" ]
then
echo "{"
echo " \"nodes\": {"
echo -n " \"hosts\": ["
first=1
for host in $(cut -d ' ' -f 3 /var/lib/libvirt/dnsmasq/default.leases)
do
if [ $first -eq 1 ]
then
first=0
echo -n " \"${host}\""
else
echo -n ", \"${host}\""
fi
done
echo " ]"
echo " }"
echo "}"
else
echo "{}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.