S43htpdate 867 B

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