Add README.md and some scripts to get DHCPD hosts into unbound for DNS
This commit is contained in:
parent
68a324be03
commit
c3d133a75e
4 changed files with 141 additions and 0 deletions
28
cron/unbound-dhcpd-updater
Executable file
28
cron/unbound-dhcpd-updater
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
readonly DHCPD_CONF_FILE='/etc/dhcpd.conf'
|
||||
readonly DHCPD_LEASES_FILE='/var/db/dhcpd.leases'
|
||||
readonly UNBOUND_LOCAL_DATA_FILE='/var/unbound/etc/local-data-dhcpd.conf'
|
||||
UNBOUND_LOCAL_DATA_FILE_TMP="$(mktemp)"
|
||||
readonly UNBOUND_LOCAL_DATA_FILE_TMP
|
||||
|
||||
get_file_modify_time() {
|
||||
stat -f %m "$1"
|
||||
}
|
||||
|
||||
if [ -e "$UNBOUND_LOCAL_DATA_FILE" ]; then
|
||||
UNBOUND_LOCAL_DATA_FILE_MODIFY_TIME="$(get_file_modify_time "$UNBOUND_LOCAL_DATA_FILE")"
|
||||
|
||||
if [ "$UNBOUND_LOCAL_DATA_FILE_MODIFY_TIME" -gt "$(get_file_modify_time "$DHCPD_CONF_FILE")" ]; then
|
||||
if [ "$UNBOUND_LOCAL_DATA_FILE_MODIFY_TIME" -gt "$(get_file_modify_time "$DHCPD_LEASES_FILE")" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
../dhcpd/list_active_assignments | ../unbound/local-data-file-generator > "$UNBOUND_LOCAL_DATA_FILE_TMP"
|
||||
|
||||
mv "$UNBOUND_LOCAL_DATA_FILE_TMP" "$UNBOUND_LOCAL_DATA_FILE"
|
||||
|
||||
rcctl reload unbound
|
Loading…
Add table
Add a link
Reference in a new issue