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

General support for the Pi-Star System
Post Reply
DF2AP
Posts: 2
Joined: Fri Jun 21, 2019 5:00 am

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

Post 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
DG0OFZ
Posts: 26
Joined: Thu Jun 07, 2018 6:53 pm

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

Post 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.
73s de Thomas, DG0OFZ
DG0OFZ
Posts: 26
Joined: Thu Jun 07, 2018 6:53 pm

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

Post 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
73s de Thomas, DG0OFZ
User avatar
MW0MWZ
Site Admin
Posts: 1505
Joined: Wed Apr 04, 2018 9:15 pm
Location: Wales, UK
Contact:

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

Post by MW0MWZ »

That was originally to take care of local default room numbers only, I'll look at taking in the IP also.
Andy

73 de MW0MWZ
http://pistar.uk
User avatar
MW0MWZ
Site Admin
Posts: 1505
Joined: Wed Apr 04, 2018 9:15 pm
Location: Wales, UK
Contact:

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

Post by MW0MWZ »

Change pushed - update and enjoy.
Andy

73 de MW0MWZ
http://pistar.uk
BX3ACB
Posts: 9
Joined: Tue Jan 29, 2019 2:44 am

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

Post 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 ?
DF2AP
Posts: 2
Joined: Fri Jun 21, 2019 5:00 am

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

Post 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
PU1OWL
Posts: 1
Joined: Mon Apr 06, 2020 10:48 am

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

Post 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.
Post Reply