update-dnsmasq 763 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. logger -t dhcpd "Refresh dnsmasq config request"
  3. /usr/local/scripts/print-dnsmasq.pl >/tmp/mac-all
  4. ret=$?
  5. if [ ${ret} -ne 0 ]; then
  6. exit
  7. fi
  8. touch /etc/dnsmasq.d/mac-all
  9. diff -aqbBfi /tmp/mac-all /etc/dnsmasq.d/mac-all >/dev/null
  10. ret=$?
  11. if [ ${ret} -ne 0 ]; then
  12. logger -t dhcpd "Update dnsmasq config"
  13. cat /etc/dnsmasq.d/mac-all >/tmp/mac.old
  14. cat /tmp/mac-all >/etc/dnsmasq.d/mac-all
  15. /usr/sbin/dnsmasq --test >/dev/null 2>&1
  16. ret=$?
  17. if [ ${ret} -eq 0 ]; then
  18. systemctl restart dnsmasq>/dev/null
  19. else
  20. logger -t dhcpd "Config error! Rollback changes."
  21. cat /tmp/mac.old >/etc/dnsmasq.d/mac-all
  22. fi
  23. else
  24. logger -t dhcpd "Config not changed. Skip restart"
  25. fi
  26. logger -t dhcpd "done"
  27. exit