dns_runner.php 941 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. ## old PHP memory leaked a lot. die after 6 hours and let systemd restart
  3. $delay = 6;
  4. $end_ts = time() + ($delay*3600);
  5. $path = realpath(dirname(__FILE__));
  6. $refresh_root_hint_days = 7;
  7. while (time() < $end_ts) {
  8. if (file_exists("{$path}/../data/ubound_force_reload.lck")) {
  9. print ("DNS Refresh required\n");
  10. @unlink("{$path}/../data/ubound_force_reload.lck");
  11. exec("cp {$path}/../data/unbound.conf.d/* /etc/unbound/unbound.conf.d/");
  12. # Keep root.hints reasonbly up to date without being obnoxious
  13. if (!file_exists("/etc/unbound/root.hints") || ((time() - filemtime("/etc/unbound/root.hints")) > ($refresh_root_hint_days * 86400))){
  14. system("curl -o /etc/unbound/root.hints https://www.internic.net/domain/named.cache");
  15. }
  16. system("systemctl restart unbound");
  17. }
  18. sleep(5);
  19. }