ascension

Migrate DNS zones to the GNU Name System
Log | Files | Refs | README | LICENSE

commit 3d9b0cb2a4cb7f0a86d128c6a8afc8e006e0e1cb
parent 8c52d3b3235a6862fdd4675087871c6a7f8fed9c
Author: rexxnor <rexxnor+gnunet@brief.li>
Date:   Fri, 10 May 2019 00:27:06 +0200

bugfixes, improved config file

Diffstat:
Mascension/ascension.py | 3+++
Adebian/ascension-bind-0.0.1/debian/.debhelper/generated/ascension-bind/installed-by-dh_installdocs | 0
Mdebian/ascension-bind-0.0.1/debian/ascension-bind.config | 18+++++++++++++++---
Mdebian/ascension-bind-0.0.1/debian/ascension-bind.postrm.debhelper | 2+-
Mdebian/ascension-bind-0.0.1/debian/ascension-bind.templates | 1-
Mdebian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/config | 92+++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
Mdebian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/templates | 1-
Ddebian/ascension-bind-0.0.1/debian/debhelper-build-stamp | 1-
8 files changed, 76 insertions(+), 42 deletions(-)

diff --git a/ascension/ascension.py b/ascension/ascension.py @@ -136,6 +136,9 @@ class Ascender(): except dns.resolver.NXDOMAIN: logging.warning("The domain '%s' is not publicly resolvable.", domain) + except Exception: + logging.warning("The domain '%s' is not publicly resolvable.", + domain) try: if resolver: diff --git a/debian/ascension-bind-0.0.1/debian/.debhelper/generated/ascension-bind/installed-by-dh_installdocs b/debian/ascension-bind-0.0.1/debian/.debhelper/generated/ascension-bind/installed-by-dh_installdocs diff --git a/debian/ascension-bind-0.0.1/debian/ascension-bind.config b/debian/ascension-bind-0.0.1/debian/ascension-bind.config @@ -15,7 +15,7 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } #read -r zones < installedzones zonelist=$(grep "^zone" < /etc/bind/named.conf.local | grep -vE "(arpa|localhost|\"\.\")" | cut -d '"' -f2) -zonelist=${zonelist// /, /} +zonelist=$(echo $zonelist | sed 's/\n/ /g' | sed 's/ /, /g') #altzonelist=$(named-checkconf -z | grep -P "\d{4,}$") #altzones=("$altzonelist") @@ -37,6 +37,7 @@ db_subst ascension-bind/zones choices "$zonelist" db_fset ascension-bind/zones seen false db_input high ascension-bind/zones || true db_go || true + # fix the zone selection db_get ascension-bind/zones echo "$RET" | sed 's/ //g' | sed 's/,/\n/g' > selectedzones @@ -46,9 +47,14 @@ db_fset ascension-bind/publishing seen false db_input medium ascension-bind/publishing || true db_go || true PUBLIC=$RET + zonestatus=true for ZONE in "${zones[@]}" do + echo "$ZONE" | hexdump -C + ZONE=echo "$ZONE" | tr -d '\n' + echo "$ZONE" | hexdump -C + exit 1 zonestatus=zonestatus && ascension "$ZONE" -n localhost done @@ -66,6 +72,7 @@ if [ -z $zonestatus ]; then zonestatus=true for ZONE in "${zones[@]}" do + ZONE=${ZONE} | tr -d '\n' zonestatus=zonestatus && ascension "$ZONE" -n localhost done if [ -z $zonestatus ]; then @@ -81,6 +88,7 @@ fi mkdir -p /etc/ascension.d/ for ZONE in "${zones[@]}" do + ZONE=${ZONE} | tr -d '\n' echo "Creating ascension import config files for $ZONE" cat > "/etc/ascension.d/bind-import-$ZONE.conf" << EOF [ascension] @@ -107,10 +115,14 @@ EOF ln -sf "/etc/ascension.d/ascension-bind-$ZONE.service" "/lib/systemd/system/ascension-bind-$ZONE.service" done +for ZONE in "${zones[@]}" do + ZONE=${ZONE} | tr -d '\n' echo "Starting and enabling ascension-bind-$ZONE" - deb-systemd-invoke start "ascension-bind-$ZONE" - deb-systemd-invoke enable "ascension-bind-$ZONE" + systemctl start "ascension-bind-$ZONE" + systemctl enable "ascension-bind-$ZONE" + #deb-systemd-invoke start "ascension-bind-$ZONE" + #deb-systemd-invoke enable "ascension-bind-$ZONE" done exit 0 diff --git a/debian/ascension-bind-0.0.1/debian/ascension-bind.postrm.debhelper b/debian/ascension-bind-0.0.1/debian/ascension-bind.postrm.debhelper @@ -1,4 +1,4 @@ -# Automatically added by dh_installdebconf +# Automatically added by dh_installdebconf/12.1.1~bpo9+1 if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then . /usr/share/debconf/confmodule db_purge diff --git a/debian/ascension-bind-0.0.1/debian/ascension-bind.templates b/debian/ascension-bind-0.0.1/debian/ascension-bind.templates @@ -4,7 +4,6 @@ Choices: ${zonelist} Description: Which zones do you want to migrate to the GNU Name System? Please select the zones you want to have migrated into the GNU Name System. - Template: ascension-bind/publishing Type: boolean Default: true diff --git a/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/config b/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/config @@ -14,53 +14,82 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 } #grep "Zone dump" /var/cache/bind/named_dump.db | grep -v "arpa" | grep "IN" | grep -v localhost > installedzones #read -r zones < installedzones -zonelist=$(grep "^zone" < /etc/bind/named.conf.local | grep -vE "(arpa|localhost|\"\.\")" | grep -v "allow-transfer" | cut -d '"' -f2) -zonelist=$(echo $zonelist | sed 's/ /, /g') +zonelist=$(grep "^zone" < /etc/bind/named.conf.local | grep -vE "(arpa|localhost|\"\.\")" | cut -d '"' -f2) +zonelist=$(echo $zonelist | sed 's/\n/ /g' | sed 's/ /, /g') #altzonelist=$(named-checkconf -z | grep -P "\d{4,}$") #altzones=("$altzonelist") -#echo $zonelist -#echo $altzonelist -#echo $altzones - #if [ ${#zones[@]} -eq ${#altzones[@]} ]; then #db_metaget ascension-bind/zones choices #echo "$RET" #db_set ascension-bind/zones 'foo.bar, this.does.not.work' #db_subst ascension-bind/zones choices "mine, this.does.work" #db_set ascension-bind/zones "foo.bar, this.does.not.work" - -if [ -n "$(ls -A /etc/ascension.d/)" ]; then - echo "there seem to be config files already" -fi +#if grep allow-transfer < /etc/bind/named.conf &> /dev/null; then +# db_fset ascension-bind/transfer-allowed seen false +# db_input high ascension-bind/transfer-allowed +# db_go || true +# exit 1 +#fi db_set ascension-bind/zones "$zonelist" db_subst ascension-bind/zones choices "$zonelist" db_fset ascension-bind/zones seen false db_input high ascension-bind/zones || true db_go || true + # fix the zone selection db_get ascension-bind/zones - -echo "$RET" | sed 's/ //g' | sed 's/,/\n/g' | sed '/^ *$/d' > selectedzones +echo "$RET" | sed 's/ //g' | sed 's/,/\n/g' > selectedzones readarray zones < selectedzones -rm selectedzones - -if [ ${#zones[@]} -eq 0 ]; then - echo "No zones to enable zonetransfer on" - exit 0 -fi db_fset ascension-bind/publishing seen false db_input medium ascension-bind/publishing || true db_go || true PUBLIC=$RET +zonestatus=true +for ZONE in "${zones[@]}" +do + echo "$ZONE" | hexdump -C + ZONE=echo "$ZONE" | tr -d '\n' + echo "$ZONE" | hexdump -C + exit 1 + zonestatus=zonestatus && ascension "$ZONE" -n localhost +done + +if [ -z $zonestatus ]; then + echo "Some zones don't allow zone transfer" + if grep allow-transfer /etc/bind/named.conf* &> /dev/null; then + db_fset ascension-bind/transfer-allowed seen false + db_input high ascension-bind/transfer-allowed + db_go || true + exit 1 + else + echo "Trying to allow zone transfer on localhost in global configuration" + sed -i.backup -r 's|(^[^\n\S]*options\s?{)|\1 allow\-transfer { localhost; }; |g' /etc/bind/named.conf.options + systemctl reload bind9 + zonestatus=true + for ZONE in "${zones[@]}" + do + ZONE=${ZONE} | tr -d '\n' + zonestatus=zonestatus && ascension "$ZONE" -n localhost + done + if [ -z $zonestatus ]; then + db_fset ascension-bind/transfer-allowed seen false + db_input high ascension-bind/transfer-allowed + db_go || true + exit 1 + fi + echo "Zone transfer possible, continuing" + fi +fi + mkdir -p /etc/ascension.d/ for ZONE in "${zones[@]}" do - ZONE=$(echo "$ZONE" | tr -d '\n' | tr '.' '_') - echo "creating ascension import config files" + ZONE=${ZONE} | tr -d '\n' + echo "Creating ascension import config files for $ZONE" cat > "/etc/ascension.d/bind-import-$ZONE.conf" << EOF [ascension] ZONE = $ZONE @@ -68,11 +97,9 @@ TRANSFERNS = localhost PORT = 53 PUBLIC = $PUBLIC EOF -touch "/etc/ascension.d/bind-import-$ZONE.conf" -echo "editing config to allow local zone transfer" -sed -i.backup -r 's|(^[^\n\S]*zone\s\"[a-zA-Z.]*\".*\{)|\1 allow\-transfer { localhost; }; |g' /etc/bind/named.conf.local -echo "creating systemd unit file" -cat > "/etc/ascension.d/ascension-bind-$ZONE.service" << EOF + touch "/etc/ascension.d/bind-import-$ZONE.conf" + echo "Creating systemd unit file." + cat > "/etc/ascension.d/ascension-bind-$ZONE.service" << EOF [Unit] Description=Ascension-bind for $ZONE After=gnunet-ascension.service @@ -85,22 +112,17 @@ ExecStart=/usr/bin/ascension $ZONE -n localhost [Install] WantedBy=multi-user.target EOF -ln -sf "/etc/ascension.d/ascension-bind-$ZONE.service" "/lib/systemd/system/ascension-bind-$ZONE.service" + ln -sf "/etc/ascension.d/ascension-bind-$ZONE.service" "/lib/systemd/system/ascension-bind-$ZONE.service" done -if systemctl reload bind9; then - echo "reconfiguring failed, restoring original state" - mv /etc/bind/named.conf.local.backup /etc/bind/named.conf.local - systemctl reload bind9 - exit 1 -fi - for ZONE in "${zones[@]}" do - ZONE=$(echo "$ZONE" | tr -d '\n' | tr '.' '_') - echo "starting and enabling ascension-bind-$ZONE" + ZONE=${ZONE} | tr -d '\n' + echo "Starting and enabling ascension-bind-$ZONE" systemctl start "ascension-bind-$ZONE" systemctl enable "ascension-bind-$ZONE" + #deb-systemd-invoke start "ascension-bind-$ZONE" + #deb-systemd-invoke enable "ascension-bind-$ZONE" done exit 0 diff --git a/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/templates b/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/templates @@ -4,7 +4,6 @@ Choices: ${zonelist} Description: Which zones do you want to migrate to the GNU Name System? Please select the zones you want to have migrated into the GNU Name System. - Template: ascension-bind/publishing Type: boolean Default: true diff --git a/debian/ascension-bind-0.0.1/debian/debhelper-build-stamp b/debian/ascension-bind-0.0.1/debian/debhelper-build-stamp @@ -1 +0,0 @@ -ascension-bind