S60netdata 960 B

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