SambaDC/image/ad-dnsupdate.sh
2026-09-24 11:29:54 -05:00

24 lines
1.1 KiB
Bash

#!/bin/sh
# =====================================================================================
# Samba dnsupdate wrapper: pins DNS registration to the address(es) this DC advertises.
#
# Why: a Docker host is multi-homed (docker0 + every user-defined bridge + whatever stale
# DHCP addresses linger). Samba's updater registers ALL non-loopback interfaces, so the DC's
# A record ends up containing 172.17.0.1 etc. Clients that pick one of those get connection
# failures that look like Kerberos/SMB bugs. Wired in via smb.conf:
# dns update command = /usr/local/bin/ad-dnsupdate
# so it governs the daemon's internal updater as well as manual invocations.
#
# The address list is written by ad-entrypoint to /run/ad-dc-addresses (one per line).
# =====================================================================================
IPFILE=/run/ad-dc-addresses
if [ -f "$IPFILE" ]; then
set -- --current-ip="$(head -n 1 "$IPFILE")" "$@"
# remaining lines (e.g. IPv6) -> additional --current-ip arguments
for line in $(tail -n +2 "$IPFILE"); do
set -- "$@" --current-ip="$line"
done
fi
exec /usr/sbin/samba_dnsupdate "$@"