aboutsummaryrefslogtreecommitdiff
path: root/src/data/proto-test
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/proto-test')
-rwxr-xr-xsrc/data/proto-test/txtrec-enc.sh19
-rwxr-xr-xsrc/data/proto-test/txtrec-set.sh61
2 files changed, 80 insertions, 0 deletions
diff --git a/src/data/proto-test/txtrec-enc.sh b/src/data/proto-test/txtrec-enc.sh
new file mode 100755
index 0000000..0836f0f
--- /dev/null
+++ b/src/data/proto-test/txtrec-enc.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 <prefix>" >&2
+ exit 2
+fi
+
+set -e
+cnt=0
+while true; do
+ rec="$(dd bs=189 count=1 status=none | base64 -w0)"
+ if [ -z "$rec" ]; then
+ break
+ fi
+
+ printf "%08X%s %s\n" $cnt "$1" "$rec"
+ let "cnt += 1"
+done
+
+printf "\n%08x%s\n" $cnt "$1"
diff --git a/src/data/proto-test/txtrec-set.sh b/src/data/proto-test/txtrec-set.sh
new file mode 100755
index 0000000..50bb07d
--- /dev/null
+++ b/src/data/proto-test/txtrec-set.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+set -e
+
+ARR_HOOKS="
+ aws
+"
+
+if [ $# -lt 2 ]; then
+ echo "Usage: $0 <head rec> <hook> <zone id> [TTL]
+Hooks:" >&2
+ for h in $ARR_HOOKS; do
+ echo -e "\t$h"
+ done
+
+ exit 2
+fi
+
+HEAD_REC="$1"
+HOOK="$2"
+ZONE_ID="$3"
+if [ -z "$4" ]; then
+ TTL=3600
+else
+ TTL="$4"
+fi
+
+aws_param () {
+ cat << EOF
+{
+ "Changes": [
+ {
+ "Action": "UPSERT",
+ "ResourceRecordSet": {
+ "Name": "$1",
+ "Type": "TXT",
+ "TTL": $TTL,
+ "ResourceRecords": [
+ { "Value": "\"$2\"" }
+ ]
+ }
+ }
+ ]
+}
+EOF
+}
+
+hook_aws () {
+ aws route53 change-resource-record-sets\
+ --hosted-zone-id "$ZONE_ID"\
+ --change-batch "$(aws_param "$1" "$2")"
+}
+
+while read line; do
+ if [ -z "$line" ]; then
+ break;
+ fi
+ "hook_$HOOK" $line
+done
+
+read line
+"hook_$HOOK" "$HEAD_REC" "$line"