You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.6 KiB

5 years ago
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: myservice
  4. # Required-Start: $remote_fs $syslog
  5. # Required-Stop: $remote_fs $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: Put a short description of the service here
  9. # Description: Put a long description of the service here
  10. ### END INIT INFO
  11. # Change the next 3 lines to suit where you install your script and what you want to call it
  12. DIR=/usr/local/bin/ComputerSwitchboard
  13. DAEMON=$DIR/minimal_read3.py
  14. DAEMON_NAME=minimal_read3
  15. # Add any command line options for your daemon here
  16. DAEMON_OPTS=""
  17. # This next line determines what user the script runs as.
  18. # Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
  19. DAEMON_USER=root
  20. # The process ID of the script when it runs is stored here:
  21. PIDFILE=/var/run/$DAEMON_NAME.pid
  22. . /lib/lsb/init-functions
  23. do_start () {
  24. log_daemon_msg "Starting system $DAEMON_NAME daemon"
  25. start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS
  26. log_end_msg $?
  27. }
  28. do_stop () {
  29. log_daemon_msg "Stopping system $DAEMON_NAME daemon"
  30. start-stop-daemon --stop --pidfile $PIDFILE --retry 10
  31. log_end_msg $?
  32. }
  33. case "$1" in
  34. start|stop)
  35. do_${1}
  36. ;;
  37. restart|reload|force-reload)
  38. do_stop
  39. do_start
  40. ;;
  41. status)
  42. status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
  43. ;;
  44. *)
  45. echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
  46. exit 1
  47. ;;
  48. esac
  49. exit 0