Do not remove manually added DNS-Records #2
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the ability to keep manually added Records intact.
It does so by adding a ";dynamic" comment at the end of the line in the zonefile.
The DSM UI ignores this comment completly and won't remove it from the lines until the line is manually edited (for example the IP was changed) which will correctly mark it as a static DNS entry.
On next run the script will read every line except for the ones that include the ";dynamic" comment to create a new zonefile and rebuild the dynamic lines based on the DHCP lease files. It also makes sure that no static/manual DNS-Record entry will be overwritten nor can a DHCP Client add itself to a static/manual added Record by specifying the same DNS name in the DHCP Request.
For the above example if there is a new DHCP client with the name "static" it will not be added to the DNS as the static.home.lan A-Record already exists.
The handling of static IP-Adresses as it was currently implemented has been removed as I don't feel it's needed anymore.
I also made the zonefiles more editor and parser friendly by implementing tabs instead of spaces as the DSM UI does.
As I was working on the awk script I cleaned up a few unused variables, too.
Might need some testing before finally pulling.