Turn MMDVMHost Logs into XML for Simoco Radios

From PiStar Wiki
Revision as of 12:39, 7 January 2018 by MW0MWZ (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

1. Login to your Pi-Star

2. Make the disk RW

 [email protected](ro):~$ rpi-rw

3. crate the script

 [email protected](rw):~$ nano dmr_calls.sh

4. Paste in the following code;

 #!/bin/bash
 
 #
 # Get the callsigns from MMDVMHost logs, use those to build out XML for Simoco radios.
 # Concept by David McCunnie, PoC script by Andy Taylor (MW0MWZ)
 #
 # Notes:
 # Pulling all of the callsigns from all available logs with
 # $ grep "received network voice header from" /var/log/pi-star/MMDVM-*.log | awk '{ print $12 }'
 # works well, however we need to sort the output and then pass it to uniq to get unique calls,
 # this does present a problem in as much as I cannot then tell what are the most recent calls.
 # In reality the number of unique calls was actually pretty low, so this may not matter.
 
 # Get the list of unique callsigns
 for callsign in `grep "received network voice header from" /var/log/pi-star/MMDVM-*.log | awk '{ print $12 }' | sort | uniq | tail -1000`; do
 	# Many people have more than one DMR ID, we only get the largest number
 	id=`grep "${callsign}" /usr/local/etc/DMRIds.dat | tail -1 | awk -F '\t' '{ print $1 }'`
 	name=`grep "${callsign}" /usr/local/etc/DMRIds.dat | tail -1 | awk -F '\t' '{ print $3 }'`
 
 	# Now that we have all of the information, build the output
 	echo "<Contact Name=\"${callsign} ${name}\" Number=\"${id}\" Id=\"0\" ContactType=\"UID\" Attribute=\"0\"/>"
 done

now save it with Ctrl-X (follow the prompts on screen)

5. Make it executable

 [email protected](rw):~$ chmod +x dmr_calls.sh

6. Run the script, collect the output

 [email protected](rw):~$ ./dmr_calls.sh > simoco.txt

7. Transfer the file somewhere useful, I'd probably drop it into the webserver and use the browser on your PC to go get it...

 [email protected](rw):~$ sudo cp /home/pi-star/simoco.txt /var/www/dashboard/simoco.txt

8. Fetch it from http://pi-star.local/simoco.txt

9. Congratulate yourself on a job well done :)