From ed6f3fdaa421475daad179cac74ac122f421e55a Mon Sep 17 00:00:00 2001 From: Florian Pfitzer Date: Fri, 11 Jun 2021 09:43:38 +0200 Subject: [PATCH 1/4] Create dns_burp.sh --- dnsapi/dns_burp.sh | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 dnsapi/dns_burp.sh diff --git a/dnsapi/dns_burp.sh b/dnsapi/dns_burp.sh new file mode 100644 index 00000000..c8685039 --- /dev/null +++ b/dnsapi/dns_burp.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env sh + +#Author: Florian Pfitzer +#Report Bugs here: https://github.com/acmesh-official/acme.sh +#export BURP_COLLABORATOR_CONFIG=/etc/burp/collaborator.json +#export BURP_COLLABORATOR_RESTART='/usr/bin/systemctl restart burp-collaborator' +# +######## Public functions ##################### + +dns_burp_add() { + fulldomain=$1 + txtvalue=$2 + _info "Using burp" + BURP_COLLABORATOR_CONFIG="${BURP_COLLABORATOR_CONFIG:-$(_readaccountconf_mutable BURP_COLLABORATOR_CONFIG)}" + BURP_COLLABORATOR_RESTART="${BURP_COLLABORATOR_RESTART:-$(_readaccountconf_mutable BURP_COLLABORATOR_RESTART)}" + if [ -z "$BURP_COLLABORATOR_CONFIG" ] || [ -z "$BURP_COLLABORATOR_RESTART" ]; then + BURP_COLLABORATOR_CONFIG="" + BURP_COLLABORATOR_RESTART="" + _err "You did not specify BURP_COLLABORATOR_CONFIG and BURP_COLLABORATOR_RESTART" + return 1 + fi + _saveaccountconf_mutable BURP_COLLABORATOR_CONFIG "$BURP_COLLABORATOR_CONFIG" + _saveaccountconf_mutable BURP_COLLABORATOR_RESTART "$BURP_COLLABORATOR_RESTART" + + json=$(cat $BURP_COLLABORATOR_CONFIG) + json=$(echo $json|jq ".customDnsRecords += [{\"label\": \"_acme-challenge\", \"record\": \"$txtvalue\", \"type\": \"TXT\", \"ttl\": 60}]") + + echo "$json" > $BURP_COLLABORATOR_CONFIG + + eval $BURP_COLLABORATOR_RESTART + + return 0 +} + +#Usage: fulldomain txtvalue +#Remove the txt record after validation. +dns_burp_rm() { + fulldomain=$1 + txtvalue=$2 + _info "Using burp" + + json=$(cat $BURP_COLLABORATOR_CONFIG) + json=$(echo $json|jq "del(.customDnsRecords[] | select(.label == \"_acme-challenge\"))") + + echo "$json" > $BURP_COLLABORATOR_CONFIG + + eval $BURP_COLLABORATOR_RESTART +} + +#################### Private functions below ################################## + From bb7cdb318567817fe5df60c12cfcec673b368f37 Mon Sep 17 00:00:00 2001 From: Florian Pfitzer Date: Mon, 14 Jun 2021 10:15:01 +0200 Subject: [PATCH 2/4] fix ci error --- dnsapi/dns_burp.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dnsapi/dns_burp.sh b/dnsapi/dns_burp.sh index c8685039..62815062 100644 --- a/dnsapi/dns_burp.sh +++ b/dnsapi/dns_burp.sh @@ -23,9 +23,9 @@ dns_burp_add() { _saveaccountconf_mutable BURP_COLLABORATOR_RESTART "$BURP_COLLABORATOR_RESTART" json=$(cat $BURP_COLLABORATOR_CONFIG) - json=$(echo $json|jq ".customDnsRecords += [{\"label\": \"_acme-challenge\", \"record\": \"$txtvalue\", \"type\": \"TXT\", \"ttl\": 60}]") + json=$(echo "$json" | jq ".customDnsRecords += [{\"label\": \"_acme-challenge\", \"record\": \"$txtvalue\", \"type\": \"TXT\", \"ttl\": 60}]") - echo "$json" > $BURP_COLLABORATOR_CONFIG + echo "$json" >$BURP_COLLABORATOR_CONFIG eval $BURP_COLLABORATOR_RESTART @@ -35,14 +35,13 @@ dns_burp_add() { #Usage: fulldomain txtvalue #Remove the txt record after validation. dns_burp_rm() { - fulldomain=$1 txtvalue=$2 _info "Using burp" json=$(cat $BURP_COLLABORATOR_CONFIG) - json=$(echo $json|jq "del(.customDnsRecords[] | select(.label == \"_acme-challenge\"))") + json=$(echo "$json" | jq "del(.customDnsRecords[] | select(.label == \"_acme-challenge\"))") - echo "$json" > $BURP_COLLABORATOR_CONFIG + echo "$json" >$BURP_COLLABORATOR_CONFIG eval $BURP_COLLABORATOR_RESTART } From 1aac843382f7e82ba011bad8d3170b810959db64 Mon Sep 17 00:00:00 2001 From: Florian Pfitzer Date: Fri, 30 Jul 2021 07:52:47 +0200 Subject: [PATCH 3/4] fix ci error --- dnsapi/dns_burp.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/dnsapi/dns_burp.sh b/dnsapi/dns_burp.sh index 62815062..93169621 100644 --- a/dnsapi/dns_burp.sh +++ b/dnsapi/dns_burp.sh @@ -8,7 +8,6 @@ ######## Public functions ##################### dns_burp_add() { - fulldomain=$1 txtvalue=$2 _info "Using burp" BURP_COLLABORATOR_CONFIG="${BURP_COLLABORATOR_CONFIG:-$(_readaccountconf_mutable BURP_COLLABORATOR_CONFIG)}" From 6f2f5999fab59e0e80bf93d1bcaff1724bf223aa Mon Sep 17 00:00:00 2001 From: Florian Pfitzer Date: Fri, 30 Jul 2021 07:59:26 +0200 Subject: [PATCH 4/4] fix shellcheck and shfmt errors --- dnsapi/dns_burp.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/dnsapi/dns_burp.sh b/dnsapi/dns_burp.sh index 93169621..284d1312 100644 --- a/dnsapi/dns_burp.sh +++ b/dnsapi/dns_burp.sh @@ -21,12 +21,12 @@ dns_burp_add() { _saveaccountconf_mutable BURP_COLLABORATOR_CONFIG "$BURP_COLLABORATOR_CONFIG" _saveaccountconf_mutable BURP_COLLABORATOR_RESTART "$BURP_COLLABORATOR_RESTART" - json=$(cat $BURP_COLLABORATOR_CONFIG) + json=$(cat "$BURP_COLLABORATOR_CONFIG") json=$(echo "$json" | jq ".customDnsRecords += [{\"label\": \"_acme-challenge\", \"record\": \"$txtvalue\", \"type\": \"TXT\", \"ttl\": 60}]") - echo "$json" >$BURP_COLLABORATOR_CONFIG + echo "$json" >"$BURP_COLLABORATOR_CONFIG" - eval $BURP_COLLABORATOR_RESTART + eval "$BURP_COLLABORATOR_RESTART" return 0 } @@ -37,13 +37,12 @@ dns_burp_rm() { txtvalue=$2 _info "Using burp" - json=$(cat $BURP_COLLABORATOR_CONFIG) + json=$(cat "$BURP_COLLABORATOR_CONFIG") json=$(echo "$json" | jq "del(.customDnsRecords[] | select(.label == \"_acme-challenge\"))") - echo "$json" >$BURP_COLLABORATOR_CONFIG + echo "$json" >"$BURP_COLLABORATOR_CONFIG" - eval $BURP_COLLABORATOR_RESTART + eval "$BURP_COLLABORATOR_RESTART" } #################### Private functions below ################################## -