-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from mavericm1/master
adding bash script for install / start / stop
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
|
||
targetdir=/home/pi | ||
pidfile=/tmp/voc.pid | ||
|
||
case "$1" in | ||
|
||
start) | ||
|
||
if [ $(ls $pidfile) ] && [ $(ps $(cat $pidfile) | egrep -v "PID") ] | ||
then | ||
echo "VOC RUNNING PLEASE STOP PROCESS FIRST $0 stop" | ||
else | ||
sudo node $targetdir/index.js -o | ffplay -i - -analyzeduration 1 -probesize 32 -sync ext & | ||
vocpid=$! | ||
echo "$vocpid" > $pidfile | ||
echo "VOC Started!" | ||
fi | ||
|
||
|
||
;; | ||
|
||
stop) | ||
|
||
if [[ $(ls $pidfile) ]] | ||
then | ||
kill $(cat $pidfile) | ||
rm $pidfile | ||
echo "VOC Stopped!" | ||
else | ||
sudo node $targetdir/index.js -o | ffplay -i - -analyzeduration 1 -probesize 32 -sync ext & | ||
vocpid=$! | ||
echo "$vocpid" > $pidfile | ||
fi | ||
|
||
|
||
;; | ||
|
||
install) | ||
|
||
sudo apt-get install -y ffmpeg curl | ||
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - | ||
sudo apt-get install -y nodejs git | ||
git clone https://github.com/fpv-wtf/voc-poc.git | ||
cp -r voc-poc/* $targetdir/ # voc-poc expects /home/pi/index.js | ||
npm install | ||
sudo apt-get install -y libudev-dev | ||
|
||
$0 start | ||
|
||
;; | ||
|
||
*) | ||
if [ $(ls $pidfile)] && [ $(ps $(cat $pidfile) | egrep -v "PID") ] | ||
then | ||
echo "VOC RUNNING" | ||
else | ||
if [[ $(ls $targetdir/index.js) ]] | ||
then | ||
echo "VOC installed please run $0 start" | ||
else | ||
$0 install | ||
fi | ||
fi | ||
;; | ||
esac | ||
|