Merge pull request #48 from akhepcat/master

startup script/systemd cleanup
pull/58/head
bert hubert 2019-12-26 22:19:21 +01:00 committed by GitHub
commit 10dbbad213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 18 deletions

18
Dockerfile-pi 100644
View File

@ -0,0 +1,18 @@
#FROM ubuntu:disco
FROM arm32v7/debian:unstable
ENV DEBIAN_FRONTEND noninteractive
ENV LC_ALL C.UTF-8
# Update packages and install dependencies
RUN apt-get update && apt-get -y upgrade && apt-get -y clean
RUN apt-get install -y protobuf-compiler libh2o-dev libcurl4-openssl-dev \
libssl-dev libprotobuf-dev libh2o-evloop-dev libwslay-dev libeigen3-dev \
make clang-9 build-essential curl autoconf automake libfmt-dev libncurses5-dev \
&& apt-get -y clean
# Build
ADD . /galmon/
WORKDIR /galmon/
RUN make
ENV PATH=/galmon:${PATH}

View File

@ -182,7 +182,7 @@ This allows anyone to send you frames, so be aware.
Next up, run `navnexus ./storage ::`, which will serve your recorded data from port 29601. It will merge messages
coming in from all sources and serve them in time order.
Finally, you can do `nv 127.0.0.1 29601 | ./navdump`, which will give you all messages over the past 24 hours, and stream you more.
Finally, you can do `nc 127.0.0.1 29601 | ./navdump`, which will give you all messages over the past 24 hours, and stream you more.
This also works for `navparse` for the pretty website and influx storage, `nc 127.0.0.1 29601 | ./navparse 127.0.0.0:10000 html galileo`,
if you have an influxdb running on localhost with a galileo database in there.
@ -267,6 +267,7 @@ In alphabetical order:
* Spain
* Tonga
* USA
* Alaska (Anchorage)
* California (Santa Cruz, Los Angeles area, etc)
* Massachusetts (Boston area)
* Uruguay

View File

@ -7,10 +7,11 @@ StartLimitIntervalSec=0
Type=simple
Restart=always
RestartSec=1
# uncomment User and Group to not run as root
#User=ubxtool
#Group=ubxtool
#DynamicUser=yes
#RuntimeDirectory=ubxtool
RuntimeDirectory=ubxtool
RuntimeDirectoryPreserve=yes
WorkingDirectory=/run/ubxtool
ExecStart=/usr/local/ubxtool/ubxtool.sh

View File

@ -1,21 +1,46 @@
#!/bin/bash
runDir="/run/ubxtool"
DEVICE="/dev/ttyACM0"
DESTINATION="`cat /usr/local/ubxtool/destination`"
CONSTELLATIONS="--galileo --gps --glonass"
# CONSTELLATIONS="--galileo --gps --beidou"
# CONSTELLATIONS="--galileo --gps --glonass --beidou" # only on the F9P
DIR="/run/ubxtool"
# DEVICE="/dev/ttyACM0" # comment out or leave blank to auto-search
STATION="`cat /usr/local/ubxtool/station`"
CONSTELLATIONS="--galileo --gps --beidou"
#########################################################################
rotate() {
logt=$1
cd ${runDir}
if [ -r ${logt}.log ]; # only rotate if there's a current logfile
then
if [ -r ${logt}.log.4 ]; then mv ${logt}.log.4 ${logt}.log.5 ; fi;
if [ -r ${logt}.log.3 ]; then mv ${logt}.log.3 ${logt}.log.4 ; fi;
if [ -r ${logt}.log.2 ]; then mv ${logt}.log.2 ${logt}.log.3 ; fi;
if [ -r ${logt}.log.1 ]; then mv ${logt}.log.1 ${logt}.log.2 ; fi;
if [ -r ${logt}.log ]; then mv ${logt}.log ${logt}.log.1 ; fi;
fi
}
(
mkdir ${DIR}
cd ${DIR}
mv stdout.log.4 stdout.log.5 ; mv stderr.log.4 stderr.log.5 ; mv logfile.4 logfile.5
mv stdout.log.3 stdout.log.4 ; mv stderr.log.3 stderr.log.4 ; mv logfile.3 logfile.4
mv stdout.log.2 stdout.log.3 ; mv stderr.log.2 stderr.log.3 ; mv logfile.2 logfile.3
mv stdout.log.1 stdout.log.2 ; mv stderr.log.1 stderr.log.2 ; mv logfile.1 logfile.2
mv stdout.log stdout.log.1 ; mv stderr.log stderr.log.1 ; mv logfile logfile.1
) 2> /dev/null
if [ -z "${DEVICE}" ];
then
# programmatically find the interface
SYSD=$(grep -il u-blox /sys/bus/usb/devices/*/manufacturer)
SYSD=${SYSD//manufacturer/}
DEVD=$(find ${SYSD} -type d -iname 'ttyACM*')
DEVICE="/dev/${DEVD##*/}"
fi
exec /usr/local/ubxtool/ubxtool --wait ${CONSTELLATIONS} --port ${DEVICE} --station ${STATION} --destination ${DESTINATION} >> stdout.log 2>> stderr.log < /dev/null
DESTINATION=$(cat /usr/local/ubxtool/destination)
STATION=$(cat /usr/local/ubxtool/station)
# systemctl script will do this, but if you don't use systemctl, we need to take care of it
[[ -d ${runDir} ]] || mkdir -p ${runDir}
[[ -e ${runDir}/gps.sock ]] || mkfifo ${runDir}/gps.sock
for logFile in stdout stderr logfile
do
rotate ${logFile}
done
exec /usr/local/ubxtool/ubxtool --wait ${CONSTELLATIONS} --port ${DEVICE} --station ${STATION} --destination ${DESTINATION} >> ${runDir}/stdout.log 2>> ${runDir}/stderr.log < /dev/null