mirror of
https://github.com/owntracks/docker-recorder.git
synced 2026-08-26 10:37:17 +00:00
@@ -6,6 +6,7 @@ MAINTAINER Malte Deiseroth <mdeiseroth88@gmail.com>
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
COPY config.mk /config.mk
|
||||
COPY recorder.conf /etc/default/recorder.conf
|
||||
COPY recorder-health.sh /usr/local/sbin/recorder-health.sh
|
||||
|
||||
ENV VERSION=0.8.0
|
||||
|
||||
@@ -25,12 +26,15 @@ RUN apk add --no-cache --virtual .build-deps \
|
||||
&& cd / \
|
||||
&& chmod 755 /entrypoint.sh \
|
||||
&& rm -rf /usr/local/source \
|
||||
&& chmod 755 /usr/local/sbin/recorder-health.sh \
|
||||
&& apk del .build-deps
|
||||
|
||||
VOLUME ["/store", "/config"]
|
||||
|
||||
COPY recorder.conf /config/recorder.conf
|
||||
|
||||
HEALTHCHECK CMD /usr/local/sbin/recorder-health.sh
|
||||
|
||||
EXPOSE 8083
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
addr=`hostname`
|
||||
port=8083
|
||||
|
||||
epoch=$(date +%s)
|
||||
|
||||
location=$(cat <<EOJSON
|
||||
{
|
||||
"_type": "location",
|
||||
"tid": "pp",
|
||||
"lat": 51.47879,
|
||||
"lon": -0.010677,
|
||||
"tst": $epoch
|
||||
}
|
||||
EOJSON
|
||||
)
|
||||
|
||||
# POST location to ping/ping, ignoring output
|
||||
curl -sSL --data "${location}" "http://${addr}:${port}/pub?u=ping&d=ping" > /dev/null
|
||||
|
||||
# obtain tst of ping/ping's last location
|
||||
ret_epoch=$(curl -sSL http://${addr}:${port}/api/0/last --data "user=ping&device=ping" |
|
||||
env python -c 'import sys, json; print json.load(sys.stdin)[0]["tst"];')
|
||||
|
||||
if [ $epoch -ne $ret_epoch ]; then
|
||||
echo PANIC $epoch $ret_epoch
|
||||
exit 1
|
||||
else
|
||||
echo OK
|
||||
exit 0
|
||||
fi
|
||||
Reference in New Issue
Block a user