From c6563f0523bdd24a88bb4766509494c23d43e38f Mon Sep 17 00:00:00 2001 From: Warren Baker Date: Mon, 31 Jan 2011 18:40:03 +0200 Subject: Remove manual user deletion (its handled by the pkg removal process). Also added Cache Restoration support, so the existing cache is dumped to disk and restored in case of a service restart, reboot or shutdown of the server. --- config/unbound/unbound.inc | 24 +++++++++++++++++++++--- config/unbound/unbound.xml | 6 ++++++ 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'config/unbound') diff --git a/config/unbound/unbound.inc b/config/unbound/unbound.inc index 8cb14aae..eafafcb9 100644 --- a/config/unbound/unbound.inc +++ b/config/unbound/unbound.inc @@ -119,6 +119,7 @@ function unbound_rc_setup() { fetch_root_hints(); unbound_control(\"start\"); unbound_control(\"forward\"); + unbound_control(\"restore_cache\"); echo \"done.\\n\"; ?> ENDPHP\n"; @@ -127,6 +128,7 @@ $stop = "/usr/local/bin/php -q -d auto_prepend_file=config.inc < @@ -154,6 +156,7 @@ function unbound_control($action) { global $config, $g; $unbound_config = $config['installedpackages']['unbound']['config'][0]; + $cache_dumpfile = "/var/tmp/unbound_cache"; switch ($action) { case "forward": @@ -206,6 +209,21 @@ function unbound_control($action) { //Stop Unbound by sigkillbypid(); sigkillbypid("{$g['varrun_path']}/unbound.pid", "TERM"); break; + + case "dump_cache": + //Dump Unbound's Cache + if($unbound_config['dumpcache'] == "on") + unbound_ctl_exec("dump_cache > $cache_dumpfile"); + break; + + case "restore_cache": + //Restore Unbound's Cache + if($unbound_config['dumpcache'] == "on") { + $cache_dumpfile = "/var/tmp/unbound_cache"; + if(file_exists($cache_dumpfile)) + unbound_ctl_exec("load_cache < $cache_dumpfile"); + } + break; default: break; @@ -555,14 +573,17 @@ function unbound_reconfigure() { if ($unbound_config['unbound_status'] != "on") { if(is_service_running("unbound")) { + unbound_control("dump_cache"); unbound_control("termstop"); } } else { if(is_service_running("unbound")) { + unbound_control("dump_cache"); unbound_control("termstop"); } unbound_resync_config(); unbound_control("start"); + unbound_control("restore_cache"); unbound_control("forward"); } } @@ -578,9 +599,6 @@ function unbound_uninstall() { mwexec("rm -f /usr/local/etc/rc.d/unbound.sh"); mwexec("rm -f {$g['varlog_path']}/unbound.log"); - // Remove unbound user - exec("/usr/sbin/pw userdel unbound"); - conf_mount_ro(); } diff --git a/config/unbound/unbound.xml b/config/unbound/unbound.xml index 85ab6173..f7bcbf2b 100644 --- a/config/unbound/unbound.xml +++ b/config/unbound/unbound.xml @@ -170,6 +170,12 @@ checkbox on + + dumpcache + Cache Restoration Support + This option allows the restoration of the current Unbound cache, so that in the event of a reboot or shutdown the cache is restored instantly. This helps speed up DNS resolving. + checkbox + Unbound Statistics listtopic -- cgit v1.2.3