diff options
author | David Timber <mieabby@gmail.com> | 2020-11-01 16:42:59 +1030 |
---|---|---|
committer | David Timber <mieabby@gmail.com> | 2020-11-01 16:42:59 +1030 |
commit | 60308ca4d9a5976a06aa8fe78a7b21951f9f206d (patch) | |
tree | fe0e95f49e58f991c5e3c6e973e5fafacf24fc7f | |
parent | 3fb3d74e7113e514819670ee42e7f5703f13ceec (diff) |
Add txtrec-del.sh, rename proto-test -> proto
-rw-r--r-- | src/data/proto/hostinfo_req (renamed from src/data/proto-test/hostinfo_req) | 0 | ||||
-rw-r--r-- | src/data/proto/hostinfo_rsp (renamed from src/data/proto-test/hostinfo_rsp) | 0 | ||||
-rw-r--r-- | src/data/proto/hover (renamed from src/data/proto-test/hover) | 0 | ||||
-rw-r--r-- | src/data/proto/nybin_head (renamed from src/data/proto-test/nybin_head) | 0 | ||||
-rwxr-xr-x | src/data/proto/print-raw.sh (renamed from src/data/proto-test/print-raw.sh) | 0 | ||||
-rw-r--r-- | src/data/proto/runbin (renamed from src/data/proto-test/runbin) | 0 | ||||
-rw-r--r-- | src/data/proto/runcmd_demux (renamed from src/data/proto-test/runcmd_demux) | 0 | ||||
-rw-r--r-- | src/data/proto/runcmd_detached (renamed from src/data/proto-test/runcmd_detached) | 0 | ||||
-rw-r--r-- | src/data/proto/runcmd_empty-out_ab (renamed from src/data/proto-test/runcmd_empty-out_ab) | 0 | ||||
-rw-r--r-- | src/data/proto/runcmd_outonly (renamed from src/data/proto-test/runcmd_outonly) | 0 | ||||
-rwxr-xr-x | src/data/proto/txtrec-del.sh | 64 | ||||
-rwxr-xr-x | src/data/proto/txtrec-enc.sh (renamed from src/data/proto-test/txtrec-enc.sh) | 0 | ||||
-rwxr-xr-x | src/data/proto/txtrec-set.sh (renamed from src/data/proto-test/txtrec-set.sh) | 0 |
13 files changed, 64 insertions, 0 deletions
diff --git a/src/data/proto-test/hostinfo_req b/src/data/proto/hostinfo_req index abeee61..abeee61 100644 --- a/src/data/proto-test/hostinfo_req +++ b/src/data/proto/hostinfo_req diff --git a/src/data/proto-test/hostinfo_rsp b/src/data/proto/hostinfo_rsp index 659a146..659a146 100644 --- a/src/data/proto-test/hostinfo_rsp +++ b/src/data/proto/hostinfo_rsp diff --git a/src/data/proto-test/hover b/src/data/proto/hover index 52d52e2..52d52e2 100644 --- a/src/data/proto-test/hover +++ b/src/data/proto/hover diff --git a/src/data/proto-test/nybin_head b/src/data/proto/nybin_head index 79cd1b7..79cd1b7 100644 --- a/src/data/proto-test/nybin_head +++ b/src/data/proto/nybin_head diff --git a/src/data/proto-test/print-raw.sh b/src/data/proto/print-raw.sh index a824fe1..a824fe1 100755 --- a/src/data/proto-test/print-raw.sh +++ b/src/data/proto/print-raw.sh diff --git a/src/data/proto-test/runbin b/src/data/proto/runbin index 099a1a6..099a1a6 100644 --- a/src/data/proto-test/runbin +++ b/src/data/proto/runbin diff --git a/src/data/proto-test/runcmd_demux b/src/data/proto/runcmd_demux index c0a630e..c0a630e 100644 --- a/src/data/proto-test/runcmd_demux +++ b/src/data/proto/runcmd_demux diff --git a/src/data/proto-test/runcmd_detached b/src/data/proto/runcmd_detached index be4741d..be4741d 100644 --- a/src/data/proto-test/runcmd_detached +++ b/src/data/proto/runcmd_detached diff --git a/src/data/proto-test/runcmd_empty-out_ab b/src/data/proto/runcmd_empty-out_ab index f85b789..f85b789 100644 --- a/src/data/proto-test/runcmd_empty-out_ab +++ b/src/data/proto/runcmd_empty-out_ab diff --git a/src/data/proto-test/runcmd_outonly b/src/data/proto/runcmd_outonly index 56e25c2..56e25c2 100644 --- a/src/data/proto-test/runcmd_outonly +++ b/src/data/proto/runcmd_outonly diff --git a/src/data/proto/txtrec-del.sh b/src/data/proto/txtrec-del.sh new file mode 100755 index 0000000..7ecf253 --- /dev/null +++ b/src/data/proto/txtrec-del.sh @@ -0,0 +1,64 @@ +#!/bin/bash +ARR_HOOKS=" + aws +" + +if [ $# -lt 2 ]; then + echo "Usage: $0 <head rec> <hook> <zone id> +Hooks:" >&2 + for h in $ARR_HOOKS; do + echo -e "\t$h" + done + + exit 2 +fi + +HEAD_REC="$1" +HOOK="$2" +ZONE_ID="$3" + +aws_param () { + cat << EOF +{ + "Changes": [ + { + "Action": "DELETE", + "ResourceRecordSet": $1 + } + ] +} +EOF +} + +hook_aws () { + local tmpfile=`mktemp --tmpdir txtrec-del.XXXXXXXXXX` + + aws route53 list-resource-record-sets\ + --hosted-zone-id "$ZONE_ID" > "$tmpfile" + local nb_rec=`jq ".ResourceRecordSets | length" "$tmpfile"` + local escaped_name=$(echo "$HEAD_REC" | sed -e s/\\./\\\\./g) + + for (( i = 0; i < nb_rec; i += 1 )); do + local rec=$(jq ".ResourceRecordSets[$i]" "$tmpfile") + jq ".ResourceRecordSets[$i].Name" "$tmpfile" | + egrep -i "\"([0-9a-f]+\.)?$escaped_name\.?\"" + if [ $? -eq 0 ]; then + aws route53 change-resource-record-sets\ + --hosted-zone-id "$ZONE_ID"\ + --change-batch "$(aws_param "$rec")" + fi + done + + rm -f "$tmpfile" +} + +"hook_$HOOK" "$HEAD_REC" + +i=0 +while true; do + "hook_$HOOK" $i."$HEAD_REC" + if [ $? -ne 0 ]; then + break + fi + let i=i+1 +done diff --git a/src/data/proto-test/txtrec-enc.sh b/src/data/proto/txtrec-enc.sh index 0836f0f..0836f0f 100755 --- a/src/data/proto-test/txtrec-enc.sh +++ b/src/data/proto/txtrec-enc.sh diff --git a/src/data/proto-test/txtrec-set.sh b/src/data/proto/txtrec-set.sh index 50bb07d..50bb07d 100755 --- a/src/data/proto-test/txtrec-set.sh +++ b/src/data/proto/txtrec-set.sh |