-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdxlgps.sh
81 lines (62 loc) · 1.54 KB
/
dxlgps.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
workingdir="$( cd "$(dirname "$0")" ; pwd -P )"
source ${workingdir}/ws-options.conf
piddir=${workingdir}/pidfiles
bindir=${workingdir}/bin
caldir=${workingdir}/calibrations
FIFOPATH=${workingdir}/fifos
beaconfile=${workingdir}/beacon.txt
commentfile=${workingdir}/comment.txt
GPS2APRS=${bindir}/gps2aprs
command -v ${GPS2APRS} >/dev/null 2>&1 || { echo "I miss " ${GPS2APRS} >&2; exit 1; }
function startgps2aprs {
echo "Start gps2aprs"
${GPS2APRS} -f 0 -i "/>" -I ${objectcall} -l 1 -N 127.0.0.1:4030 -n 5 -t /dev/ttyACM0:9600 -0 30 -b 15 -g 10 -D -r 127.0.0.1:4030 2>&1 > /dev/null &
gps_pid=$!
echo $gps_pid > $PIDFILE
}
function sanitycheck {
# check pidfiles in piddir
shopt -s nullglob # no error if no PIDFILE
for f in ${piddir}/*.pid; do
pid=`cat $f`
if [ -f /proc/$pid/exe ]; then ## pid is running?
echo "$(basename $f) ok pid: $pid"
else ## pid not running
echo "$(basename $f) died"
rm $f
fi
done
}
function checkproc {
#checks if prog is running or not
if [ -s $PIDFILE ];then ##have PIDFILE
pid=`cat $PIDFILE`
if [ -f /proc/$pid/exe ]; then ## pid is running?
return 0
else ## pid not running
return 1
fi
else ## no PIDFILE
return 1
fi
}
tnow=`date "+%x_%X"`
echo $tnow
### kill procs
if [ "x$1" == "xstop" ];then
killall gps2aprs
sanitycheck
exit 0
fi
# ## check for udpgate
LOGFILE=/tmp/gps2aprs.log
PIDFILE=${piddir}/gps2aprs.pid
checkproc
returnval=$?
if [ $returnval -eq 1 ];then
: > ${LOGFILE}
startgps2aprs
fi
sanitycheck
exit 0