forked from ursereg/ntripclient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathntripclient.sh
More file actions
22 lines (20 loc) · 718 Bytes
/
ntripclient.sh
File metadata and controls
22 lines (20 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
#
. /etc/default/ntripclient.conf
DateStart=`date -u '+%s'`
SLEEPMIN=10 # Wait min sec for next reconnect try
SLEEPMAX=10000 # Wait max sec for next reconnect try
while true;
do
ntripclient -s $SERVER -r $PORT -m $MOUNTPOINT -u $USER -p $PASSWORD -D $DEVICE -B $BAUDRATE
if test $? -eq 0;
then
DateStart=`date -u '+%s'`; fi
DateCurrent=`date -u '+%s'`
SLEEPTIME=`echo $DateStart $DateCurrent | awk '{printf("%d",($2-$1)*0.02)}'`
if test $SLEEPTIME -lt $SLEEPMIN; then SLEEPTIME=$SLEEPMIN; fi
if test $SLEEPTIME -gt $SLEEPMAX; then SLEEPTIME=$SLEEPMAX; fi
# Sleep 2 percent of outage time before next reconnect try
echo "Retry after " + $SLEEPTIME
sleep $SLEEPTIME
done