1276541Sdes@echo off 2276541Sdesrem -------------------------------------------------------------- 3276541Sdesrem -- DNS cache save/load script 4276541Sdesrem -- 5282009Sdesrem -- Version 1.2 6276541Sdesrem -- By Yuri Voinov (c) 2014 7276541Sdesrem -------------------------------------------------------------- 8276541Sdes 9276541Sdesrem Variables 10276541Sdesset prefix="C:\Program Files (x86)" 11276541Sdesset program_path=%prefix%\Unbound 12276541Sdesset uc=%program_path%\unbound-control.exe 13276541Sdesset fname="unbound_cache.dmp" 14276541Sdes 15276541Sdesrem Check Unbound installed 16276541Sdesif exist %uc% goto start 17276541Sdesecho Unbound control not found. Exiting... 18276541Sdesexit 1 19276541Sdes 20276541Sdes:start 21276541Sdes 22282009Sdesrem arg1 - command (optional) 23282009Sdesrem arg2 - file name (optional) 24282009Sdesset arg1=%1 25282009Sdesset arg2=%2 26276541Sdes 27282009Sdesif /I "%arg1%" == "-h" goto help 28276541Sdes 29282009Sdesif "%arg1%" == "" ( 30276541Sdesecho Loading cache from %program_path%\%fname% 31282009Sdesdir /a %program_path%\%fname% 32276541Sdestype %program_path%\%fname%|%uc% load_cache 33276541Sdesgoto end 34276541Sdes) 35276541Sdes 36282009Sdesif defined %arg2% (goto Not_Defined) else (goto Defined) 37282009Sdes 38282009Sdesrem If file not specified; use default dump file 39282009Sdes:Not_defined 40282009Sdesif /I "%arg1%" == "-s" ( 41276541Sdesecho Saving cache to %program_path%\%fname% 42276541Sdes%uc% dump_cache>%program_path%\%fname% 43282009Sdesdir /a %program_path%\%fname% 44276541Sdesecho ok 45276541Sdesgoto end 46276541Sdes) 47276541Sdes 48282009Sdesif /I "%arg1%" == "-l" ( 49276541Sdesecho Loading cache from %program_path%\%fname% 50282009Sdesdir /a %program_path%\%fname% 51276541Sdestype %program_path%\%fname%|%uc% load_cache 52276541Sdesgoto end 53276541Sdes) 54276541Sdes 55282009Sdesif /I "%arg1%" == "-r" ( 56276541Sdesecho Saving cache to %program_path%\%fname% 57282009Sdesdir /a %program_path%\%fname% 58276541Sdes%uc% dump_cache>%program_path%\%fname% 59276541Sdesecho ok 60276541Sdesecho Loading cache from %program_path%\%fname% 61276541Sdestype %program_path%\%fname%|%uc% load_cache 62276541Sdesgoto end 63276541Sdes) 64276541Sdes 65282009Sdesrem If file name specified; use this filename 66282009Sdes:Defined 67282009Sdesif /I "%arg1%" == "-s" ( 68282009Sdesecho Saving cache to %arg2% 69282009Sdes%uc% dump_cache>%arg2% 70282009Sdesdir /a %arg2% 71282009Sdesecho ok 72282009Sdesgoto end 73282009Sdes) 74282009Sdes 75282009Sdesif /I "%arg1%" == "-l" ( 76282009Sdesecho Loading cache from %arg2% 77282009Sdesdir /a %arg2% 78282009Sdestype %arg2%|%uc% load_cache 79282009Sdesgoto end 80282009Sdes) 81282009Sdes 82282009Sdesif /I "%arg1%" == "-r" ( 83282009Sdesecho Saving cache to %arg2% 84282009Sdesdir /a %arg2% 85282009Sdes%uc% dump_cache>%arg2% 86282009Sdesecho ok 87282009Sdesecho Loading cache from %arg2% 88282009Sdestype %arg2%|%uc% load_cache 89282009Sdesgoto end 90282009Sdes) 91282009Sdes 92276541Sdes:help 93282009Sdesecho Usage: unbound_cache.cmd [-s] or [-l] or [-r] or [-h] [filename] 94276541Sdesecho. 95276541Sdesecho l - Load - default mode. Warming up Unbound DNS cache from saved file. cache-ttl must be high value. 96276541Sdesecho s - Save - save Unbound DNS cache contents to plain file with domain names. 97276541Sdesecho r - Reload - reloadind new cache entries and refresh existing cache 98276541Sdesecho h - this screen. 99282009Sdesecho filename - file to save/load dumped cache. If not specified, %program_path%\%fname% will be used instead. 100276541Sdesecho Note: Run without any arguments will be in default mode. 101276541Sdesecho Also, unbound-control must be configured. 102276541Sdesexit 1 103276541Sdes 104276541Sdes:end 105282009Sdesexit 0 106