Traccar on DietPi, just a little help to installation scripts

Hi, few months ago I did an official request here: https://github.com/MichaIng/DietPi/discussions/5571

And today I tried to make functional all the scritps necessary for adding it to DietPi if possible.

I just need some help because I have very low codding knowledge

Install script:

#!/bin/bash
curl -L https://github.com/tananaev/traccar/releases/download/v5.5/traccar-linux-arm-5.5.zip > traccar.zip
unzip traccar.zip
rm traccar.zip
sudo ./traccar.run
#apt install default-jre-headless (it would be necessary to dietpi to install that package on this step if arm64 is detected)
rm /opt/traccar/jre/bin/java
ln -s /usr/lib/jvm/java-17-openjdk-arm64/bin/java /opt/traccar/jre/bin/java
#run as non root user
useradd traccar
chown -R traccar:traccar /opt/traccar
mkdir /etc/systemd/system/traccar.service.d/
touch /etc/systemd/system/traccar.service.d/run-as-user.conf
cat > /etc/systemd/system/traccar.service.d/run-as-user.conf <<EOF
[Service]
User=traccar
Group=traccar
EOF
systemctl start traccar

Here as I put on the comments, it would be necessary to add the instalation of package 196 for those systems running arm64, if not these line are not necessary:

rm /opt/traccar/jre/bin/java
ln -s /usr/lib/jvm/java-17-openjdk-arm64/bin/java /opt/traccar/jre/bin/java

Update script:

#!/bin/bash
systemctl stop traccar
#make a backup of database files on /opt/traccar/data and config files on /opt/traccar/conf, I make this with the copy of dietpi-backup overwriting files
rm /opt/traccar
curl -L https://github.com/tananaev/traccar/releases/download/v5.5/traccar-linux-arm-5.5.zip > traccar.zip
unzip traccar.zip
rm traccar.zip
sudo ./traccar.run
#apt install default-jre-headless (it would be necessary to dietpi to install that package on this step if arm64 is detected)
chown -R traccar:traccar /opt/traccar
rm /opt/traccar/jre/bin/java
ln -s /usr/lib/jvm/java-17-openjdk-arm64/bin/java /opt/traccar/jre/bin/java
systemctl start traccar

Uninstall script:

systemctl stop traccar
#Remove systemd service
systemctl disable traccar
rm /etc/systemd/system/traccar.service
systemctl daemon-reload
#Remove traccar user
deluser traccar
#Remove traccar directory
rm -R /opt/traccar

It would be needed to change this:

curl -L https://github.com/tananaev/traccar/releases/download/v5.5/traccar-linux-arm-5.5.zip > traccar.zip

To something that gets dinamically the latest release, and not the number version.

What do you think? Is it possible?

I’m sure you can improve it a lot…

Just wanted to help the community.

Regards.

1 Like

Pretty cool!!! Thanks!
GPS Tracking Software - Free and Open Source System - Traccar
Linux Installation - Traccar

1 Like

I have a (off topic) question about how this works.so I install the client software on my desired GPS-capable client. This client sends it’s coordinates via network (cellular/wifi) to my self-hosted server?

That’s correct @Jappe
You don’t need to install anything on the device, just setting up your server IP address or alias.