1
0

update-dhcpd 775 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. logger -t dhcpd "Refresh dnsmasq config request"
  3. /usr/local/scripts/sync_user_dhcp.pl
  4. /usr/local/scripts/print-dhcpd-km135.pl >/tmp/mac-all
  5. ret=$?
  6. if [ ${ret} -ne 0 ]; then
  7. exit
  8. fi
  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. service dnsmasq restart >/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