diff --git a/main.sh b/main.sh index a8b9ac7..11c3663 100755 --- a/main.sh +++ b/main.sh @@ -17,6 +17,12 @@ if [[ ! "$MYIP" =~ ^([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([1-9]?[0-9]|1[ fi # fetch current record with dig, and choose what to do +# TODO we should probably improve this choice: current implementation prevents hosts that do not have a record yet to register themselves; We'd need to differentiate cases: +# * correct ip, not the same -> OK, need to update +# * correct ip, the same -> OK, nothing to do +# * no result, name server was reachable -> OK, need to register +# * no result, name server was not reachable -> NOK, abort +# * result which is not a correct ip -> NOK, abort current_ip_record=$(dig $FQDN +short) if [[ "$current_ip_record" =~ ^([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$ ]]; then if [[ ! "$MYIP" = "$current_ip_record" ]]; then