forked from pageauc/pi-timolo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpi-timolo.sh
executable file
·61 lines (55 loc) · 2 KB
/
pi-timolo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
# writtem by Claude Pageau
# Script to run pi-timolo.py in background available here
# wget https://raw.github.com/pageauc/pi-timolo/master/source/timolo.sh
# launch from command line or via entry in /etc/rc.local file
# You may have to change sleep delay if it does not run properly in rc.local
# make sure to make this script executable
# chmod +x timolo.sh
# NOTE : This script can be used as a generic launcher by changing
# the parameters below
# This script avoids launching the pi-timolo.py script more than once
# since the pi camera hardware cannot be run more than once sumultaneously.
progpath="$HOMR/pi-timolo"
progname="pi-timolo.py"
proglog="verbose.log"
progsleep=10
echo "$0 ver 1.1 written by Claude Pageau"
echo "-----------------------------------------------"
cd "$progpath"
# Check if progname exists
if [ ! -e $progname ]; then
echo "ERROR - Could Not Find $progname"
exit 1
fi
if [ -z "$(pgrep -f $progname)" ]; then
if [ "$1" = "start" ]; then
echo "START - Start $progpath/$progname in Background"
# delay for boot to complete if running from /etc/rc.local
echo "STATUS - Waiting $progsleep seconds ...."
sleep $progsleep
# comment line below for no redirection of console output
$progpath/$progname >/dev/null 2>&1 &
# NOTE set verbose = True in config.py then
# then uncomment line below for logging
# echo "Start $progpath/$progname with log to $progpath/$proglog"
# python -u $progpath/$progname > $progpath/$proglog &
fi
else
if [ "$1" = "stop" ]; then
echo "STATUS - Stopping $progname ...."
progPID=$(pgrep -f $progname)
sudo kill $progPID
fi
fi
if [ -z "$(pgrep -f $progname)" ]; then
echo "STATUS - $progname is Not Running ..."
echo "INFO - To Start $progname execute command below"
echo "INFO - $0 start"
else
progPID=$(pgrep -f $progname)
echo "STATUS - $progname is Running ..."
echo "STATUS - PID is $progPID"
echo "INFO - To Stop $progname execute command below"
echo "INFO - $0 stop"
fi