pingpanel 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/sh
  2. #
  3. # /etc/init.d/pingpanel Startup script for the PingPanel process
  4. #
  5. ### BEGIN INIT INFO
  6. # Provides: pingpanel
  7. # Required-Start: $remote_fs
  8. # Required-Stop: $remote_fs
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Short-Description: PingPanel monitoring of network devices
  12. # Description: PingPanel is a utility for monitoring network devices
  13. # and provides a web-based service, the panel, for
  14. # displaying the captured statuses.
  15. ### END INIT INFO
  16. . /lib/lsb/init-functions
  17. DAEMON=/opt/PingPanel/PingPanel.py
  18. CONFIG=/opt/PingPanel/config.cfg
  19. NAME=pingpanel
  20. DESC="PingPanel monitor service"
  21. LOGFILE=/var/log/pingpanel.log
  22. PINGPANEL_OPTS=
  23. set -e
  24. # Check if DAEMON binary exist
  25. [ -f $DAEMON ] || exit 0
  26. [ -f "/etc/default/$NAME" ] && . /etc/default/$NAME
  27. PINGPANEL_OPTS="-c $CONFIG $PINGPANEL_OPTS"
  28. case "$1" in
  29. start)
  30. log_daemon_msg "Starting $DESC" "$NAME"
  31. start_daemon /usr/bin/python3 -u $DAEMON $PINGPANEL_OPTS 1>>$LOGFILE 2>>$LOGFILE &
  32. if pgrep -f $DAEMON
  33. then
  34. log_success_msg "$DAEMON running."
  35. else
  36. log_failure_msg "$DAEMON start FAILED!"
  37. fi
  38. ;;
  39. stop)
  40. log_daemon_msg "Stopping $DESC" "$NAME"
  41. kill -9 $(pgrep -f $DAEMON)
  42. if pgrep -f $DAEMON
  43. then
  44. log_end_msg 1
  45. else
  46. log_end_msg 0
  47. fi
  48. ;;
  49. restart)
  50. $0 stop
  51. sleep 2
  52. $0 start
  53. ;;
  54. status)
  55. if pgrep -f $DAEMON
  56. then
  57. log_end_msg 0
  58. exit 0
  59. else
  60. log_end_msg 1
  61. exit 1
  62. fi
  63. ;;
  64. *)
  65. log_action_msg "Usage: /etc/init.d/$NAME {start|stop|restart|status}"
  66. ;;
  67. esac
  68. exit 0