@@ -10,7 +10,6 @@ rpz_example=$(cat <<EOF
10
10
ok.example.com CNAME rpz-passthru.
11
11
EOF
12
12
)
13
-
14
13
# create example RPZ
15
14
echo " $rpz_example " >> $rpz_file
16
15
@@ -21,14 +20,8 @@ local-data:
21
20
watchdog: false
22
21
EOF
23
22
)
24
-
25
- # configure RPZ file
23
+ # add RPZ to config
26
24
echo " $rpz_conf " >> /etc/knot-resolver/config.yaml
27
- kresctl reload
28
- if [ " $? " -ne " 0" ]; then
29
- echo " Could not set RPZ."
30
- exit 1
31
- fi
32
25
33
26
function count_errors(){
34
27
echo " $( journalctl -u knot-resolver.service | grep -c error) "
@@ -38,35 +31,39 @@ function count_reloads(){
38
31
echo " $( journalctl -u knot-resolver.service | grep -c " Reloading policy rules has finished" ) "
39
32
}
40
33
41
- # test that RPZ watchdog is turned off
34
+ # test that RPZ watchdog
42
35
# {{
43
36
44
37
err_count=$( count_errors)
45
38
rel_count=$( count_reloads)
46
39
40
+ # reload config with RPZ configured without watchdog turned on
41
+ kresctl reload
42
+ sleep 1
47
43
if [ $( count_errors) -ne $err_count ] || [ $( count_reloads) -ne $rel_count ]; then
48
44
echo " RPZ file watchdog is running (should not) or other errors occurred."
49
45
exit 1
50
46
fi
51
47
52
- # }}
53
-
54
48
# configure RPZ file and turn on watchdog
55
49
kresctl config set -p /local-data/rpz/0/watchdog true
50
+ sleep 1
56
51
if [ " $? " -ne " 0" ]; then
57
52
echo " Could not turn on RPZ file watchdog."
58
53
exit 1
59
54
fi
60
55
61
- # test modification
56
+ # }}
57
+
58
+ # test RPZ modification
62
59
# {{
63
60
64
61
# modify RPZ file, it will trigger reload
65
62
rel_count=$( count_reloads)
66
63
echo " 32.1.2.0.192.rpz-client-ip CNAME rpz-passthru." >> $rpz_file
67
64
68
65
# wait for files reload to finish
69
- sleep 10
66
+ sleep 6
70
67
71
68
if [ $( count_errors) -ne $err_count ] || [ $( count_reloads) -eq $rel_count ]; then
72
69
echo " Could not reload modified RPZ file."
0 commit comments