Skip to content

Commit 7377064

Browse files
committed
adding bash script for install / start / stop
1 parent 7dc370e commit 7377064

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

install-scripts/pi.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
targetdir=/home/pi
4+
pidfile=/tmp/voc.pid
5+
6+
case "$1" in
7+
8+
start)
9+
10+
if [ $(ls $pidfile) ] && [ $(ps $(cat $pidfile) | egrep -v "PID") ]
11+
then
12+
echo "VOC RUNNING PLEASE STOP PROCESS FIRST $0 stop"
13+
else
14+
sudo node $targetdir/index.js -o | ffplay -i - -analyzeduration 1 -probesize 32 -sync ext &
15+
vocpid=$!
16+
echo "$vocpid" > $pidfile
17+
echo "VOC Started!"
18+
fi
19+
20+
21+
;;
22+
23+
stop)
24+
25+
if [[ $(ls $pidfile) ]]
26+
then
27+
kill $(cat $pidfile)
28+
rm $pidfile
29+
echo "VOC Stopped!"
30+
else
31+
sudo node $targetdir/index.js -o | ffplay -i - -analyzeduration 1 -probesize 32 -sync ext &
32+
vocpid=$!
33+
echo "$vocpid" > $pidfile
34+
fi
35+
36+
37+
;;
38+
39+
install)
40+
41+
sudo apt-get install -y ffmpeg curl
42+
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
43+
sudo apt-get install -y nodejs git
44+
git clone https://github.com/fpv-wtf/voc-poc.git
45+
cp -r voc-poc/* $targetdir/ # voc-poc expects /home/pi/index.js
46+
npm install
47+
sudo apt-get install -y libudev-dev
48+
49+
$0 start
50+
51+
;;
52+
53+
*)
54+
if [ $(ls $pidfile)] && [ $(ps $(cat $pidfile) | egrep -v "PID") ]
55+
then
56+
echo "VOC RUNNING"
57+
else
58+
if [[ $(ls $targetdir/index.js) ]]
59+
then
60+
echo "VOC installed please run $0 start"
61+
else
62+
$0 install
63+
fi
64+
fi
65+
;;
66+
esac
67+

0 commit comments

Comments
 (0)