diff options
author | Erich Eckner <git@eckner.net> | 2019-04-01 09:07:02 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-04-01 09:07:02 +0200 |
commit | ed9464dae9a1cab898a2555c752442e2cfcdb47c (patch) | |
tree | 58c010e8a4be425d572381689b9db0378209772f | |
parent | 7f0ec510c84f13b05cf887a2dcf9f141a3d4631b (diff) | |
download | update-ddns-ed9464dae9a1cab898a2555c752442e2cfcdb47c.tar.xz |
update-ddns.in: style update
-rw-r--r-- | update-ddns.in | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/update-ddns.in b/update-ddns.in index ce65561..72e89a7 100644 --- a/update-ddns.in +++ b/update-ddns.in @@ -5,12 +5,9 @@ stty &> /dev/null || \ sleep $[$RANDOM%60] -if ! ipCmd="$(which ip 2> /dev/null)" -then - for p1 in / /usr/ - do - for p2 in bin/ sbin/ - do +if ! ipCmd=$(which ip 2> /dev/null); then + for p1 in / /usr/; do + for p2 in bin/ sbin/; do ipCmd="${p1}${p2}ip" [ -x "${ipCmd}" ] && break done @@ -22,38 +19,31 @@ unset ignoreIps i=0 -while read -r ipVer updateUrl dnsName -do +while read -r ipVer updateUrl dnsName; do - if [[ "${ipVer}" = '#'* ]] || [ -z "${ipVer}" ] - then + if [[ "${ipVer}" = '#'* ]] || [ -z "${ipVer}" ]; then continue fi - if [[ "${ipVer}" == 'ignore' ]] - then + if [[ "${ipVer}" == 'ignore' ]]; then ignoreIps="${ignoreIps} ${updateUrl} ${dnsName}" continue fi - if [[ "${ipVer}" == *"?" ]] - then + if [[ "${ipVer}" == *"?" ]]; then ipVer="${ipVer%?}" [ -z "$(${ipCmd} -o -${ipVer} addr show scope global)" ] && continue fi - if [ "${ipVer}" == '4' ] - then + if [ "${ipVer}" == '4' ]; then dnsVers[${i}]='A' inetVers[${i}]='inet' ipCmdVers[${i}]='-4' - elif [ "${ipVer}" == '6' ] - then + elif [ "${ipVer}" == '6' ]; then dnsVers[${i}]='AAAA' inetVers[${i}]='inet6' ipCmdVers[${i}]='-6' - elif [ "${ipVer}" == '46' ] || [ "${ipVer}" == '64' ] - then + elif [ "${ipVer}" == '46' ] || [ "${ipVer}" == '64' ]; then dnsVers[${i}]='A' inetVers[${i}]='inet' ipCmdVers[${i}]='-4' @@ -97,28 +87,24 @@ for dnsName in $( \ echo "${dnsNamen[@]}" | \ tr ' ' '\n' | \ sort -u -) -do +); do unset updateIps unset updateUrl unset curlForceIpVer needsUpdate=false - for ((j=0; j<${i}; j++)) - do + for ((j=0; j<${i}; j++)); do [ "${dnsName}" != "${dnsNamen[${j}]}" ] && continue updateUrl="${updateUrls[${j}]}" - if [[ "${dnsName}" == *'/'* ]] - then + if [[ "${dnsName}" == *'/'* ]]; then dnsIps="$( curl ${ipCmdVers[${j}]} "${dnsName}" 2> /dev/null )" ips='1' updateIps="${updateIps}"',auto' - if [ -n "${curlForceIpVer}" ] && [ "${curlForceIpVer}" != "${ipCmdVers[${j}]}" ] - then + if [ -n "${curlForceIpVer}" ] && [ "${curlForceIpVer}" != "${ipCmdVers[${j}]}" ]; then >&2 echo 'Error: I cannot determine two different ip versions automatically (because Erich didn'"'"'t need it).' exit 1 fi @@ -141,8 +127,7 @@ do sort -u )" - if [ $(echo "${ips}" | grep -c '.') -eq 0 ] - then + if [ $(echo "${ips}" | grep -c '.') -eq 0 ]; then updateIps="${updateIps}"',auto' if [ -n "${curlForceIpVer}" ] && [ "${curlForceIpVer}" != "${ipCmdVers[${j}]}" ] then @@ -155,16 +140,13 @@ do fi fi - if [ "${dnsIps}" != "${ips}" ] - then + if [ "${dnsIps}" != "${ips}" ]; then needsUpdate=true fi done - if ${needsUpdate} - then - if [[ "${updateUrl}" = *'?'* ]] - then + if ${needsUpdate}; then + if [[ "${updateUrl}" = *'?'* ]]; then updateIps='&address='"${updateIps#,}" else updateIps='?address='"${updateIps#,}" |