#!/bin/sh
# Make sure LDAP certificate is downloaded when the network become
# available, if the init.d script failed to fetch it at boot.

if [ -r /etc/debian-edu/config ] ; then
    . /etc/debian-edu/config
fi

if [ false = "$DHCP_FETCH_LDAP_CERT" ] ; then
    exit 0
fi

# Avoid dependency loop by not calling init.d script when dhclient is
# called by init.d/networking.  Workaround for BTS issue #754218.
if [ -d /run/systemd/system ]; then
    systemctl list-jobs | grep -q network.target && exit 0
fi

case $reason in
    BOUND|RENEW|REBIND|REBOOT)
	/etc/init.d/fetch-ldap-cert start
	;;
    EXPIRE|FAIL|RELEASE|STOP)
	;;
esac
