1#!/bin/sh 2# 3# Starts Network Time Protocol daemon 4# 5 6DAEMON="ntpd" 7PIDFILE="/var/run/$DAEMON.pid" 8 9NTPD_ARGS="-g" 10 11# shellcheck source=/dev/null 12[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON" 13 14start() { 15 printf 'Starting %s: ' "$DAEMON" 16 # shellcheck disable=SC2086 # we need the word splitting 17 start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \ 18 -- $NTPD_ARGS -p "$PIDFILE" 19 status=$? 20 if [ "$status" -eq 0 ]; then 21 echo "OK" 22 else 23 echo "FAIL" 24 fi 25 return "$status" 26} 27 28stop() { 29 printf 'Stopping %s: ' "$DAEMON" 30 start-stop-daemon -K -q -p "$PIDFILE" 31 status=$? 32 if [ "$status" -eq 0 ]; then 33 rm -f "$PIDFILE" 34 echo "OK" 35 else 36 echo "FAIL" 37 fi 38 return "$status" 39} 40 41restart() { 42 stop 43 sleep 1 44 start 45} 46 47case "$1" in 48 start|stop|restart) 49 "$1";; 50 reload) 51 # Restart, since there is no true "reload" feature. 52 restart;; 53 *) 54 echo "Usage: $0 {start|stop|restart|reload}" 55 exit 1 56esac 57