Page 1 of 1

Different Reflector Setting in /root/XLXHosts.txt not working

Posted: Thu Apr 02, 2020 9:22 pm
by DF2AP
Hello,

I have a different Setting für one XLX-Reflector followed this Instruction:

https://amateurradionotes.com/pi-star-notes.htm#addref

In the /root/XLXHostst.txt there is only one Line with the following Setting:

985;44.XXX.XXX.XX;4004

(44.XXX.XXX.XX = IP via Hamnet)

After pistar-update this line is not in the /usr/local/etc/XLXHosts.txt and I can not get a connection to the Hamnet XLX-Reflector.

What´s wrong with my Setup.

mni tnx es 73 de

Juergen
DF2AP

Re: Different Reflector Setting in /root/XLXHosts.txt not working

Posted: Fri Apr 03, 2020 4:56 pm
by DG0OFZ
Hi all,

I've found some lines in /usr/local/sbin/HostFilesUpdate.sh which are overwriting /usr/local/etc/XLXHosts.txt with the content of /root/XLXHosts.txt:

Code: Select all

# If there is an XLX over-ride
if [ -f "/root/XLXHosts.txt" ]; then
        while IFS= read -r line; do
                if [[ $line != \#* ]] && [[ $line = *";"* ]]
                then
                        xlxid=`echo $line | awk -F  ";" '{print $1}'`
                        xlxroom=`echo $line | awk -F  ";" '{print $3}'`
                        xlxip=`grep "^${xlxid}" /usr/local/etc/XLXHosts.txt | awk -F  ";" '{print $2}'`
                        xlxNewLine="${xlxid};${xlxip};${xlxroom}"
                        /bin/sed -i "/^$xlxid\;/c\\$xlxNewLine" /usr/local/etc/XLXHosts.txt
                fi
        done < /root/XLXHosts.txt
fi
If I understand this code correctly, it reads /root/XLXHosts.txt line by line, searches a line in /usr/local/etc/XLXHosts.txt with the same XLXID (first value in each line) and REPLACES this line with a new line where ONLY the XLXROOM number from /root/XLXHosts.txt is used.

Example:
File /usr/local/etc/XLXHosts.txt contains a line

Code: Select all

985;1.2.3.4;4004
File /root/XLXHosts.txt contains a line

Code: Select all

985;1.1.1.1;4005
the resulting line in /usr/local/etc/XLXHosts.txt will be

Code: Select all

985;1.2.3.4;4005
Don't know, what's the use case for this.

Re: Different Reflector Setting in /root/XLXHosts.txt not working

Posted: Fri Apr 03, 2020 9:12 pm
by DG0OFZ
Have checked my Example above by putting those lines into a small script on my linux box:

It works exactly as I understand it: It changes only the "xlxroom"-Number in /usr/local/etc/XLXHosts.txt

Re: Different Reflector Setting in /root/XLXHosts.txt not working

Posted: Tue Apr 07, 2020 9:18 am
by MW0MWZ
That was originally to take care of local default room numbers only, I'll look at taking in the IP also.

Re: Different Reflector Setting in /root/XLXHosts.txt not working

Posted: Tue Apr 07, 2020 9:22 am
by MW0MWZ
Change pushed - update and enjoy.

Re: Different Reflector Setting in /root/XLXHosts.txt not working

Posted: Mon Apr 13, 2020 5:46 am
by BX3ACB
Dear sir

It means I can use /root/XLXHosts.txt to overwrite or add new XLX dmr server in the list right ?

Or I need to use /root/DMR_Hosts.txt ?

Re: Different Reflector Setting in /root/XLXHosts.txt not working

Posted: Mon Apr 13, 2020 5:30 pm
by DF2AP
MW0MWZ wrote: Tue Apr 07, 2020 9:22 am Change pushed - update and enjoy.
Hi Andy,

now it´s also working with changing the IP-Adress. Great work :) .

Thank you very much

73 de Juergen
DF2AP

Re: Different Reflector Setting in /root/XLXHosts.txt not working

Posted: Thu Apr 23, 2020 3:35 pm
by PU1OWL
Sorry to bother you Andy,

But what if I want to add a custom XLX line?

pistar-update will always remove any custom line I add. May I suggest replacing line 168 in HostFilesUpdate.sh with a test, as below?

Code: Select all

# If there is an XLX over-ride
if [ -f "/root/XLXHosts.txt" ]; then
        while IFS= read -r line; do
                if [[ $line != \#* ]] && [[ $line = *";"* ]]
                then
                        xlxid=`echo $line | awk -F  ";" '{print $1}'`
						xlxip=`echo $line | awk -F  ";" '{print $2}'`
                        #xlxip=`grep "^${xlxid}" /usr/local/etc/XLXHosts.txt | awk -F  ";" '{print $2}'`
						xlxroom=`echo $line | awk -F  ";" '{print $3}'`
                        xlxNewLine="${xlxid};${xlxip};${xlxroom}"
						
			if  grep -q "^${xlxid}" /usr/local/etc/XLXHosts.txt;
				then
					/bin/sed -i "/^$xlxid\;/c\\$xlxNewLine" /usr/local/etc/XLXHosts.txt
				else
					echo $xlxNewLine >> /usr/local/etc/XLXHosts.txt
			fi
                fi
        done < /root/XLXHosts.txt
fi
Bear in mind I am not a sed or shell guru, so there must be a better way to do it...

Regards

Rafael

That way, if such line is not found, it is appended to the file.