summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteph Enders <steph@senders.io>2023-12-28 07:30:38 -0500
committerSteph Enders <steph@senders.io>2023-12-28 07:30:38 -0500
commit839cace80067942977dcb8ecccb3d4655eb4c781 (patch)
treec16d89f40299046e7b6f6a3f560ebc96a7014f21
parente5d5d0c62195b5995c0f723bce34b5ea62279313 (diff)
Properly handle configuration passing
I had misread my own code from the porkbun-ip-update script! Updated script to take either "config" or "hosted_zone + domain" args. If you're using the domain + hz you'll need to ensure AWS CLI is configured
-rwxr-xr-xupdate.sh19
1 files changed, 13 insertions, 6 deletions
diff --git a/update.sh b/update.sh
index ab023a7..d67006d 100755
--- a/update.sh
+++ b/update.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env sh
+#!/usr/bin/env bash
set -e
# Not needed but useful to know
@@ -8,12 +8,19 @@ function aws_ip_check {
--query "ResourceRecordSets[?(Name == 'senders.io.' && Type == 'A')].ResourceRecords[0].Value | [0]" --output text
}
-if [ $# -ne 2 ]; then
- echo "Usage: ./update.sh HOSTED_ZONE_ID DOMAIN"
+if [ $# -lt 1 ]; then
+ echo "Usage: ./update.sh HOSTED_ZONE_ID DOMAIN
+ ./update.sh CONFIG_FILE
+"
+ exit 1
+fi
+if [ $# -eq 1 ]; then
+ source $1
+fi
+if [ $# -eq 2 ]; then
+ HOSTED_ZONE_ID=$1
+ DOMAIN=$2
fi
-HOSTED_ZONE_ID=$1
-DOMAIN=$2
-source API_CONFIG
RECORD_CHANGE_JSON=/tmp/aws-ip-update.json
# Fetch IPs