eole-lemonldap/postservice/98-lemonldap-ng-scribe-regi...

46 lines
1.4 KiB
Plaintext
Raw Normal View History

#!/bin/bash
[ "$(CreoleGet activerLemon non)" = 'oui' ] || exit 0
[ -f /usr/lib/eole/eolead.sh ] || exit 0
. /usr/lib/eole/eolead.sh
# ScribeAD/HorusAD
. $CONTAINER_ROOTFS/etc/eole/samba4-vars.conf
DNS_IP="${CONTAINER_IP}"
CONTAINER_EXEC='lxc-attach -n addc --'
EXT_IP=$(CreoleGet adresse_ip_eth0)
for service in manager auth reload
do
fqdn=$(CreoleGet "${service}WebName")
service_addr=$(dig "@${DNS_IP}" "${fqdn}" +short)
if [ "${service_addr}" != "${EXT_IP}" ]
then
${CONTAINER_EXEC} kinit "${AD_HOST_NAME^^}@${AD_REALM^^}" -k -t "${AD_HOST_KEYTAB_FILE}"
if [ -n "${service_addr}" ]
then
echo -n "Suppression de lenregistrement DNS '${fqdn} IN A ${service_addr}' : "
$CONTAINER_EXEC samba-tool \
dns \
delete \
"${AD_HOST_NAME}.${AD_REALM}" \
"${AD_REALM}" \
"${fqdn}" A "${service_addr}" \
-k 1
fi
echo -n "Ajout de lenregistrement DNS '${fqdn} IN A ${EXT_IP}' : "
$CONTAINER_EXEC samba-tool \
dns \
add \
"${AD_HOST_NAME}.${AD_REALM}" \
"${AD_REALM}" \
"${fqdn}" A "${EXT_IP}" \
-k 1
fi
done
exit 0