monero/external/unbound/contrib/unbound_cache.cmd

106 lines
2.6 KiB
Batchfile
Raw Normal View History

2014-10-05 15:44:31 -06:00
@echo off
rem --------------------------------------------------------------
rem -- DNS cache save/load script
rem --
2015-04-02 03:16:18 -06:00
rem -- Version 1.2
2014-10-05 15:44:31 -06:00
rem -- By Yuri Voinov (c) 2014
rem --------------------------------------------------------------
rem Variables
set prefix="C:\Program Files (x86)"
set program_path=%prefix%\Unbound
set uc=%program_path%\unbound-control.exe
set fname="unbound_cache.dmp"
rem Check Unbound installed
if exist %uc% goto start
echo Unbound control not found. Exiting...
exit 1
:start
2015-04-02 03:16:18 -06:00
rem arg1 - command (optional)
rem arg2 - file name (optional)
set arg1=%1
set arg2=%2
2014-10-05 15:44:31 -06:00
2015-04-02 03:16:18 -06:00
if /I "%arg1%" == "-h" goto help
2014-10-05 15:44:31 -06:00
2015-04-02 03:16:18 -06:00
if "%arg1%" == "" (
2014-10-05 15:44:31 -06:00
echo Loading cache from %program_path%\%fname%
2015-04-02 03:16:18 -06:00
dir /a %program_path%\%fname%
2014-10-05 15:44:31 -06:00
type %program_path%\%fname%|%uc% load_cache
goto end
)
2015-04-02 03:16:18 -06:00
if defined %arg2% (goto Not_Defined) else (goto Defined)
rem If file not specified; use default dump file
:Not_defined
if /I "%arg1%" == "-s" (
2014-10-05 15:44:31 -06:00
echo Saving cache to %program_path%\%fname%
%uc% dump_cache>%program_path%\%fname%
2015-04-02 03:16:18 -06:00
dir /a %program_path%\%fname%
2014-10-05 15:44:31 -06:00
echo ok
goto end
)
2015-04-02 03:16:18 -06:00
if /I "%arg1%" == "-l" (
2014-10-05 15:44:31 -06:00
echo Loading cache from %program_path%\%fname%
2015-04-02 03:16:18 -06:00
dir /a %program_path%\%fname%
2014-10-05 15:44:31 -06:00
type %program_path%\%fname%|%uc% load_cache
goto end
)
2015-04-02 03:16:18 -06:00
if /I "%arg1%" == "-r" (
2014-10-05 15:44:31 -06:00
echo Saving cache to %program_path%\%fname%
2015-04-02 03:16:18 -06:00
dir /a %program_path%\%fname%
2014-10-05 15:44:31 -06:00
%uc% dump_cache>%program_path%\%fname%
echo ok
echo Loading cache from %program_path%\%fname%
type %program_path%\%fname%|%uc% load_cache
goto end
)
2015-04-02 03:16:18 -06:00
rem If file name specified; use this filename
:Defined
if /I "%arg1%" == "-s" (
echo Saving cache to %arg2%
%uc% dump_cache>%arg2%
dir /a %arg2%
echo ok
goto end
)
if /I "%arg1%" == "-l" (
echo Loading cache from %arg2%
dir /a %arg2%
type %arg2%|%uc% load_cache
goto end
)
if /I "%arg1%" == "-r" (
echo Saving cache to %arg2%
dir /a %arg2%
%uc% dump_cache>%arg2%
echo ok
echo Loading cache from %arg2%
type %arg2%|%uc% load_cache
goto end
)
2014-10-05 15:44:31 -06:00
:help
2015-04-02 03:16:18 -06:00
echo Usage: unbound_cache.cmd [-s] or [-l] or [-r] or [-h] [filename]
2014-10-05 15:44:31 -06:00
echo.
echo l - Load - default mode. Warming up Unbound DNS cache from saved file. cache-ttl must be high value.
echo s - Save - save Unbound DNS cache contents to plain file with domain names.
echo r - Reload - reloadind new cache entries and refresh existing cache
echo h - this screen.
2015-04-02 03:16:18 -06:00
echo filename - file to save/load dumped cache. If not specified, %program_path%\%fname% will be used instead.
2014-10-05 15:44:31 -06:00
echo Note: Run without any arguments will be in default mode.
echo Also, unbound-control must be configured.
exit 1
:end
2015-04-02 03:16:18 -06:00
exit 0