#!/bin/bash
#
# @(#) Generate charts for a single HP receiver.
#
# This is is the directory where the darkgps distribution lives.
PROGRAMDIR="/opt/ntp/timelord/shm"
#
# The semaphore that will prevent multiple copies of this
# file from running.
FSEM="/tmp/chartsemaphore"
#
# This is the directory where the EFC chart will be generated
EFILE="/opt/http/htdocs/darkgps/chartEFC0"
#
# This is the directory where the Holdover Uncertainty chart will be generated
UFILE="/opt/http/htdocs/darkgps/chartHU0"
#
# The title that will be generated in the chart
TITLE="darksmile.net Z3801A Receivers"
#
# This is the file that has the timelog data
LOG="/opt/gpsdata/timelogS0.log"
#
if [[ -f $FSEM ]]
then
	echo "Previous chart already running"
	exit
fi
#
# If we are trapped, then we remove the semaphore
trap "rm -f ${FSEM}" 1 2 3 15
#
cd $PROGRAMDIR || exit
touch $FSEM
	./gpschart -i "${LOG}" -e "${EFILE}" -u "${UFILE}" -t "${TITLE}"
	echo ""
rm -f $FSEM
