#!/bin/sh

# PROVIDE: gpxloggerd
# REQUIRE: NETWORKING DAEMON cleanvar devfs gpsd
# BEFORE:  ntpd
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable gpxloggerd:
#
# gpxloggerd_enable (bool):	Set to "NO" by default.
#				Set it to "YES" to enable gpxloggerd.
#
# gpxloggerd_host (str):	Set to "" by default, which is equal
#				to "localhost:2947".
#				Set to host:port if gpsd is not local.
#
# gpxloggerd_flags (str):	Set to "-d" by default.
#
# gpxloggerd_template (str):	Set to "/var/log/%d %B %Y - %H:%M.gpx"
#				by default.
#				
#				See gpxloggerd(8) for more info.

. /etc/rc.subr

name=gpxloggerd
rcvar=gpxloggerd_enable

load_rc_config $name

# Set defaults
template="${gpxloggerd_template:-/var/log/%d %B %Y - %H:%M.gpx}"
user="${gpxloggerd_user:-nobody}"
group="${gpxloggerd_group:-nobody}"
pidfile=/var/run/$name.pid

command=%%PREFIX%%/sbin/$name
command_args="-u ${user}:${group} -p ${pidfile} -f \"${template}\" $gpxloggerd_host"

run_rc_command "$1"
