Replies: 5 comments
-
I have written similar code in nodejs but that code is a few years old and it a hassle to deploy so hoping I can use your nice compiled GO project instead. |
Beta Was this translation helpful? Give feedback.
-
now that I know that it will run as a one off I can build a bash script around it. Still it would be great to pass some executable and have it run it on change. |
Beta Was this translation helpful? Give feedback.
-
would be nice to have a usable return status. (failed, no change, change) Right now all I seem to be able to do is grep on "not changed" which is not robust if you change the wording of the log or if the program eventually supports a locale. |
Beta Was this translation helpful? Give feedback.
-
so rather than a cron job I can run a systemd timer which will allow a bash script that calls ddns-route53. |
Beta Was this translation helpful? Give feedback.
-
#!/bin/bash
sdir="$(dirname -- "$( readlink -f -- "$0"; )")"
[[ ! $1 ]] && echo config yaml file required && exit 1
conf=$1.yml
if [[ ! -f $conf ]]; then
conf=$sdir/$conf
[[ ! -f $conf ]] && echo unable to find configuration file $1 && exit 2
fi
cred=$1.env
if [[ ! -f $cred ]]; then
cred=$sdir/$cred
if [[ ! -f $cred ]]; then
cred=credentials.env
if [[ ! -f $cred ]]; then
cred=$sdir/$cred
[[ ! -f $cred ]] && echo unable to find a credentials file && exit 3
fi
fi
fi
echo running ddns-route53 using configuration file $conf and credentials file $cred
if result=$(source $cred; $sdir/ddns-route53 --config $conf); then
if [[ "$(echo $result | grep "set updated")" ]]; then
echo public ip changed. Do something.
else
echo public ip not changed. Nothing to do
fi
# echo $result
else
echo error trying to set ddns, $?
fi |
Beta Was this translation helpful? Give feedback.
-
I didn't see anything in the docs so I am asking.
My use case is that I run a site to site VPN tunnel and if the IP address of either end changes then the vpn must be restarted so that the a tunnel can be established to the new IP.
Beta Was this translation helpful? Give feedback.
All reactions