summaryrefslogtreecommitdiffstats
path: root/abs/core/ntp/ntpd
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/ntp/ntpd')
-rwxr-xr-xabs/core/ntp/ntpd40
1 files changed, 26 insertions, 14 deletions
diff --git a/abs/core/ntp/ntpd b/abs/core/ntp/ntpd
index 56f6248..825efc1 100755
--- a/abs/core/ntp/ntpd
+++ b/abs/core/ntp/ntpd
@@ -4,30 +4,42 @@
. /etc/rc.d/functions
. /etc/conf.d/ntp-client.conf
-PID=`pidof -o %PPID /usr/bin/ntpd`
+PIDFILE="/var/run/ntpd/ntpd.pid"
+PID=$(cat $PIDFILE 2> /dev/null)
+
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 &
- fi
- if [ ! -z "$PID" -o $? -gt 0 ]; then
- stat_fail
+ /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
- PID=`pidof -o %PPID /usr/bin/ntpd`
- echo $PID > /var/run/ntpd.pid
- add_daemon ntpd
- stat_done
+ stat_fail
+ exit 1
fi
;;
stop)
stat_busy "Stopping NTP Daemon"
- [ ! -z "$PID" ] && kill $PID &> /dev/null
- if [ $? -gt 0 ]; then
- stat_fail
+ 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
- rm_daemon ntpd
- stat_done
+ stat_fail
+ exit 1
fi
;;
restart)