Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #!/usr/bin/env sh
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides: prtgprobe
  5. # Required-Start: $remote_fs $syslog
  6. # Required-Stop: $remote_fs $syslog
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: will run the MiniProbe as service
  10. # Description: This will run the PRTG Python Miniprobe as a service
  11. ### END INIT INFO
  12.  
  13. # Change the next 3 lines to suit where you install your script and what you want to call it
  14. DIR=/etc/PythonMiniProbe-development/miniprobe
  15. DAEMON=$DIR/probe.py
  16. DAEMON_NAME=prtgprobe
  17.  
  18. # This next line determines what user the script runs as.
  19. # Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
  20. DAEMON_USER=root
  21.  
  22. # The process ID of the script when it runs is stored here:
  23. PIDFILE=/var/run/$DAEMON_NAME.pid
  24.  
  25. . /lib/lsb/init-functions
  26.  
  27. do_start () {
  28. log_daemon_msg "Starting system $DAEMON_NAME daemon"
  29. start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --chdir $DIR --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON
  30. log_end_msg $?
  31. }
  32. do_stop () {
  33. log_daemon_msg "Stopping system $DAEMON_NAME daemon"
  34. start-stop-daemon --stop --pidfile $PIDFILE --retry 10
  35. log_end_msg $?
  36. }
  37.  
  38. case "$1" in
  39.  
  40. start|stop)
  41. do_${1}
  42. ;;
  43.  
  44. restart|reload|force-reload)
  45. do_stop
  46. do_start
  47. ;;
  48.  
  49. status)
  50. status_of_proc -p $PIDFILE "$DAEMON" "$DAEMON_NAME" && exit 0 || exit $?
  51. ;;
  52. *)
  53. echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
  54. exit 1
  55. ;;
  56.  
  57. esac
  58. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement