Changeset View
Changeset View
Standalone View
Standalone View
unbound.in
- This file was copied to systemd-resolved.in.
| #!/bin/sh | #!/bin/sh | ||||
| # Copyright (c) 2009-2016 Roy Marples | # Copyright (c) 2009-2023 Roy Marples | ||||
| # All rights reserved | # All rights reserved | ||||
| # unbound subscriber for resolvconf | # unbound subscriber for resolvconf | ||||
| # Redistribution and use in source and binary forms, with or without | # Redistribution and use in source and binary forms, with or without | ||||
| # modification, are permitted provided that the following conditions | # modification, are permitted provided that the following conditions | ||||
| # are met: | # are met: | ||||
| # * Redistributions of source code must retain the above copyright | # * Redistributions of source code must retain the above copyright | ||||
| Show All 11 Lines | |||||
| # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| unbound_insecure= | unbound_insecure= | ||||
| unbound_private= | |||||
| [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0 | [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0 | ||||
| . "@SYSCONFDIR@/resolvconf.conf" || exit 1 | . "@SYSCONFDIR@/resolvconf.conf" || exit 1 | ||||
| [ -z "$unbound_conf" ] && exit 0 | [ -z "$unbound_conf" ] && exit 0 | ||||
| [ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)" | [ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)" | ||||
| NL=" | NL=" | ||||
| " | " | ||||
| : ${unbound_pid:=/var/run/unbound.pid} | : ${unbound_pid:=/var/run/unbound.pid} | ||||
| : ${unbound_service:=unbound} | : ${unbound_service:=unbound} | ||||
| newconf="# Generated by resolvconf$NL" | newconf="# Generated by resolvconf$NL" | ||||
| for d in $DOMAINS; do | for d in $DOMAINS; do | ||||
| dn="${d%%:*}" | dn="${d%%:*}" | ||||
| ns="${d#*:}" | ns="${d#*:}" | ||||
| create_unbound_insecure=false | |||||
| create_unbound_private=false | |||||
| case "$unbound_insecure" in | case "$unbound_insecure" in | ||||
| [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) | [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) | ||||
| create_unbound_insecure=true ;; | |||||
| esac | |||||
| case "$unbound_private" in | |||||
| [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) | |||||
| create_unbound_private=true ;; | |||||
| esac | |||||
| if $create_unbound_insecure || $create_unbound_private; then | |||||
| newconf="$newconf${NL}server:$NL" | newconf="$newconf${NL}server:$NL" | ||||
| if $create_unbound_insecure; then | |||||
| newconf="$newconf domain-insecure: \"$dn\"$NL" | newconf="$newconf domain-insecure: \"$dn\"$NL" | ||||
| ;; | fi | ||||
| esac | if $create_unbound_private; then | ||||
| newconf="$newconf private-domain: \"$dn\"$NL" | |||||
| fi | |||||
| fi | |||||
| newconf="$newconf${NL}forward-zone:$NL name: \"$dn\"$NL" | newconf="$newconf${NL}forward-zone:$NL name: \"$dn\"$NL" | ||||
| if [ -n "$unbound_forward_zone_options" ]; then | |||||
| newconf="$newconf $unbound_forward_zone_options${NL}" | |||||
| fi | |||||
| while [ -n "$ns" ]; do | while [ -n "$ns" ]; do | ||||
| newconf="$newconf forward-addr: ${ns%%,*}$NL" | newconf="$newconf forward-addr: ${ns%%,*}$NL" | ||||
| [ "$ns" = "${ns#*,}" ] && break | [ "$ns" = "${ns#*,}" ] && break | ||||
| ns="${ns#*,}" | ns="${ns#*,}" | ||||
| done | done | ||||
| done | done | ||||
| if [ -n "$NAMESERVERS" ]; then | if [ -n "$NAMESERVERS" ]; then | ||||
| newconf="$newconf${NL}forward-zone:$NL name: \".\"$NL" | newconf="$newconf${NL}forward-zone:$NL name: \".\"$NL" | ||||
| if [ -n "$unbound_forward_zone_options" ]; then | |||||
| newconf="$newconf $unbound_forward_zone_options${NL}" | |||||
| fi | |||||
| for n in $NAMESERVERS; do | for n in $NAMESERVERS; do | ||||
| newconf="$newconf forward-addr: $n$NL" | newconf="$newconf forward-addr: $n$NL" | ||||
| done | done | ||||
| fi | fi | ||||
| # Try to ensure that config dirs exist | # Try to ensure that config dirs exist | ||||
| if type config_mkdirs >/dev/null 2>&1; then | if command -v config_mkdirs >/dev/null 2>&1; then | ||||
| config_mkdirs "$unbound_conf" | config_mkdirs "$unbound_conf" | ||||
| else | else | ||||
| @SBINDIR@/resolvconf -D "$unbound_conf" | @SBINDIR@/resolvconf -D "$unbound_conf" | ||||
| fi | fi | ||||
| restart_unbound() | restart_unbound() | ||||
| { | { | ||||
| if [ -n "$unbound_restart" ]; then | if [ -n "$unbound_restart" ]; then | ||||
| Show All 22 Lines | |||||