DMRGateway Startup Issue

Help with DMR issues
Post Reply
VE3RD
Posts: 113
Joined: Thu Oct 11, 2018 7:21 pm

DMRGateway Startup Issue

Post by VE3RD »

I am trying to wrap my head around the logic used to start the DMRGateway
I had to add the echo lines to give me feedback as to why it would not start
The following is just me ranting.
I have fixed the following issues so that my script runs just fine

# if dstarrepeater is configured or running, dont start this daemon!
! test -r /etc/dstar-radio.dstarrepeater || exit 1
//// This rule is ignored as I don't use d-star

########################################################
if [[ $(egrep -h -i "1234567|M1ABC" ${CONFIG} | wc -l) -gt 0 ]]; then
echo "Invalid ID" //Added for test results
exit 1;
fi
////
CONFIG=/etc/dmrgateway
why are we searching for M1ABC in dmrgateway
My DMRGateway failed to start because I had ID=1234567 in Network 3 that was disabled
This is a generic search that will fail the script if either 1234567 is found anywhere in the file
why is the DMR Network not allowed to start because of a disabled network config. ??????
The following block of code tests for the id 1234567 only in enabled networks of /etc/dmrgateway
for i in {1..5};do
m1=$(sed -nr "/^\[DMR Network $i\]/ { :l /^Enabled[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" /etc/dmrgateway )
m2=$(sed -nr "/^\[DMR Network $i\]/ { :l /^Id[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" /etc/dmrgateway )
if [ "$m1" == "1" ] && [ "$m2" == "1234567" ]; then
echo "Network $i Failed Test"
fi
done

############################################################################

# Make sure DMR Networking is on
if [ `sed -n '/\[DMR Network\]/{n;p;}' /etc/mmdvmhost | cut -c 8` == 0 ]; then
echo "DMR Network not Enabled in /etc/mmdvmhost" //Added for test results
exit 1;
fi
/////////// This one makes sense except if enable is not the first line after the header it fails
why not use a line independent test like the following
if [ 'sed -nr "/^\[DMR Network\]/ { :l /^Enable[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" /etc/mmdvmhost '=="0" ]; then

######################################################################################

# Make sure I am supposed to be used
if [ `sed -n '/\[DMR Network\]/{n;p;n;p;}' /etc/mmdvmhost | sed '1d' | awk -F = '{print $2}'` != 127.0.0.1 ]; then
echo " Invalid Address in /etc/mmdvmhost, DMR Network" // Added for test results
exit 1;
fi
///////// Again this test for address 127.0.0.1 makes sense. except if address is not the second line after the header it :lol: fails
Why not use line independent code like the following
if [ 'sed -nr "/^\[DMR Network\]/ { :l /^Address[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" /etc/mmdvmhost '=="127.0.0.1" ]; then

##################################################################################################

# Reconfigure to use old style service if the config is not ready
#if [[ $(grep -c "\[DMR Network 3\]" /etc/dmrgateway) -eq "0" ]]; then

# DAEMON=DMRGateway_old
#fi
//////// I don't use Network 3 . It is always disabled as this is reconfigured by the dashboard configuration for HBLink, DMR2YSF, DMR2NXDN and it tries to use and old DMRGateway_old that does not exist if enable = 0
If Network 3 is not configured for one of these, pi-star configuration turns off Network 3 - ????????
Therefore I had to comment out the whole rule

######################################################################################################

in the original file, there was No feedback as to why the script failed to start the DMRGateway

I have not looked at the other service startups, but I suspect similar coding.

Phil VE3RD
User avatar
MW0MWZ
Site Admin
Posts: 1505
Joined: Wed Apr 04, 2018 9:15 pm
Location: Wales, UK
Contact:

Re: DMRGateway Startup Issue

Post by MW0MWZ »

DMR Gateway Network 3 default config looks like this:

[DMR Network 3]
Enabled=0
Name=HBLink
Address=1.2.3.4
Port=5555
TGRewrite=2,11,2,11,1
Password=PASSWORD
Location=0
Debug=0
TGRewrite0=2,11,2,11,1

this network is used by DMR2NXDN or DMR2YSF, I always suggest that if you want to experiment you use networks 4 and 5, the config page will not change those.

I do agree that I could clean up the ID check code, it looks for ID 1234567 and Callsign M1ABC because those are the defaults and should never appear in live configs, if you are managing your config outside of the config page, well then yes you can build a config I didn't expect.
Andy

73 de MW0MWZ
http://pistar.uk
VE3RD
Posts: 113
Joined: Thu Oct 11, 2018 7:21 pm

Re: DMRGateway Startup Issue

Post by VE3RD »

By default Network 3 is disabled as you say so DMRGateway will try to run a non existent config file.

I use
Net1 BM
Net2 Dmr+
Net4 tgif
and just recently
net5 new tgif server under test

ocasionally I use dmr2ysf on NET3

shouldn't the search for M1ABC be done in /etc/mmdvmhost, not /etc/dmrgateway and also
should this not be trapped when starting mmdvmhost, long before you get around to setting up the dmrgateway

Phil VE3RD
User avatar
MW0MWZ
Site Admin
Posts: 1505
Joined: Wed Apr 04, 2018 9:15 pm
Location: Wales, UK
Contact:

Re: DMRGateway Startup Issue

Post by MW0MWZ »

VE3RD wrote: Sat May 09, 2020 10:46 pm By default Network 3 is disabled as you say so DMRGateway will try to run a non existent config file.

I use
Net1 BM
Net2 Dmr+
Net4 tgif
and just recently
net5 new tgif server under test

ocasionally I use dmr2ysf on NET3

shouldn't the search for M1ABC be done in /etc/mmdvmhost, not /etc/dmrgateway and also
should this not be trapped when starting mmdvmhost, long before you get around to setting up the dmrgateway

Phil VE3RD
If you use the config page to configure the services, both ID 1234567 and callsign M1ABC will be gone from the config; the configs are smoke-tested for those ID's to make sure somthing weird didnt happen after there were some Pi-Star units connecting to networks with those IDs.
Andy

73 de MW0MWZ
http://pistar.uk
Post Reply