Extracting Connection Information For Display Elsewhere
Posted: Sun Aug 08, 2021 4:15 am
Hi,
So I had this crazy idea of slapping my current connection information in to a format I could embed it in some of my other pages/profiles. Since I'd done some work a couple years ago scraping information from Pi-Star dashboard for some APRS-IS stuff; I decided to just stick with that general idea. Unlike my previous stuff that ran a bash script on pi-star and required some additional stuff; this runs on the webserver and now requires absolutely nothing special except access to the pi-star dashboard.
This is making the assumption that you self-host a webserver. You can probably do this using remote access to the dashboard depending on your level of paranoia. So far all I have working is the bash script portion:
For DMR; I do the hacky thing of pulling a copy of bm_links.php and strip the HTML tags out by converting them to line breaks. This makes for a stupid number of lines....but efficiency isn't a concern on the webserver. This allows me to grab the groups by filtering by lines that start with TG rather than using a modified copy of bm_links on pistar. TG is converted to #, timeslot information is stripped (since I run duplex), and line breaks are converted to spaces to put the talk groups back on a single line. If no groups are returned, a message is used instead.
Same thing for DStar....except we just egrep for a reflector prefix, strip the HTML, and cut the protocol (i.e "DPlus/OUT"). This is hacky. If you happen to connect to a repeater directly and not a reflector; it won't register. That's something I'm going to work on. But since 99.9% of my activity is on a reflector....this will work. Again...if I'm not linked to a reflector a message is used instead.
I was attempting to get this to display using PHP, but I'm probably tired and not understanding something because while I can get PHP at command-line to work; the browser gets nothing. [s]I'll figure that out tomorrow.[/s]
Update: I apparently forgot to update nginx config for this server directive when I upgraded PHP. https://qth.nq4t.com/hotspots.php now actually displays some text.
73 de Jay/NQ4T
So I had this crazy idea of slapping my current connection information in to a format I could embed it in some of my other pages/profiles. Since I'd done some work a couple years ago scraping information from Pi-Star dashboard for some APRS-IS stuff; I decided to just stick with that general idea. Unlike my previous stuff that ran a bash script on pi-star and required some additional stuff; this runs on the webserver and now requires absolutely nothing special except access to the pi-star dashboard.
This is making the assumption that you self-host a webserver. You can probably do this using remote access to the dashboard depending on your level of paranoia. So far all I have working is the bash script portion:
Code: Select all
#!/bin/bash
#.006 alpha
dmr=$(curl -s http://192.168.1.10/mmdvmhost/bm_links.php| sed 's/<[^>]\+>/\n/g' | grep '^TG' | sed 's/TG/#/g'| sed 's/(.)//g' | sed ':a;N;$!ba;s/\n/ /g')
[ -z "$dmr" ] && dmr="No Talkgroups Found"
dstar=$(curl -s http://192.168.1.11/mmdvmhost/repeaterinfo.php | egrep "REF|XRF|DCS|XLX" | sed 's/<[^>]\+>//g' | sed 's/L/l/'| cut -b 1-8)
[ -z "$dstar" ] && dstar="Not Linked"
printf "%s\n" "BM TG: $dmr"
printf "%s\n" "DStar: $dstar"
Same thing for DStar....except we just egrep for a reflector prefix, strip the HTML, and cut the protocol (i.e "DPlus/OUT"). This is hacky. If you happen to connect to a repeater directly and not a reflector; it won't register. That's something I'm going to work on. But since 99.9% of my activity is on a reflector....this will work. Again...if I'm not linked to a reflector a message is used instead.
Code: Select all
dewdude@ovh:/media/html/qth-nq4t$ ./hotspots.sh
BM TG: #3151 #98003
DStar: DCS216 E
dewdude@ovh:/media/html/qth-nq4t$ ./hotspots.sh
BM TG: #3151 #98003
DStar: Not Linked
dewdude@ovh:/media/html/qth-nq4t$ ./hotspots.sh
BM TG: No Talkgroups Found
DStar: DCS216 E
dewdude@ovh:/media/html/qth-nq4t$ ./hotspots.sh
BM TG: No Talkgroups Found
DStar: Not Linked
Update: I apparently forgot to update nginx config for this server directive when I upgraded PHP. https://qth.nq4t.com/hotspots.php now actually displays some text.
73 de Jay/NQ4T