Notizbl0g.

h4cking, ham radio, fire fighting and m0re

Setting Up an XReflector

After fiddling around with some D-Star stuff I came to setting up an own D-Star reflector using dxrfd. As that is basically just some C program to compile there is some stuff to do to get it running as a service. My one is running on a server hosted at a German data center running Ubuntu 14.04 LTS at the moment. To set all this up there are several things to consider from logging up to refreshing the dashboard values

Creating a startup script

I took the basic script from [1] and did some modifications as i for example put the config into /etc/dxrfd and the XRF_STATUS file into /var/run. That starts up the reflector on system boot time and connects some preconfigured reflector uplinks using a cron job.

If you want to set up your XReflector to connect some other reflectors by default you can use the UDP control port and send some commands. In my case I (re-)connect some default reflectors every 15 minutes. This also prevents loosing them when the corresponding IP address changes. Reconnecting is simply done with a cronjob:

0,15,30,45 * * * * echo "lrf CREF006C" | netcat -uq 1 176.9.1.168 30002 2>&1 > /dev/null

This connects the local module C to REF006 module C every 15 minutes. If that is already connected nothing happens.

Logging

The host is running rsyslog and all messages from dxrfd kept appearing in the systems syslog. That blows up the logfile with unnecessary entries as every incoming reflector stream (also the unused modules) caused a line in the logfile. I wanted to redirect all the stuff that dxrfd logs into another single file. So I created a config file named /etc/rsyslog.d/30-dxrfd.conf with the following content:

if $programname == 'dxrfd' then -/var/log/dxrfd.log
if $programname == 'dxrfd' then stop

The first line redirects all output from dxrfd to the separate logfile. But as rsyslog goes on with the rest of the configs the logentries of dxrfd kept appearing in the syslog as well. So you need to add an extra line in order to exit the ruleset after the first match so that these messages cannot be logged to any other file that the dxrfd log file.

Dashboard

I use a dashboard from the XReflectorPlus package that is generated by xrf_lh which can be found in the two subdirectories for German and English language. That is basically a little C programm that connects the reflector on the control port (30002/UDP normally), lists all the connections and then pipes the output to an html file. The normal way is to redirect the output to a file in the webservers root directory. The problem with that is that the output file is truncated when the execution starts and filled not until the command finished. In this case the output file is empty for quite a while. During this time the requesting clients will only see a blank page and refreshing does not work any more.

My option is to redirect the ouput of the dashboard program to a temporary file and when that is done move the file to the target directory. This way the time with a blank file is greatly reduced and refreshing is not interrupted by a blank file. Updating is simply done with a little shell script that is called by cron every minute. The shell script is as follows:

#!/bin/sh
cd /home/df2et/XReflectorPlus/dashboard-31Oktober2015-EN
./xrf_lh 1NFO XRF518 N18 176.9.1.168 YES ./xrfs.url 60 "Contact: <a href=\"mailto:df2et@n18.de\">df2et@n18.de</a>" > status.html 2> /dev/null
mv status.html /var/www/xrf518.n18.de/index.html
exit 0

The dashboard of my reflector can be found unter [2]

References

[1] https://github.com/ggramaize/dxrfd/blob/master/dxrfd.lsb-init
[2] http://xrf518.n18.de/