#!/bin/bash

if [ -x /usr/bin/logger ]; then
	LOGGER="/usr/bin/logger -s -p user.notice -t NetworkManagerDispatcher"
else
	LOGGER=echo
fi

if [ ! -x /etc/init.d/ntpd ]; then
  $LOGGER "init script /etc/init.d/ntpd missing or not executible"
  return
fi
  
if [ -n $1 ] && [ $2 == "up" ]; then

  if [ -f /var/run/ntpd.pid ]; then
    $LOGGER "ntpd is running, restart"
    /sbin/service ntpd restart
  else
    $LOGGER "ntpd is not running, start"
    /sbin/service ntpd start
  fi

fi

if [ -n $1 ] && [ $2 == "down" ] && [ -f /var/run/ntpd.pid ]; then
  $LOGGER "ntpd is running, stop"
  /sbin/service ntpd stop
fi

