#!/bin/bash
#
# recordum_ntp_fix
#
# v0.1 2014-02-07 RE
#
# when switching to DHCP usage, the ntp daemon possibly creates a time server file (if the server also serves as a time server)
# this file will not be delete, when switching to static addresses; therefore we will delete it manually upon start up
# by adding the call to /etc/rc.local

NTPDEFAULT=/var/lib/ntp/ntp.conf.dhcp
DHCP=$( grep "iface eth0 " /etc/network/interfaces |awk '{print $4}' |awk 'FNR <= 1' ) || exit 1

# when static, then remove a possible wrong ntp
if [[ ${DHCP} == "static" ]]
then
    if [[ -f ${NTPDEFAULT} ]]
    then
        /bin/rm -f ${NTPDEFAULT} || exit 2
        service ntp restart
    fi
fi

exit 0
