浏览代码

feat(hooks): get rid of post_update hook. pdns automatically increases serial if SOA-EDIT-API is set, rectifies upon outgoing AXFR, and notifies regularly

Peter Thomassen 8 年之前
父节点
当前提交
10f915452d

+ 3 - 8
desecapi/hooks/domain_post_create.sh

@@ -14,21 +14,16 @@ filename=/tmp/`date -Ins`_$ZONE.log
 touch $filename
 touch $filename
 chmod 640 $filename
 chmod 640 $filename
 
 
-echo "sign, post-update $ZONE"
-pdnsutil secure-zone $ZONE; pdnsutil set-nsec3 $ZONE "1 0 10 $SALT" && `dirname $0`/domain_post_update.sh $ZONE || exit 2
+echo "signing $ZONE and updating serial"
+pdnsutil secure-zone $ZONE && pdnsutil set-nsec3 $ZONE "1 0 10 $SALT" && pdnsutil increase-serial $ZONE || exit 2
 
 
-echo "getting DS records for $ZONE"
+echo "Setting DS records for $ZONE and put them in parent zone"
 DATA='{"rrsets": [ {"name": "'"$ZONE".'", "type": "DS", "ttl": 60, "changetype": "REPLACE", "records": '
 DATA='{"rrsets": [ {"name": "'"$ZONE".'", "type": "DS", "ttl": 60, "changetype": "REPLACE", "records": '
 DATA+=`curl -sS -X GET -H "X-API-Key: $APITOKEN" http://127.0.0.1:8081/api/v1/servers/localhost/zones/$ZONE/cryptokeys \
 DATA+=`curl -sS -X GET -H "X-API-Key: $APITOKEN" http://127.0.0.1:8081/api/v1/servers/localhost/zones/$ZONE/cryptokeys \
 	| jq -c '[.[] | select(.active == true) | {content: .ds[]?, disabled: false}]'`
 	| jq -c '[.[] | select(.active == true) | {content: .ds[]?, disabled: false}]'`
 DATA+=" } ] }"
 DATA+=" } ] }"
 echo $DATA >> $filename
 echo $DATA >> $filename
-
-echo "Setting DS records in parent zone $PARENT"
 curl -sSv -X PATCH --data "$DATA" -H "X-API-Key: $APITOKEN" http://127.0.0.1:8081/api/v1/servers/localhost/zones/$PARENT &>> $filename || exit 3
 curl -sSv -X PATCH --data "$DATA" -H "X-API-Key: $APITOKEN" http://127.0.0.1:8081/api/v1/servers/localhost/zones/$PARENT &>> $filename || exit 3
 
 
-echo "post-update $PARENT"
-`dirname $0`/domain_post_update.sh $PARENT || exit 4
-
 echo -n "This was $0: "
 echo -n "This was $0: "
 date
 date

+ 0 - 16
desecapi/hooks/domain_post_update.sh

@@ -1,16 +0,0 @@
-#!/bin/bash
-echo -n "This is $0: "
-date
-
-if [ -z "$1" ]; then
-        exit 1
-fi
-
-set -ex
-
-ZONE=$1
-
-pdnsutil rectify-zone $ZONE
-
-echo -n "This was $0: "
-date

+ 0 - 6
desecapi/hooks/mock/domain_post_update.sh

@@ -1,6 +0,0 @@
-#!/bin/bash
-echo Mockup hook for: $0 "$@"
-
-# Send 1M zero bytes to stdout
-# (large output of this script caused problems earlier)
-dd if=/dev/zero bs=1M count=1 2>/dev/null

+ 0 - 5
desecapi/models.py

@@ -176,8 +176,6 @@ class Domain(models.Model):
         if r.status_code < 200 or r.status_code >= 300:
         if r.status_code < 200 or r.status_code >= 300:
             raise Exception(r)
             raise Exception(r)
 
 
-        self.postUpdateHook()
-
     def hook(self, cmd):
     def hook(self, cmd):
         if not self.name:
         if not self.name:
             raise Exception
             raise Exception
@@ -201,9 +199,6 @@ class Domain(models.Model):
     def postCreateHook(self):
     def postCreateHook(self):
         self.hook(cmd='domain_post_create.sh')
         self.hook(cmd='domain_post_create.sh')
 
 
-    def postUpdateHook(self):
-        self.hook(cmd='domain_post_update.sh')
-
     class Meta:
     class Meta:
         ordering = ('created',)
         ordering = ('created',)