diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2012-08-03 09:58:09 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-08-03 09:58:09 +0000 |
commit | 7c08058fac709df4e6f49184048501dc890de028 (patch) | |
tree | 292e485bdc50530d4da98fbeb33b760911a52a23 /main/unbound/migrate-dnscache-to-unbound | |
parent | 9d1db9e42cf8bb4fe6a7fa5954e366d856991839 (diff) | |
download | aports-7c08058fac709df4e6f49184048501dc890de028.tar.bz2 aports-7c08058fac709df4e6f49184048501dc890de028.tar.xz |
main/unbound: upgrade to 1.4.18
Diffstat (limited to 'main/unbound/migrate-dnscache-to-unbound')
-rw-r--r-- | main/unbound/migrate-dnscache-to-unbound | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/main/unbound/migrate-dnscache-to-unbound b/main/unbound/migrate-dnscache-to-unbound new file mode 100644 index 000000000..a2ad99e4f --- /dev/null +++ b/main/unbound/migrate-dnscache-to-unbound @@ -0,0 +1,67 @@ +#!/bin/sh + + +to_subnet() { + pref=$1 + case "$pref" in + *.*.*.*) echo $pref/32;; + *.*.*) echo $pref.0/24;; + *.*) echo $pref.0.0/16;; + *) echo $pref.0.0.0/8;; + esac +} + +gen_stub_zones() { + local zonefile ip + local fwdtype="stub" + if [ -n "$FORWARDONLY" ]; then + fwdtype="forward" + fi + for zonefile in "$root"/etc/dnscache/servers/*; do + local zone=${zonefile##*/} + if [ "$zone" = "@" ] || [ "$zone" = '*' ]; then + continue + fi + + echo "${fwdtype}-zone:" + echo -e "\tname: ${zone}" + for ip in $(cat $zonefile); do + echo -e "\t${fwdtype}-addr: $ip" + done + echo "" + done +} + +root=${root:-/} +while getopts "r:" opt; do + case "$opt" in + 'r') root="$OPTARG";; + esac +done + +confd="$root"/etc/conf.d/dnscache +if [ -r "$confd" ]; then + . "$confd" +fi + +interface="$IP" +outgoing_interface="$IPSEND" + +echo $IPSEND +echo $IP +echo $FORWARDONLY + +for i in "$root"/etc/dnscache/ip/*; do + [ -f "$i" ] || continue + access_control="$access_control $(to_subnet ${i##*/})" +done + +echo -e "\tinterface: $IP\n" +echo -e "\toutgoing-interface: $IPSEND\n" +for i in $access_control; do + echo -e "\taccess-control: $i allow" +done +echo "" + +gen_stub_zones + |