Skip to content

Instantly share code, notes, and snippets.

@tarao
Created July 5, 2013 17:46
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 tarao/5936099 to your computer and use it in GitHub Desktop.
Save tarao/5936099 to your computer and use it in GitHub Desktop.
#!/bin/sh
# /etc/libvirt/hooks/daemon
net="default"
pidfile="/var/run/libvirt/network/$net.pid"
dnsmasq="/usr/sbin/dnsmasq"
config="/var/lib/libvirt/dnsmasq/$net.conf"
case $2 in
start)
( sleep 1 && pgrep -F "$pidfile" dnsmasq >/dev/null && {
pid=`cat "$pidfile"`
kill "$pid"
rm -f "$pidfile"
sed -i '/^domain-needed$/d; /^local=/d' "$config"
start-stop-daemon --start --quiet --pidfile "$pidfile" \
--exec "$dnsmasq" -- --conf-file="$config"
} ) </dev/null 2>/dev/null 1>&2 & # async
;;
esac
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment