forked from chaos-consulting/adsberry
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathais.sh
More file actions
23 lines (21 loc) · 701 Bytes
/
ais.sh
File metadata and controls
23 lines (21 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
#place this script in /opt/ais and chmod +x it
#Edit username and password here
username='user'
password='password'
#No changes needed from here on
msgs=""
gpspipe -w -2 -S | while read x ;
do
# cache AIS-messages
if [[ $x == *"AIS"* ]]; then
msgs+=$(echo "$x" | tr -d '\r\n')
msgs+=","
fi
# if more than 1 second elapsed and the cache is not empty, post the cached msgs to the server
if (( $SECONDS > 0 )) && [[ ! -z "${msgs}" ]]; then
echo "[ ${msgs%,*} ]" | gzip | curl -s -u $username:$password -X POST -H "Content-Type: application/json" -H "Content-encoding: gzip" --data-binary @- -m 1 https://ais.chaos-consulting.de/shipin/index.php &
SECONDS=0
msgs=""
fi
done