# -*- sh -*-

#------------------------------------------------------------------------
# bastion - Restart bastion on DHCP BOUND
# Copyright © 2014 Pôle de compétences EOLE <eole@ac-dijon.fr>
#
# License CeCILL:
#  * in french: http://www.cecill.info/licences/Licence_CeCILL_V2-fr.html
#  * in english http://www.cecill.info/licences/Licence_CeCILL_V2-en.html

# Check if some IP parameters has changed
is_ip_changed() {
    [ "${new_ip_address}" != "${old_ip_address}" ] \
	|| [ "${new_network_number}" != "${old_network_number}" ] \
	|| [ "${new_subnet_mask}" != "${old_subnet_mask}" ] \
	|| [ "${new_broadcast_address}" != "${old_broadcast_address}" ] \
	|| [ "${new_routers}" != "${old_routers}" ] \
	|| [ "${new_domain_name}" != "${old_domain_name}" ] \
	|| [ "${new_domain_name_servers}" != "${old_domain_name_servers}" ] \
	|| [ "${new_netbios_name_servers}" != "${old_netbios_name_servers}" ] \
	|| [ "${new_ntp_servers}" != "${old_ntp_servers}" ]
}

if [ "${reason}" = "BOUND" ]
then
    if is_ip_changed
    then
	/usr/sbin/bastion regen
    fi
fi
