Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dns/bind/src/etc/rc.syshook.d/early/99-named
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

#
# It's OK to delete these files on bootup because we clean them out
# during a clean shutdown. Therefore if these files still exist on
# bootup, it means that the system wasn't shut down cleanly and as
# a result these files are suspect and likely broken, so they need
# to be removed to avoid any BIND9 bootup issues.
#
echo "Clearing out vestigial BIND9 journal files ..."
find /usr/local/etc/namedb/primary -type f -name '*.jnl' -delete -print
31 changes: 31 additions & 0 deletions dns/bind/src/etc/rc.syshook.d/stop/99-named
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

BINDHOME="/usr/local/etc/namedb"

log()
{
[ ${#} -gt 0 ] || return 0
logger -is -t "bind-cleanup" "${@}"
}

#
# First, do things the easy way (only possible if BIND9 is running!)
#
if service named status 1>/dev/null 2>&1 ; then
log "Clearing out pending BIND9 journal files..."
OUT="$(rndc sync -clean 2>&1)" || log "RNDC SYNC failed (rc=${?}): ${OUT}"

log "Stopping BIND ..."
OUT="$(service named stop 2>&1)" || log "Could not stop BIND (rc=${?}): ${OUT}"
fi

#
# If the easy way didn't work, we do things the hard way because these
# journal files can cause a LOT of issues when BIND9 next tries to start
#
if OUT="$(cd "${BINDHOME}/primary" && find * -type f -name '*.jnl' | fgrep '.jnl')" ; then
log "WARNING: BIND9 journal files still exist - [${OUT}]"
find "${BINDHOME}/primary" -type f -name '*.jnl' -delete -print
fi

exit 0
10 changes: 10 additions & 0 deletions dns/bind/src/opnsense/scripts/OPNsense/Bind/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,13 @@ for DIR in /var/run/named /var/dump /var/stats /var/log/named /usr/local/etc/nam
chown -R bind:bind ${DIR}
chmod 755 ${DIR}
done

# This should help clean out orphaned journal files
if ! rndc sync -clean ; then
# If the RNDC command didn't work, we should probably clean
# the files out manually because on a clean shutdown they
# would be cleared out by "service named stop" ... so if
# they're still around it means something went down HARD and
# thus the files are suspect and could derail BIND9 startup
find /usr/local/etc/namedb/primary -type f -name '*.jnl' -print -delete
fi