mkr680-sysv-init 860 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. set -e
  3. ### BEGIN INIT INFO
  4. # Provides: mkr680-sender
  5. # Required-Start: $local_fs $remote_fs $network $time
  6. # Required-Stop: $local_fs $remote_fs $network $time
  7. # Should-Start: $syslog
  8. # Should-Stop: $syslog
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Short-Description: Environmental Sensor UART (BOSCH BME680)
  12. ### END INIT INFO
  13. pid() { pgrep -xu jb6113 -o 'php'; }
  14. status() {
  15. cd /home/jb6113/environmental-sensor-uart;
  16. pid || return 1;
  17. ps --no-headers p `pid` 2>/dev/null |grep 'php sender.php' &>/dev/null;
  18. }
  19. stop() { status && sudo kill -TERM `pid`; }
  20. start() { status || sudo -u jb6113 nohup php sender.php & }
  21. restart() { stop && start; }
  22. case "$1" in
  23. restart|stop|start) $1;;
  24. status) status && echo "running";;
  25. *)
  26. echo "Usage: $0 {start|stop|restart|status}"
  27. exit 1
  28. ;;
  29. esac
  30. exit 0