#!/bin/sh

# Only run once
[ -n "${POST_UPGRADE_CACHE}" ] && touch "${POST_UPGRADE_CACHE}/`basename $0`"

# Skip if already configured or not present at all
TIMING_CF="/etc/conf.d/timing.local"
[ -e "${TIMING_CF}" ] || exit 0
grep -q "^start_gpsstatusd" "${TIMING_CF}" && exit 0

echo " * Configuring GPS status monitor."

# Work out whether gpsstatusd should be started or not
MODE="`gcs_rwvar gcs_get_varcf "mode" "${TIMING_CF}"`"

START_GPSSTATUSD="false"
case "${MODE}" in
direct_gps)
	START_GPSSTATUSD="true"
	;;
esac

# Update the config file
gcs_rwvar gcs_set_varcf "start_gpsstatusd" "${TIMING_CF}" "${START_GPSSTATUSD}"
exit $?
