#!/bin/sh set -e ### BEGIN INIT INFO # Provides: mkr680-sender # Required-Start: $local_fs $remote_fs $network $time # Required-Stop: $local_fs $remote_fs $network $time # Should-Start: $syslog # Should-Stop: $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Environmental Sensor UART (BOSCH BME680) ### END INIT INFO pid() { pgrep -xu jb6113 -o 'php'; } status() { cd /home/jb6113/environmental-sensor-uart; pid || return 1; ps --no-headers p `pid` 2>/dev/null |grep 'php sender.php' &>/dev/null; } stop() { status && sudo kill -TERM `pid`; } start() { status || sudo -u jb6113 nohup php sender.php & } restart() { stop && start; } case "$1" in restart|stop|start) $1;; status) status && echo "running";; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit 0