Skip to content

Instantly share code, notes, and snippets.

@ahoka
Last active February 17, 2016 16:51
Show Gist options
  • Save ahoka/83d9cbb21c9df1c109a6 to your computer and use it in GitHub Desktop.
Save ahoka/83d9cbb21c9df1c109a6 to your computer and use it in GitHub Desktop.
#!/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