Skip to content

Instantly share code, notes, and snippets.

@gak
Last active August 29, 2015 14:06
Show Gist options
  • Save gak/1e4124fde555ef480fd9 to your computer and use it in GitHub Desktop.
Save gak/1e4124fde555ef480fd9 to your computer and use it in GitHub Desktop.
--- dnsmasq.old 2014-09-03 04:39:53.119771520 +0000
+++ dnsmasq 2014-09-03 05:21:11.718863850 +0000
@@ -143,9 +143,15 @@
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
- start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile /var/run/dnsmasq/$NAME.pid --name $NAME
- RETVAL="$?"
- [ "$RETVAL" = 2 ] && return 2
+
+ # -f so it doesn't complain if the file isn't there
+ RETVAL=2
+ if [ -f /var/run/dnsmasq/$NAME.pid ]; then
+ kill `cat /var/run/dnsmasq/$NAME.pid`
+ RETVAL="$?"
+ rm /var/run/dnsmasq/$NAME.pid
+ fi
+
return "$RETVAL"
}
@@ -164,10 +170,10 @@
# 1 if daemon is dead and pid file exists
# 3 if daemon is not running
# 4 if daemon status is unknown
- start-stop-daemon --start --quiet --pidfile /var/run/dnsmasq/$NAME.pid --exec $DAEMON --test > /dev/null
+ pidof $NAME > /dev/null
case "$?" in
- 0) [ -e "/var/run/dnsmasq/$NAME.pid" ] && return 1 ; return 3 ;;
- 1) return 0 ;;
+ 1) [ -e "/var/run/dnsmasq/$NAME.pid" ] && return 1 ; return 3 ;;
+ 0) return 0 ;;
*) return 4 ;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment