#!/bin/sh # vim: set sw=4 ts=4 sts=4 et : SYSVOL=/var/lib/samba/sysvol IDMAP_LDB=/var/lib/samba/private/idmap.ldb case "${DEBUG}" in yes|YES|y|Y|on|ON|1|true|TRUE|t|T) unset DEBUG DEBUG=1 ;; *) unset DEBUG ;; esac debug() { [ -z "${DEBUG}" ] || echo "$*" >&2 } info() { echo "$*" >&2 } get_pdc() { dig @localhost +short -t srv _ldap._tcp.pdc._msdcs.$(dnsdomainname) \ | sort -n \ | awk '{print $4;exit}' } fqdn=$(hostname -f) pdc=$(get_pdc) pdc="${pdc%.}" if [ "${pdc}" = "${fqdn}" ]; then debug 'Skipping SYSVOL sync on PDC emulator' exit 0 fi if [ -z "${pdc}" ]; then echo 'Could not identify PDC emulator' >&2 exit 1 fi debug "Found PDC emulator: ${pdc}" ssh_config=/var/cache/sysvolsync/ssh_config debug "Generating configuration file: ${ssh_config}" cat > "${ssh_config}" <