From 839cace80067942977dcb8ecccb3d4655eb4c781 Mon Sep 17 00:00:00 2001 From: Steph Enders Date: Thu, 28 Dec 2023 07:30:38 -0500 Subject: 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 --- update.sh | 19 +++++++++++++------ 1 file 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 -- cgit v1.2.3-54-g00ecf