Added update failure notification
This commit is contained in:
parent
532f2abd1e
commit
37d51c50e7
18
cfddns.sh
18
cfddns.sh
@ -90,6 +90,12 @@ function quit {
|
|||||||
# exit with error code but don't display it
|
# exit with error code but don't display it
|
||||||
exit "$2"
|
exit "$2"
|
||||||
fi
|
fi
|
||||||
|
elif [ "$1" = "199" ]; then
|
||||||
|
# list DNS entries that were not updated
|
||||||
|
for failedName in "${failedDNS[@]}"; do
|
||||||
|
echo -e "\e[1;31m-- [ERROR] $failedName was NOT updated --\e[0m"
|
||||||
|
done
|
||||||
|
exit "$1"
|
||||||
else
|
else
|
||||||
# notify use that error has occurred and provide exit code
|
# notify use that error has occurred and provide exit code
|
||||||
echo -e "\e[1;31m-- [ERROR] Script exited with code $1 --"
|
echo -e "\e[1;31m-- [ERROR] Script exited with code $1 --"
|
||||||
@ -111,6 +117,7 @@ cfDetails=()
|
|||||||
cfRecords=()
|
cfRecords=()
|
||||||
currentIP=()
|
currentIP=()
|
||||||
recordID=()
|
recordID=()
|
||||||
|
failedDNS=()
|
||||||
ip4=1
|
ip4=1
|
||||||
ip6=0
|
ip6=0
|
||||||
|
|
||||||
@ -271,6 +278,7 @@ for recordIdx in "${!currentIP[@]}"; do
|
|||||||
echo -e "\e[1;32m${dnsRecords[recordIdx]} updated.\e[0m]"
|
echo -e "\e[1;32m${dnsRecords[recordIdx]} updated.\e[0m]"
|
||||||
else
|
else
|
||||||
echo -e "\e[1;31m${dnsRecords[recordIdx]} update failed\e[0m"
|
echo -e "\e[1;31m${dnsRecords[recordIdx]} update failed\e[0m"
|
||||||
|
failedDNS+=("${dnsRecords[recordIdx]}")
|
||||||
fi
|
fi
|
||||||
elif [ $ip6 -eq 1 ]; then
|
elif [ $ip6 -eq 1 ]; then
|
||||||
# update record at CloudFlare with new IP
|
# update record at CloudFlare with new IP
|
||||||
@ -280,14 +288,18 @@ for recordIdx in "${!currentIP[@]}"; do
|
|||||||
echo -e "\e[1;32m${dnsRecords[recordIdx]} updated.\e[0m"
|
echo -e "\e[1;32m${dnsRecords[recordIdx]} updated.\e[0m"
|
||||||
else
|
else
|
||||||
echo -e "\e[1;31m${dnsRecords[recordIdx]} update failed\e[0m"
|
echo -e "\e[1;31m${dnsRecords[recordIdx]} update failed\e[0m"
|
||||||
|
failedDNS+=("${dnsRecords[recordIdx]}")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Check if failedDNS array contains entries and exit with error, else exit 0
|
||||||
|
if [ -z "${failedDNS}" ]; then
|
||||||
quit
|
quit
|
||||||
|
else
|
||||||
|
quit 199
|
||||||
|
fi
|
||||||
|
|
||||||
# this code should never be executed
|
# this code should never be executed
|
||||||
exit 99
|
exit 99
|
||||||
|
Loading…
Reference in New Issue
Block a user