S49ntpd 997 B

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