FreeBSD

Script (in /usr/local/etc/rc.d) to launch Traccar on FreeBSD:

#!/bin/sh
#

# PROVIDE: traccar
# REQUIRE: DAEMON
# BEFORE:
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable `traccar':
#
# traccar_enable="YES"
#

. /etc/rc.subr

name="traccar"
rcvar="traccar_enable"

# read configuration and set defaults
load_rc_config "$name"
: ${traccar_enable="NO"}
: ${traccar_root="/opt/traccar"}                # standard root
: ${traccar_java="java"}                        # path to your JRE
: ${traccar_user="traccar"}                     # user to run as
: ${traccar_stdout="/dev/null"}
: ${traccar_stderr="/dev/null"}

traccar_chdir=${traccar_root}                   # will add a cd $traccar_root before launching

command="$traccar_java"
command_args="-jar ${traccar_root}/tracker-server.jar ${traccar_root}/conf/traccar.xml"
pidfile="/var/run/${name}.pid"
required_files="${traccar_root}/conf/traccar.xml"

# ugly hack to abuse this but I don't want to launch with nohup around su
start_cmd="/usr/sbin/daemon -p ${pidfile} -u ${traccar_user} ${command} ${command_args} > ${traccar_stdout} 2> ${traccar_stderr}"

run_rc_command "$1"

The rest of the installation instructions is like the OpenBSD version:

  1. Get the package
  2. sh traccar.run --noexec --target /usr/local/traccar (although there isn’t anything wrong with /opt/traccar if you’ve got a SYSV fetish. Or /var/www/traccar)
  3. Put the above script into /usr/local/etc/rc.d
  4. If you don’t want to run it as root you should add an appropriate user (just like OpenBSD, but not using ksh – this is a real BSD 8-), use a /bin/sh )
  5. Adapt traccar.cfg (I would use an editor instead of perl. But I’m riding a bike, not a tank)
  6. Edit /etc/rc.conf, adding at least:
traccar_enable=“yes"

and maybe

traccar_root=“/var/www/traccar"
traccar_user=“my-traccar-user"
traccar_java="/usr/local/openjdk7/bin/java”

if something is non-standard. You’ll find the variable names in the rc.d script further up.

If everything is ok,

/usr/local/etc/rc.d/traccar start

should launch it.