]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/unbound_cache.cmd
Vendor import of Unbound 1.9.2.
[FreeBSD/FreeBSD.git] / contrib / unbound_cache.cmd
1 @echo off\r
2 rem --------------------------------------------------------------\r
3 rem -- DNS cache save/load script\r
4 rem --\r
5 rem -- Version 1.2\r
6 rem -- By Yuri Voinov (c) 2014\r
7 rem --------------------------------------------------------------\r
8 \r
9 rem Variables\r
10 set prefix="C:\Program Files (x86)"\r
11 set program_path=%prefix%\Unbound\r
12 set uc=%program_path%\unbound-control.exe\r
13 set fname="unbound_cache.dmp"\r
14 \r
15 rem Check Unbound installed\r
16 if exist %uc% goto start\r
17 echo Unbound control not found. Exiting...\r
18 exit 1\r
19 \r
20 :start\r
21 \r
22 rem arg1 - command (optional)\r
23 rem arg2 - file name (optional)\r
24 set arg1=%1\r
25 set arg2=%2\r
26 \r
27 if /I "%arg1%" == "-h" goto help\r
28 \r
29 if "%arg1%" == "" (\r
30 echo Loading cache from %program_path%\%fname%\r
31 dir /a %program_path%\%fname%\r
32 type %program_path%\%fname%|%uc% load_cache\r
33 goto end\r
34 )\r
35 \r
36 if defined %arg2% (goto Not_Defined) else (goto Defined)\r
37 \r
38 rem If file not specified; use default dump file\r
39 :Not_defined\r
40 if /I "%arg1%" == "-s" (\r
41 echo Saving cache to %program_path%\%fname%\r
42 %uc% dump_cache>%program_path%\%fname%\r
43 dir /a %program_path%\%fname%\r
44 echo ok\r
45 goto end\r
46 )\r
47 \r
48 if /I "%arg1%" == "-l" (\r
49 echo Loading cache from %program_path%\%fname%\r
50 dir /a %program_path%\%fname%\r
51 type %program_path%\%fname%|%uc% load_cache\r
52 goto end\r
53 )\r
54 \r
55 if /I "%arg1%" == "-r" (\r
56 echo Saving cache to %program_path%\%fname%\r
57 dir /a %program_path%\%fname%\r
58 %uc% dump_cache>%program_path%\%fname%\r
59 echo ok\r
60 echo Loading cache from %program_path%\%fname%\r
61 type %program_path%\%fname%|%uc% load_cache\r
62 goto end\r
63 )\r
64 \r
65 rem If file name specified; use this filename\r
66 :Defined\r
67 if /I "%arg1%" == "-s" (\r
68 echo Saving cache to %arg2%\r
69 %uc% dump_cache>%arg2%\r
70 dir /a %arg2%\r
71 echo ok\r
72 goto end\r
73 )\r
74 \r
75 if /I "%arg1%" == "-l" (\r
76 echo Loading cache from %arg2%\r
77 dir /a %arg2%\r
78 type %arg2%|%uc% load_cache\r
79 goto end\r
80 )\r
81 \r
82 if /I "%arg1%" == "-r" (\r
83 echo Saving cache to %arg2%\r
84 dir /a %arg2%\r
85 %uc% dump_cache>%arg2%\r
86 echo ok\r
87 echo Loading cache from %arg2%\r
88 type %arg2%|%uc% load_cache\r
89 goto end\r
90 )\r
91 \r
92 :help\r
93 echo Usage: unbound_cache.cmd [-s] or [-l] or [-r] or [-h] [filename]\r
94 echo.\r
95 echo l - Load - default mode. Warming up Unbound DNS cache from saved file. cache-ttl must be high value.\r
96 echo s - Save - save Unbound DNS cache contents to plain file with domain names.\r
97 echo r - Reload - reloadind new cache entries and refresh existing cache\r
98 echo h - this screen.\r
99 echo filename - file to save/load dumped cache. If not specified, %program_path%\%fname% will be used instead.\r
100 echo Note: Run without any arguments will be in default mode.\r
101 echo       Also, unbound-control must be configured.\r
102 exit 1\r
103 \r
104 :end\r
105 exit 0\r