#!/bin/sh # # chronyd chronyd short service description # # chkconfig: 2345 58 74 # description: Client/server for the Network Time Protocol, \ # this program keeps your computer's clock accurate. # # Source function library . /etc/rc.d/init.d/functions # Get network config . /etc/sysconfig/network # default user if not overriden by config NTPD_USER="ntp" # Get service config - may override defaults [ -f /etc/sysconfig/chronyd ] && . /etc/sysconfig/chronyd # Check that networking is up. if is_yes "${NETWORKING}"; then if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then msg_network_down "Chronyd NTPD" exit 1 fi else exit 0 fi config=/etc/ntp/chrony.conf keyfile=/etc/ntp/keys chronyc=/usr/bin/chronyc chrony_command() { ! ( $chronyc < /dev/null 2>&1 & killerpid=$! wait $chronycpid >/dev/null 2>&1 kill $killerpid >/dev/null 2>&1 || echo "chronyd not responding" ) | grep -v '200 OK' } start() { # Check if the service is already running? if [ -f /var/lock/subsys/chronyd ]; then msg_already_running "Chronyd NTPD" return fi msg_starting "Chronyd NTPD" daemon /usr/sbin/chronyd -u $NTPD_USER $OPTIONS RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/chronyd } stop() { if [ ! -f /var/lock/subsys/chronyd ]; then msg_not_running "Chronyd NTPD" return fi # Stop daemons. msg_stopping "Chronyd NTPD" killproc chronyd rm -f /var/lock/subsys/chronyd } condrestart() { if [ ! -f /var/lock/subsys/chronyd ]; then msg_not_running "Chronyd NTPD" RETVAL=$1 return fi stop start } RETVAL=0 # See how we were called. case "$1" in start) start ;; stop) stop ;; restart) stop start ;; try-restart) condrestart 0 ;; force-reload) condrestart 7 ;; cyclelogs|flush-logs) status chronyd >/dev/null 2>&1 || exit 7 chrony_command cyclelogs ;; online|offline) status chronyd >/dev/null 2>&1 || exit 7 chrony_command $1 ;; command) status chronyd >/dev/null 2>&1 || exit 7 chrony_command "$2" ;; status) status chronyd RETVAL=$? if [ $RETVAL = 0 ]; then chrony_command sources fi ;; *) msg_usage "$0 {start|stop|restart|try-restart|force-reload|online|offline|cyclelogs|command|status}" exit 3 esac exit $RETVAL