Browse Source

Shellcheck compliance and double bracket conditions

pull/838/head
Lukas Kaufmann 2 years ago
parent
commit
177df93001
2 changed files with 13 additions and 13 deletions
  1. +6
    -6
      dns_scripts/dns_add_hetzner
  2. +7
    -7
      dns_scripts/dns_del_hetzner

+ 6
- 6
dns_scripts/dns_add_hetzner View File

@ -20,15 +20,15 @@ if [[ -z "$HETZNER_KEY" ]]; then
echo "HETZNER_KEY variable not set"
exit 1
fi
if [ -z "$HETZNER_ZONE_ID" ] && [ -z "$HETZNER_ZONE_NAME" ] ; then
if [[ -z "$HETZNER_ZONE_ID" && -z "$HETZNER_ZONE_NAME" ]] ; then
echo "HETZNER_ZONE_ID and HETZNER_ZONE_NAME variables not set"
exit 1
fi
# Get Zone ID if not set
if [ -z "$HETZNER_ZONE_ID" ] ; then
zone_id=$(curl --silent -X GET "$api_url/zones?name=$HETZNER_ZONE_NAME" -H 'Auth-API-Token: '"$api_key"'' | jq -r '.zones[0].id')
if [ -z "$zone_id" == "null" ] ; then
if [[ -z "$HETZNER_ZONE_ID" ]] ; then
zone_id=$(curl --silent -X GET "$api_url/zones?name=$zone_name" -H 'Auth-API-Token: '"$api_key"'' | jq -r '.zones[0].id')
if [[ "$zone_id" == "null" ]] ; then
echo "Zone ID not found"
exit 1
fi
@ -40,10 +40,10 @@ txtname="_acme-challenge.$fulldomain."
response=$(curl --silent -X POST "$api_url/records" \
-H 'Content-Type: application/json' \
-H "Auth-API-Token: $api_key" \
-d '{"value": "'$token'","ttl": 60,"type": "TXT","name": "_acme-challenge.'$fulldomain'.","zone_id": "'$zone_id'"}' \
-d '{"value": "'"$token"'","ttl": 60,"type": "TXT","name": "'"$txtname"'","zone_id": "'"$zone_id"'"}' \
-o /dev/null -w '%{http_code}')
if [ "$response" != "200" ] ; then
if [[ "$response" != "200" ]] ; then
echo "Record not created"
echo "Response code: $response"
exit 1


+ 7
- 7
dns_scripts/dns_del_hetzner View File

@ -20,15 +20,15 @@ if [[ -z "$HETZNER_KEY" ]]; then
echo "HETZNER_KEY variable not set"
exit 1
fi
if [ -z "$HETZNER_ZONE_ID" ] && [ -z "$HETZNER_ZONE_NAME" ] ; then
if [[ -z "$HETZNER_ZONE_ID" && -z "$HETZNER_ZONE_NAME" ]] ; then
echo "HETZNER_ZONE_ID and HETZNER_ZONE_NAME variables not set"
exit 1
fi
# Get Zone ID if not set
if [ -z "$HETZNER_ZONE_ID" ] ; then
zone_id=$(curl --silent -X GET "$api_url/zones?name=$HETZNER_ZONE_NAME" -H 'Auth-API-Token: '"$api_key"'' | jq -r '.zones[0].id')
if [ "$zone_id" == "null" ] ; then
if [[ -z "$HETZNER_ZONE_ID" ]] ; then
zone_id=$(curl --silent -X GET "$api_url/zones?name=$zone_name" -H 'Auth-API-Token: '"$api_key"'' | jq -r '.zones[0].id')
if [[ "$zone_id" == "null" ]] ; then
echo "Zone by name not found"
exit 1
fi
@ -39,9 +39,9 @@ fi
txtname="_acme-challenge.$fulldomain."
record_id=$(curl --silent -X GET "$api_url/records?zone_id=$zone_id" -H "Auth-API-Token: $api_key" | jq -r '.records[] | select(.name=="'$txtname'") | .id')
record_id=$(curl --silent -X GET "$api_url/records?zone_id=$zone_id" -H "Auth-API-Token: $api_key" | jq -r '.records[] | select(.name=="'"$txtname"'") | .id')
if [ "$record_id" == "null" ] ; then
if [[ "$record_id" == "null" ]] ; then
echo "Record not found"
exit 1
fi
@ -49,7 +49,7 @@ fi
# Create TXT record
response=$(curl --silent -X DELETE "$api_url/records/$record_id" -H "Auth-API-Token: $api_key" -o /dev/null -w '%{http_code}')
if [ "$response" != "200" ] ; then
if [[ "$response" != "200" ]] ; then
echo "Record not deleted"
echo "Response code: $response"
exit 1


Loading…
Cancel
Save