#!/bin/sh

. /etc/init.d/init-functions

case "$1" in
	start)
		notify "Starting dnsmasq "
		sleep 1
		/usr/bin/dnsmasq --user=dnsmasq --pid-file=/var/run/dnsmasq.pid
		echo "nameserver 0.0.0.0" > /etc/resolv.conf
		check $?
		;;
	stop)
		notify "\nStopping dnsmasq "
		if [ -f /var/run/dnsmasq.pid ]; then
			kill $(cat /var/run/dnsmasq.pid) &> /dev/null
			check $?
			rm /var/run/dnsmasq &> /dev/null
		else
			notify "[$Red Dnsmasq is not running $Color_Off]\n"
		fi
		;;
	restart|reload)
		"$0" stop
		"$0" start
		;;
	*)
		echo "dnsmasq init script usage: $0 {start|stop|restart}"
		return 1
esac
return $?
