Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fortitudepub/74c860329535ddfaf9a089c6bb107191 to your computer and use it in GitHub Desktop.
Save fortitudepub/74c860329535ddfaf9a089c6bb107191 to your computer and use it in GitHub Desktop.
A simle dnsmasq status check and restart when needed because it might listen to tailscale IP.
#!/bin/bash
logger -t "dnsmasqlivecheck" "dnsmasq live check run"
if [[ ! -f /run/dnsmasq/dnsmasq.pid ]]; then
logger -t "dnsmasqlivecheck" "dnsmasq pid not present, restart"
systemctl restart dnsmasq
exit 1
fi
pid=`cat /run/dnsmasq/dnsmasq.pid`
if [[ ! -f /proc/$pid/cmdline ]]; then
logger -t "dnsmasqlivecheck" "dnsmasq pid is stale, restart"
systemctl restart dnsmasq
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment