summaryrefslogtreecommitdiff
path: root/extra/ntp/ntpd
diff options
context:
space:
mode:
authorroot <root@rshg054.dnsready.net>2012-01-01 23:14:56 +0000
committerroot <root@rshg054.dnsready.net>2012-01-01 23:14:56 +0000
commit29f5aa692a3fa3ff3e743a47d1c57f1cc0341809 (patch)
tree862d365a74545cb3e7616d14e3b660aae977e6f8 /extra/ntp/ntpd
parent8654516201466a2dd3f3f05a6c0095e69c01715c (diff)
Sun Jan 1 23:14:56 UTC 2012
Diffstat (limited to 'extra/ntp/ntpd')
-rwxr-xr-xextra/ntp/ntpd81
1 files changed, 38 insertions, 43 deletions
diff --git a/extra/ntp/ntpd b/extra/ntp/ntpd
index a3e886e1f..480fa1088 100755
--- a/extra/ntp/ntpd
+++ b/extra/ntp/ntpd
@@ -4,49 +4,44 @@
. /etc/rc.d/functions
. /etc/conf.d/ntpd.conf
-PIDFILE="/var/run/ntpd/ntpd.pid"
-PID=$(cat $PIDFILE 2> /dev/null)
+unset PID
+PIDFILE='/run/ntpd.pid'
+
+if [[ -r ${PIDFILE} ]]; then
+ read -r PID <"${PIDFILE}"
+ if [[ -n ${PID} && ! -d /proc/${PID} ]]; then
+ rm -f "${PIDFILE}"
+ unset PID
+ fi
+fi
case "$1" in
- start)
- stat_busy "Starting NTP Daemon"
- [ ! -d /var/run/ntpd ] && install -d /var/run/ntpd &>/dev/null
- if [ -z "$PID" ]; then
- /usr/bin/ntpd $NTPD_ARGS -p /var/run/ntpd/ntpd.pid &>/dev/null
- if [ $? -gt 0 ]; then
- stat_fail
- exit 1
- else
- add_daemon ntpd
- stat_done
- fi
- else
- stat_fail
- exit 1
- fi
- ;;
- stop)
- stat_busy "Stopping NTP Daemon"
- if [ -n "$PID" ]; then
- kill $PID &> /dev/null
- if [ $? -gt 0 ]; then
- stat_fail
- exit 1
- else
- rm $PIDFILE &>/dev/null
- rm_daemon ntpd
- stat_done
- fi
- else
- stat_fail
- exit 1
- fi
- ;;
- restart)
- $0 stop
- sleep 1
- $0 start
- ;;
- *)
- echo "usage: $0 {start|stop|restart}"
+ start)
+ stat_busy "Starting NTP Daemon"
+ if [[ -z ${PID} ]] && /usr/bin/ntpd ${NTPD_ARGS} -p "${PIDFILE}" &>/dev/null; then
+ add_daemon ntpd
+ stat_done
+ else
+ stat_fail
+ exit 1
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping NTP Daemon"
+ if [[ -n ${PID} ]] && kill "${PID}" &>/dev/null; then
+ rm ${PIDFILE}
+ rm_daemon ntpd
+ stat_done
+ else
+ stat_fail
+ exit 1
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
esac