#!/bin/bash
#
# Univention Bind
#
# SPDX-FileCopyrightText: 2011-2026 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only

. /usr/lib/univention-server/lib/server_password_change/debug.sh

PAUSE_DEBUG
eval "$(univention-config-registry shell)"
RESUME_DEBUG

. /usr/share/univention-lib/base.sh

if [ -n "$bind_bindpw" -a "$bind_bindpw" != "/etc/machine.secret" ]; then
	# Skip the passwdord change
	echowithtimestamp "skip named server password change"
	exit 0
fi

if [ "$1" = "postchange" ] ; then
	echowithtimestamp "updating named zone files after server password change"
	ucr commit /etc/bind/named.conf
	# Reload or restart LDAP-BIND (if running)
	if [ "$dns_backend" = "ldap" ]; then
		echowithtimestamp "reload or restart named after server password change"
		systemctl reload-or-try-restart named.service
	fi
fi
