5
# Required-Start: $network $remote_fs $syslog
6
# Required-Stop: $network $remote_fs $syslog
7
# Default-Start: 2 3 4 5
9
# Short-Description: Start NTP daemon
12
PATH=/sbin:/bin:/usr/sbin:/usr/bin
14
. /lib/lsb/init-functions
18
PIDFILE=/var/run/ntpd.pid
20
test -x $DAEMON || exit 5
22
if [ -r /etc/default/$NAME ]; then
26
if [ -e /etc/ntp.conf.dhcp ]; then
27
NTPD_OPTS="$NTPD_OPTS -c /etc/ntp.conf.dhcp"
31
LOCKFILE=/var/lock/ntpdate
34
if [ -x /usr/bin/lockfile-create ]; then
35
lockfile-create $LOCKFILE
36
lockfile-touch $LOCKFILE &
42
if [ -x /usr/bin/lockfile-create ] ; then
44
lockfile-remove $LOCKFILE
50
UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true
54
log_daemon_msg "Starting NTP server" "ntpd"
55
if [ -z "$UGID" ]; then
56
log_failure_msg "user \"$RUNASUSER\" does not exist"
60
start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -p $PIDFILE -u $UGID $NTPD_OPTS
66
log_daemon_msg "Stopping NTP server" "ntpd"
67
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
72
$0 stop && sleep 2 && $0 start
75
if $0 status >/dev/null; then
85
pidofproc -p $PIDFILE $DAEMON >/dev/null
87
if [ $status -eq 0 ]; then
88
log_success_msg "NTP server is running."
90
log_failure_msg "NTP server is not running."
95
echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"