#!/bin/bash # # ntpd Time synchronization daemon # # chkconfig: 2345 90 60 # description: ntpd is a time synchronization daemon # processname: ntpd # config: /etc/ntpd.conf # pidfile: /var/run/ntpd.pid ### BEGIN INIT INFO # Provides: ntpd # Required-Start: $network # Should-Start: $named # Required-Stop: $network # Should-Stop: $named # Default-Start: 2 3 4 5 # Short-Description: Synchronizes system time using the Network Time Protocol (NTP) # Description: The Network Time Protocol (NTP) is used to synchronize a computer's time # with another reference time source. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions RETVAL=0 # See how we were called. prog="ntpd" # Add options, especially -s to set the time correctly as we don't use rdate NTP_OPT=" -s" start() { gprintf "Starting %s: " "$prog" daemon ntpd $NTP_OPT RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd return $RETVAL } stop() { gprintf "Stopping %s: " "$prog" killproc ntpd 2>/dev/null RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ntpd return $RETVAL } rhstatus() { status ntpd } restart() { stop start } reload() { gprintf "Reloading ntpd daemon configuration: " killproc ntpd -HUP retval=$? echo return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; status) rhstatus ;; condrestart) [ -f /var/lock/subsys/ntpd ] && restart || : ;; *) gprintf "Usage: %s {start|stop|status|reload|restart|condrestart}\n" "$0" exit 1 esac exit $?