Switching DMRGateways in WPSD or Pi-Star

The default DMRGateway in WPSD or Pi-Star has all DMR networks active with adjustable timeouts/holds, but VE3RD created a DMRGateway-6 that has only one network active at a time, and the user can use multiple ways to switch networks. I have opted for using the TG codes to select network, e.g. TG 9004 selects network 4 for instance. For this to work I made sure this was in the beginning of my dmrgateway.3rd file for VE3RD’s version of the file. StartNet is what network is active on load.

StartNet=1
GWMode=1
RawNet=0

And this lets you use normal TG numbers on each network verses TG translation with the standard DMRGateway. There are also some other modes with translation and switching you can read about in Phil’s post, but I leave talk group translations for the standard DMRGateway. The nice part of the latest version is you also have the XLX network selected by TG 9007.

There are times I want to use Phil’s DMRGateway and times I like the original DMRGateway. So if you save your main DMRGateway config file and one for Phil’s DMRGateway, along with the versions of DMRGateway executable, you can use a simple bash script to switch between them. The original DMRGateway is good for monitoring multiple networks and talk groups if not too busy as well as having access to XLX reflectors. Phil’s gateway can be advantageous for using actual talk group numbers with no translation along with isolating networks, and using 7 digit personal talk group numbers on each network where the standard DMRGateway with translation limits you to one network. Or if you are monitoring busy talk groups on mulitple networks and switching between them without awkward network switching on inactivity (you can also adjust timeouts but that’s not a perfect solution).

I copy /etc/dmrgateway to /etc/dmrgateway.old and setup /etc/dmrgateway.3rd for Phil’s DMRGateway. These are the DMRGateway config files, which then can be copied to the /etc/dmrgateway file when switching.

Also copy /usr/local/bin/DMRGateway to /usr/local/bin/DMRGateway.old and compile and copy Phil’s DMRGateway file to /usr/local/bin/DMRGateway.3rd, which can be copied to /usr/local/bin/DMRGateway when switching between versions.

Bash script to change to Phil’s version, file gw4 (chmod +x), and if on original Pi-Star uncomment the mount lines for switching between read only and read write (not needed with WPSD):

#!/bin/bash
systemctl stop mmdvmhost dmrgateway
sleep 1
#mount -o remount,rw /
cp /etc/dmrgateway.3rd /etc/dmrgateway
cp /usr/local/bin/DMRGateway.3rd /usr/local/bin/DMRGateway
systemctl restart mmdvmhost dmrgateway
#mount -o remount,ro /
echo Installed VE3RD DMRGateway 6 configuration

Bash script to switch back to default DMRGateway, file gw (chmod +x), if on original Pi-Star uncomment the mount lines for switching between read only and read write (not needed with WPSD):

#!/bin/bash
systemctl stop mmdvmhost dmrgateway
sleep 1
#mount -o remount,rw /
cp /etc/dmrgateway.old /etc/dmrgateway
cp /usr/local/bin/DMRGateway.old /usr/local/bin/DMRGateway
systemctl restart mmdvmhost dmrgateway
#mount -o remount,ro /
echo Restored original DMRGateway configuration

I just have the files in the /home/Pi-Star directory. Then to execute from the home directory, sudo ./gw4 or sudo ./gw

This also makes restoring the DMRGateway config files easy if Pi-Star wrecks them with its massive script (doesn’t seem to be an issue with WPSD). If you use WPSD or Pi-Star to edit the file, be sure to copy it to the .old or .3rd files as appropriate to preserve the change. Or just edit the .old or .3rd files directly and run the script to install. The bash scripts could be improved but just what I came up with on the fly to switch between the gateways quickly and as it’s worked fine I haven’t tweaked them. And having access to the different DMRGateways is pretty handy depending on what kind of operating mode you’re trying to enjoy.

Dealing with WPSD updating DMRGateway, you’ll need to keep up with when Chip updates DMRGateway which might overwrite your custom version and would also need to be copied to DMRGateway.old. What I do is clone Jonathan Naylor’s DMRGateway and compile it periodically and then copy it over to /usr/local/bin/DMRGateway.old. Also, Chip has a repo, https://repo.w0chp.net/, but it seems to be undergoing maintenance at the moment though you should be able to see when DMRGateway was last updated and grab the file from there as well if needed.