diff options
| author | Dave Compton <davecompton7@gmail.com> | 2024-08-08 17:12:48 -0700 |
|---|---|---|
| committer | Dave Compton <davecompton7@gmail.com> | 2024-08-08 17:12:48 -0700 |
| commit | f65df2752535a26b6b99afabca3b77aef6659c4a (patch) | |
| tree | 6d0f2280ebccf2af9487dc60766fe2907201aa30 /update_digitalocean_dns_a_record.bash | |
added working version of scripts
Diffstat (limited to 'update_digitalocean_dns_a_record.bash')
| -rwxr-xr-x | update_digitalocean_dns_a_record.bash | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/update_digitalocean_dns_a_record.bash b/update_digitalocean_dns_a_record.bash new file mode 100755 index 0000000..3dc3edf --- /dev/null +++ b/update_digitalocean_dns_a_record.bash @@ -0,0 +1,30 @@ +#! /bin/bash + +# set an A record but first check to make sure we didn't just do this. + +DIGITALOCEAN_DOMAIN=$1 +IP=$2 + +SCRIPT="${BASH_SOURCE[0]}" +SCRIPT_DIR=${SCRIPT%/*} +SCRIPT_NAME=${SCRIPT##*/} + +REPEAT_CHECK_DIR=$HOME/repeat_check +REPEAT_CHECK=$REPEAT_CHECK_DIR/$SCRIPT_NAME # file to save argument in if successful + +# exit if previous successful call was with same argument +if [[ -e $REPEAT_CHECK ]]; then + PREVIOUS_ARGUMENTS=`cat $REPEAT_CHECK` + if [[ "$*" == "$PREVIOUS_ARGUMENTS" ]]; then + echo previous call to $SCRIPT was also with arguments: \"$*\" so exiting now to avoid duplicate work. + exit + fi +fi + +if $SCRIPT_DIR/set_digitalocean_dns_a_record.bash $@; then + # if successful then save arguments. + echo call to $SCRIPT worked so saving arguments \"$*\" in $REPEAT_CHECK + mkdir -p $REPEAT_CHECK_DIR + echo "$*" > $REPEAT_CHECK +fi + |
