core/ntp/ntpd

53 lines
955 B
Plaintext
Raw Normal View History

2010-09-04 05:10:46 +08:00
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
2011-10-06 23:01:44 +08:00
. /etc/conf.d/ntpd.conf
2010-09-04 05:10:46 +08:00
PIDFILE="/var/run/ntpd/ntpd.pid"
PID=$(cat $PIDFILE 2> /dev/null)
2010-09-04 05:10:46 +08:00
case "$1" in
start)
stat_busy "Starting NTP Daemon"
[ ! -d /var/run/ntpd ] && install -d /var/run/ntpd &>/dev/null
2010-09-04 05:10:46 +08:00
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
2010-09-04 05:10:46 +08:00
else
stat_fail
exit 1
2010-09-04 05:10:46 +08:00
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
2010-09-04 05:10:46 +08:00
else
stat_fail
exit 1
2010-09-04 05:10:46 +08:00
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac