Traccar on Koozali SME server

By telleropnul, December 30, 2018

To install Traccar on Koozali SME server:

wget https://github.com/traccar/traccar/releases/download/v4.2/traccar-linux-64-4.2.zip

unzip traccar-linux-64-4.2.zip
  Archive: traccar-linux-64-4.2.zip
  inflating: traccar.run
  inflating: README.txt

rm README.txt traccar-linux-64-4.2.zip
./traccar.run --help
mkdir traccar
./traccar.run --target traccar
cd traccar

java -jar tracker-server.jar conf/traccar.xml

In puTTY add a tunnel 8082 to localhost:8082 to your SSH connection
In your internet browser, type in "http://localhost:8082" to connect to the service.
Default login is "admin/admin".

To open a hole in the firewall:

config set traccar service TCPPort 8082 access public status enabled

signal-event remoteaccess-update

iptables -L -vn | grep 8082
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            43.229.61.147       tcp dpt:8082

netstat -laputen | grep 8082
tcp        0      0 0.0.0.0:8082                0.0.0.0:*                   LISTEN      0          12485      2135/java

reboot

To create a service start/stop script quick and dirty:

/etc/rc.d/init.d/traccar

#!/bin/sh
SERVICE_NAME=traccar
PID_PATH_NAME=/var/run/traccar/traccar.pid
case $1 in
    start)
        echo "Starting $SERVICE_NAME ..."
        if [ ! -f $PID_PATH_NAME ]; then
            cd /home/e-smith/files/users/someuser/home/traccar/
            nohup java -jar tracker-server.jar conf/traccar.xml >/dev/null 2>&1 &
            echo $! > $PID_PATH_NAME
            echo "$SERVICE_NAME started ..."
        else
            echo "$SERVICE_NAME is already running ..."
        fi
    ;;
    stop)
        if [ -f $PID_PATH_NAME ]; then
            PID=$(cat $PID_PATH_NAME);
            echo "$SERVICE_NAME stoping ..."
            kill $PID;
            echo "$SERVICE_NAME stopped ..."
            rm $PID_PATH_NAME
        else
            echo "$SERVICE_NAME is not running ..."
        fi
    ;;
    restart)
        if [ -f $PID_PATH_NAME ]; then
            PID=$(cat $PID_PATH_NAME);
            echo "$SERVICE_NAME stopping ...";
            kill $PID;
            echo "$SERVICE_NAME stopped ...";
            rm $PID_PATH_NAME
            echo "$SERVICE_NAME starting ..."
            nohup java -jar $PATH_TO_JAR /tmp 2>> /dev/null >> /dev/null &
            echo $! > $PID_PATH_NAME
            echo "$SERVICE_NAME started ..."
        else
            echo "$SERVICE_NAME is not running ..."
        fi
    ;;
esac
ln -s /etc/rc.d/init.d/traccar /etc/rc.d/rc0.d/K16traccar
ln -s /etc/rc.d/init.d/traccar /etc/rc.d/rc1.d/K16traccar
ln -s /etc/rc.d/init.d/traccar /etc/rc.d/rc2.d/K16traccar
ln -s /etc/rc.d/init.d/traccar /etc/rc.d/rc3.d/K16traccar
ln -s /etc/rc.d/init.d/traccar /etc/rc.d/rc4.d/K16traccar
ln -s /etc/rc.d/init.d/traccar /etc/rc.d/rc5.d/K16traccar
ln -s /etc/rc.d/init.d/traccar /etc/rc.d/rc6.d/K16traccar
ln -s /etc/rc.d/init.d/traccar /etc/rc.d/rc7.d/S92traccar

It is strongly recommended to run the service as a non-root user account.