summaryrefslogtreecommitdiffstats
path: root/network/chrony/rc.chrony
blob: 653f774a5da8f905b75b227cc0468dff3e86a94e (plain)
#!/bin/sh

################################################################################
chronyd_start() {
################################################################################
  if [ -n "$(pidof chronyd)" ]; then
    echo "chronyd seems to be already running."
  else
    echo "Starting chronyd:  /usr/sbin/chronyd -u @NTP_USER@"
    /usr/sbin/chronyd -u @NTP_USER@
  fi
}

################################################################################
chronyd_stop() {
################################################################################
  if [ -z "$(pidof chronyd)" ]; then
    echo "chronyd does not seem to be running."
  else
    echo "Stopping chronyd..."
    kill $(cat /var/run/chronyd.pid)
  fi
}

################################################################################
chronyd_restart() {
################################################################################
  if [ -n "$(pidof chronyd)" ]; then
    chronyd_stop
    sleep 1
  fi

  chronyd_start
}

case "$1" in
  'start')
    chronyd_start ;;
  'stop')
    chronyd_stop ;;
  'restart')
    chronyd_restart ;;
  *)
    echo "usage: $0 start|stop|restart" ;;
esac