ascension

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

commit 85a136529851a709c9034b7b5cee56f50ddabe44
parent 748e800b610331545c810be19cdec27c38869508
Author: rexxnor <rexxnor+gnunet@brief.li>
Date:   Wed,  8 May 2019 15:03:42 +0200

updated files

Diffstat:
Mdebian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/config | 67+++++++++++++++++++++++++++++++++++++------------------------------
Mdebian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/control | 2+-
Mdebian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/postrm | 2+-
3 files changed, 39 insertions(+), 32 deletions(-)

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,8 +14,8 @@ ${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=$(cat /etc/bind/named.conf.local | grep "^zone" | grep -vE "(arpa|localhost|\"\.\")" | cut -d '"' -f2) -zonelist=$(echo $zonelist | sed "s/ /, /g") +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') #altzonelist=$(named-checkconf -z | grep -P "\d{4,}$") #altzones=("$altzonelist") @@ -29,11 +29,9 @@ zonelist=$(echo $zonelist | sed "s/ /, /g") #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 cat /etc/bind/named.conf.local | grep allow-transfer &> /dev/null; then - db_fset ascension-bind/transfer-allowed seen false - db_input high ascension-bind/transfer-allowed - db_go || true - exit 1 + +if [ -n "$(ls -A /etc/ascension.d/)" ]; then + echo "there seem to be config files already" fi db_set ascension-bind/zones "$zonelist" @@ -42,9 +40,16 @@ 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 +db_get ascension-bind/zones + +echo "$RET" | sed 's/ //g' | sed 's/,/\n/g' | sed '/^ *$/d' > 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 @@ -54,20 +59,20 @@ PUBLIC=$RET mkdir -p /etc/ascension.d/ for ZONE in "${zones[@]}" do - echo "creating ascension import config files" - cat > "/etc/ascension.d/bind-import-$ZONE.conf" << EOF + ZONE=$(echo "$ZONE" | tr -d '\n' | tr '.' '_') + echo "creating ascension import config files" + cat > "/etc/ascension.d/bind-import-$ZONE.conf" << EOF [ascension] ZONE = $ZONE TRANSFERNS = localhost PORT = 53 PUBLIC = $PUBLIC EOF - printf $ZONE - 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 "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 [Unit] Description=Ascension-bind for $ZONE After=gnunet-ascension.service @@ -80,21 +85,23 @@ ExecStart=/usr/bin/ascension $ZONE -n localhost [Install] WantedBy=multi-user.target EOF - ln -s "/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 deb-systemd-invoke reload bind9; then -# echo "reconfiguring failed, restoring original state" -# mv /etc/bind/named.conf.local.backup /etc/bind/named.conf.local -# exit 1 -#fi -# -#for ZONE in "${zones[@]}" -#do -# echo "starting and enabling ascension-bind-$ZONE" -# deb-systemd-invoke start "ascension-bind-$ZONE" -# deb-systemd-invoke enable "ascension-bind-$ZONE" -#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" + systemctl start "ascension-bind-$ZONE" + systemctl enable "ascension-bind-$ZONE" +done exit 0 diff --git a/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/control b/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/control @@ -2,7 +2,7 @@ Package: ascension-bind Version: 0.0.1-1 Architecture: amd64 Maintainer: rexxnor <rexxnor@brief.li> -Installed-Size: 15 +Installed-Size: 16 Depends: debconf (>= 0.5) | debconf-2.0 Section: net Priority: optional diff --git a/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/postrm b/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/postrm @@ -1,6 +1,6 @@ #!/bin/sh set -e -# 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