forked from af001/pi-detector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
watch.sh
executable file
·45 lines (40 loc) · 1.26 KB
/
watch.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
#!/bin/bash
# This script will run the webserver.py as a background task
# You will then be able close the terminal session. To auto start
# Add the following command to the /etc/rc.local
# /home/pi/pi-detector/watch.sh start
progpath="/home/pi/pi-detector"
progname="watch.py"
watchpath="/home/pi/pi-timolo/media/motion"
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 $progname in Background ..."
./$progname $watchpath & #>/dev/null 2>&1 &
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
echo "Done"