ispeaker 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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=/app/ispeaker-service
  13. DAEMON=$DIR/ispeaker
  14. DAEMON_NAME=ispeaker-service
  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. export PYTHON_VLC_LIB_PATH="/usr/lib/libvlc.so.5"
  26. echo "Starting system $DAEMON_NAME daemon"
  27. start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS
  28. #log_end_msg $?
  29. echo $?
  30. }
  31. do_stop () {
  32. #log_daemon_msg "Stopping system $DAEMON_NAME daemon"
  33. echo "Stoping system $DAEMON_NAME daemon"
  34. start-stop-daemon --stop --pidfile $PIDFILE --retry 10
  35. /bin/rm -rf /userdata/ispeaker.fifo
  36. #log_end_msg $?
  37. echo $?
  38. }
  39. case "$1" in
  40. start|stop)
  41. do_${1}
  42. ;;
  43. restart|reload|force-reload)
  44. do_stop
  45. do_start
  46. ;;
  47. status)
  48. status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
  49. ;;
  50. *)
  51. echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
  52. exit 1
  53. ;;
  54. esac
  55. exit 0