netdata-lsb.in 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-3.0+
  3. #
  4. ### BEGIN INIT INFO
  5. # Provides: netdata
  6. # Required-Start: $local_fs $remote_fs $network $named $time apache2 httpd squid nginx mysql named opensips upsd hostapd postfix lm_sensors
  7. # Required-Stop: $local_fs $remote_fs $network $named $time apache2 httpd squid nginx mysql named opensips upsd hostapd postfix lm_sensors
  8. # Should-Start: $local_fs $network $named $remote_fs $time $all
  9. # Should-Stop: $local_fs $network $named $remote_fs $time $all
  10. # Default-Start: 2 3 4 5
  11. # Default-Stop: 0 1 6
  12. # Short-Description: Start and stop the netdata real-time monitoring server daemon
  13. # Description: Controls the main netdata monitoring server daemon "netdata".
  14. # and all its plugins.
  15. ### END INIT INFO
  16. #
  17. set -e
  18. set -u
  19. ${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
  20. DAEMON="netdata"
  21. DAEMON_PATH=@sbindir_POST@
  22. PIDFILE=@localstatedir_POST@/run/$DAEMON.pid
  23. DAEMONOPTS="-P $PIDFILE"
  24. test -x $DAEMON_PATH/$DAEMON || exit 0
  25. . /lib/lsb/init-functions
  26. # Safeguard (relative paths, core dumps..)
  27. cd /
  28. umask 022
  29. service_start() {
  30. log_daemon_msg "Starting real-time performance monitoring" "netdata"
  31. start_daemon -p $PIDFILE $DAEMON_PATH/$DAEMON $DAEMONOPTS
  32. RETVAL=$?
  33. log_end_msg $RETVAL
  34. return $RETVAL
  35. }
  36. service_stop() {
  37. log_daemon_msg "Stopping real-time performance monitoring" "netdata"
  38. killproc -p ${PIDFILE} $DAEMON_PATH/$DAEMON
  39. RETVAL=$?
  40. log_end_msg $RETVAL
  41. if [ $RETVAL -eq 0 ]; then
  42. rm -f ${PIDFILE}
  43. fi
  44. return $RETVAL
  45. }
  46. condrestart() {
  47. if ! service_status > /dev/null; then
  48. RETVAL=$1
  49. return
  50. fi
  51. service_stop
  52. service_start
  53. }
  54. service_status() {
  55. status_of_proc -p $PIDFILE $DAEMON_PATH/$DAEMON netdata
  56. }
  57. #
  58. # main()
  59. #
  60. case "${1:-''}" in
  61. 'start')
  62. service_start
  63. ;;
  64. 'stop')
  65. service_stop
  66. ;;
  67. 'restart')
  68. service_stop
  69. service_start
  70. ;;
  71. 'try-restart')
  72. condrestart 0
  73. ;;
  74. 'force-reload')
  75. condrestart 7
  76. ;;
  77. 'status')
  78. service_status && exit 0 || exit $?
  79. ;;
  80. *)
  81. echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
  82. exit 1
  83. esac