VARA, ARDOP and QtSoundModem as System Services

This document is a continuation of RPI4 Trifecta: VARA, Packet & ARDOP – One Audio Interface, BPQ32 Rig Control – VOX and/or CAT PTT, RPI4: VARA & Syslog

Application as a Service

Running VARA/ARDOP/QtSoundModem as independent system services is ideal as it can help towards automation. For instance, if a TNC crashes or you need to shut down quickly it helps to have these prepared and ready to take over the repetitive and annoying tasks.

Let systemd take care of it. My systemd script forks a ‘screen’ process to capture the console output for debug analysis at any time, and it forks via a script so that minor adjustments can be made without having to ‘systemctl daemon-reload’ all the time.

There are references to another system unit file ‘vvnc-modems.service’, this is another systemd service that launches a virtual VNC desktop, to which VARA and the other modems with GUIs are thrown to.

This makes monitoring the modems a breeze because I don’t have to keep them open on the main desktop all the time or if I do I can scale the window down with all of them in so that they are up in the top corner while I do other things.

Below, all of the systemd unit files and start scripts are fully illustrated, if you want to download them ready-to-go, here’s the ZIP archive, includes bonus wsjtx.service that will autostop all modems when manually started.

VARA Systemd Unit File

/lib/systemd/system/vara.service
[Unit]
Description=VARA Start Script by PE1RRR
After=vvnc-modems.service
Wants=vvnc-modems.service
 
[Service] 
Type=forking 
WorkingDirectory=/home/pi/bin 
Restart=always 
RestartSec=15 
StartLimitInterval=60 
StartLimitBurst=3 
User=pi 
Group=pi 
ExecStart=/usr/bin/screen -S VARA-Console -d -m /home/pi/bin/startvara 
ExecStop=/usr/local/bin/wineserver -k 
SyslogIdentifier=VARA-Debug 
 
[Install]
WantedBy=multi-user.target

VARA Start Script

/home/pi/bin/startvara 
#!/bin/bash
cd /home/pi/bin
DISPLAY=:2
export DISPLAY
/usr/local/bin/wine /home/pi/.wine/drive_c/VARA/VARA.exe


Virtual VNC Systemd Unit File

/lib/systemd/system/vvnc-modems.service
[Unit]
Description=Shack Desktop Start Script by PE1RRR
After=network.target
 
[Service]
Type=forking
WorkingDirectory=/home/pi/bin
Restart=always
RestartSec=20
StartLimitInterval=60
StartLimitBurst=3
User=pi
Group=pi
ExecStart=/home/pi/bin/vvnc-modems
SyslogIdentifier=Shack-VNC
 
[Install]
WantedBy=multi-user.target
 

Virtual VNC (re)Start Script

/home/pi/bin/vvnc-modems
#!/bin/bash
vncserver -kill :2
vncserver :2 -geometry 1080x764

QtSoundModem Systemd Unit File

/lib/systemd/system/qtsm.service
[Unit]
Description=QtSoundModem Start Script by PE1RRR
After=vvnc-modems.service
Wants=vvnc-modems.service

[Service]
Type=forking
WorkingDirectory=/home/pi/bin
Restart=always
RestartSec=5
StartLimitInterval=60
StartLimitBurst=3
User=pi
Group=pi
ExecStart=/usr/bin/screen -S QTSM-Console -d -m /home/pi/bin/startqtsm
SyslogIdentifier=QTSM-Debug

[Install]
WantedBy=multi-user.target

QtSoundModem Start Script

/home/pi/bin/startqtsm
#!/bin/bash
cd /home/pi/bin


# Launch invisibly
#/home/pi/bin/SM nogui

# Launch with GUI
# Set the display number here. If HDMI connected monitor, this is usually :0
# For VNC sessions, this is determined in the desktop- check it with
# echo $DISPLAY in a shell within the VNC.
DISPLAY=:2
export DISPLAY
/home/pi/bin/piQtSoundModem 

ARDOP Systemd Unit File (Part 1)

/lib/systemd/system/ardop.service
[Unit]
Description=ARDOP Daemon Start Script by PE1RRR
After=vvnc-modems.service
Wants=vvnc-modems.service

[Service]
Type=forking
WorkingDirectory=/home/pi/bin
Restart=always
RestartSec=5
StartLimitInterval=60
StartLimitBurst=3
User=pi
Group=pi
ExecStart=/usr/bin/screen -S ARDOP -d -m /home/pi/bin/startardop
SyslogIdentifier=ARDOP-Debug

[Install]
WantedBy=multi-user.target

ARDOP Start Script

/home/pi/bin/startardop
#!/bin/bash
cd /home/pi/bin/
/home/pi/bin/piardopc 8515 ARDOP2IN ARDOP2OUT

ARDOP GUI Systemd Unit (ARDOP Part 2)

/lib/systemd/system/ardop-gui.service
[Unit]
Description=ARDOP GUI Start Script by PE1RRR
After=vvnc-modems.service
Wants=vvnc-modems.service

[Service]
Type=forking
WorkingDirectory=/home/pi/bin
Restart=always
RestartSec=5
StartLimitInterval=60
StartLimitBurst=3
User=pi
Group=pi
ExecStart=/usr/bin/screen -S ARDOP-GUI -d -m /home/pi/bin/startARDOP_GUI
SyslogIdentifier=ARDOPGUI-Debug

[Install]
WantedBy=multi-user.target

ARDOP GUI Start Script

/home/pi/bin/startARDOP_GUI
#!/bin/bash
cd /home/pi/bin

# Set the display number here. If HDMI connected monitor, this is usually :0
# For VNC sessions, this is determined in the desktop- check it with
# echo $DISPLAY in a shell within the VNC.
DISPLAY=:2
export DISPLAY
/home/pi/bin/piARDOP_GUI 

Initiating Systemd scripts

sudo systemctl enable qtsm
sudo systemctl enable vvnc-modems
sudo systemctl enable ardop
sudo systemctl enable ardop-gui
sudo systemctl enable vara


sudo service vara start (any of the modems will start the vvnc-modems virtual desktop service automatically)

I do this for all of the modems, so each one is a service and can be stopped independently, or by calling a script that just goes through the motions:

/home/pi/bin/modems-off:

sudo service vara stop
sudo service qtsm stop
sudo service ardop stop
sudo service ardop-gui stop


/home/pi/bin/modems-on:

sudo service vara start
sudo service qtsm start
sudo service ardop start
sudo service ardop-gui start