Initial commit.
						commit
						e9381cd020
					
				| @ -0,0 +1,144 @@ | |||||||
|  | # Pi-Star Information Scraper & Display | ||||||
|  | 
 | ||||||
|  | This lazily named pair of scripts will allow you to display DStar or DMR | ||||||
|  | information using PHP. | ||||||
|  | 
 | ||||||
|  | ## About | ||||||
|  | 
 | ||||||
|  | I got the bright idea that I wanted to display my hotspot status information on | ||||||
|  | my QRZ page. Like most things ham; it doesn't look nice. It's a no frills php | ||||||
|  | page that just drops text in a table with basic formatting. I go about as far | ||||||
|  | as using viewport information to make it look better in various framesizes. It | ||||||
|  | was designed to be placed in an iFrame. | ||||||
|  | 
 | ||||||
|  | This script has not seen any updates in months due to working how I wanted it | ||||||
|  | to and not causing issues. In fact I forgot it was working until going to make | ||||||
|  | this repository. | ||||||
|  | 
 | ||||||
|  | ## Example | ||||||
|  | 
 | ||||||
|  | I am going to try to ebed an iFrame in the readme. | ||||||
|  | 
 | ||||||
|  | <iframe frameborder="0" height="300" scrolling="no" src="https://qth.nq4t.com/hotspots.php" width="320"></iframe> | ||||||
|  | 
 | ||||||
|  | If this doesn't work you can visit: | ||||||
|  | 
 | ||||||
|  | https://qth.nq4t.com/hotspots.php | ||||||
|  | 
 | ||||||
|  | The direct version will be "full-screen". Just remember this was designed for | ||||||
|  | iframes. | ||||||
|  | 
 | ||||||
|  | ## Usage/Setup | ||||||
|  | 
 | ||||||
|  | To use this you must meet the following conditions: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | You must have a web-server running PHP | ||||||
|  | Your web-server must be able to access your hotspot dashboard | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | It may be possible to run this with everything on a different network without | ||||||
|  | having to expose your hotspots. A VPN could provide a way for your remote www | ||||||
|  | server to access dashboards. Running the script remotely and having your web- | ||||||
|  | server get results via SSH is another possiblity. I'll script this when I get a | ||||||
|  | chance.  | ||||||
|  | 
 | ||||||
|  | You will need to load hotspot.sh and edit the hostname information. You will  | ||||||
|  | also need to configure if you're using D-Star or DMR. Other modes may work with | ||||||
|  | the DMR setting, like YSF. DMR scrapes the bm_links.php while Dstar scrapes  | ||||||
|  | repeaterinfo.php's "Linked To" box. | ||||||
|  | 
 | ||||||
|  | Place hotspots.php in a document root and edit it to match where you put your | ||||||
|  | shell script. Simply loading hotspots.php is all you need to do. | ||||||
|  | 
 | ||||||
|  | ## Testing/Troubleshooting | ||||||
|  | 
 | ||||||
|  | You can easily test both parts of this script to check that the output is  | ||||||
|  | sane and for debugging purposes. When you run the bash script by itself, you | ||||||
|  | will get output like this: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | dewdude@ovh:/media/html/qth-nq4t$ ./hotspot13alpha.sh | ||||||
|  | <tr><td style="vertical-align: top; font-family: Verdana; font-weight: bold; text-align: right;"><small>BM TG:</small></td> | ||||||
|  | <td style="vertical-align: top;"><small style="font-style: italic;">#3151 - #8802 - #31514 - #98003 </small><br></td></tr> | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | The bash script literally just generates HTML code; but it's still clear that | ||||||
|  | it's outputting talkgroup numbers. The PHP file, hotspots.php, basically | ||||||
|  | generates an entire webpage. | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | dewdude@ovh:/media/html/qth-nq4t$ php hotspots.php | ||||||
|  | <html> | ||||||
|  | <head> | ||||||
|  | <meta content="text/html; charset=ISO-8859-1" | ||||||
|  | http-equiv="content-type"> | ||||||
|  | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||||
|  | <title>NQ4T Hotspot Info</title> | ||||||
|  | </head> | ||||||
|  | <body> | ||||||
|  | <div style="margin-right: auto; font-family: Verdana; text-align: left;"><big> | ||||||
|  | </big><small><span style="font-weight: bold;">NQ4T Pi-Star Hotspot | ||||||
|  | Network</span><br> | ||||||
|  | <br style="font-weight: bold; font-style: italic;"> | ||||||
|  | <span style="font-weight: bold; font-style: italic;">Current | ||||||
|  | Connections:</span><br> | ||||||
|  | </small><big> | ||||||
|  | </big> | ||||||
|  | <table | ||||||
|  | style="border: 1px solid black; text-align: left; border-collapse: collapse;" | ||||||
|  | cellpadding="2" cellspacing="0"> | ||||||
|  | <tbody> | ||||||
|  | <tr><td style="vertical-align: top; font-family: Verdana; font-weight: bold; text-align: right;"><small>BM TG:</small></td> | ||||||
|  | <td style="vertical-align: top;"><small style="font-style: italic;">#3151 - #8802 - #31514 - #98003 </small><br></td></tr> | ||||||
|  | </tbody> | ||||||
|  | </table> | ||||||
|  | <big> | ||||||
|  | </big><small><br style="font-style: italic; font-weight: bold;"> | ||||||
|  | <span style="font-style: italic; font-weight: bold;">Listed connections | ||||||
|  | do not mean I have a radio on or am at a radio.<br>This is especially true | ||||||
|  | for Brandmeister.</span><br | ||||||
|  | style="font-weight: bold; font-style: italic;"> | ||||||
|  | <span style="font-style: italic; font-weight: bold;"> For informational | ||||||
|  | purposes only. | ||||||
|  | </span><br> | ||||||
|  | <br> | ||||||
|  | 73 de NQ4T | ||||||
|  | <br> | ||||||
|  | 2022-05-09 @ 05:42:43z</small> | ||||||
|  | </div> | ||||||
|  | </body> | ||||||
|  | </html> | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | As you can see between `<tbody>` and `</tbody>` is our script output. | ||||||
|  | 
 | ||||||
|  | If the bash script doesn't get data or can't connect, it will just hang for a | ||||||
|  | while and output nothing. If PHP can't execute the script, it will generate an | ||||||
|  | error in the output.  | ||||||
|  | 
 | ||||||
|  | # History | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | 09-MAY-2022 - Initial Commit | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | # License | ||||||
|  | 
 | ||||||
|  |     Pi-Star Information Scraper & Display | ||||||
|  |     Copyright (C) 2022 Jay Moore - nq4tango@gmail.com | ||||||
|  | 
 | ||||||
|  |     This program is free software: you can redistribute it and/or modify | ||||||
|  |     it under the terms of the GNU General Public License as published by | ||||||
|  |     the Free Software Foundation, either version 3 of the License, or | ||||||
|  |     (at your option) any later version. | ||||||
|  | 
 | ||||||
|  |     This program is distributed in the hope that it will be useful, | ||||||
|  |     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  |     GNU General Public License for more details. | ||||||
|  | 
 | ||||||
|  |     You should have received a copy of the GNU General Public License | ||||||
|  |     along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||||
| @ -0,0 +1,45 @@ | |||||||
|  | <html> | ||||||
|  | <head> | ||||||
|  | <meta content="text/html; charset=ISO-8859-1" | ||||||
|  | http-equiv="content-type"> | ||||||
|  | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||||
|  | <title>NQ4T Hotspot Info</title> | ||||||
|  | </head> | ||||||
|  | <body> | ||||||
|  | <div style="margin-right: auto; font-family: Verdana; text-align: left;"><big> | ||||||
|  | </big><small><span style="font-weight: bold;">NQ4T Pi-Star Hotspot | ||||||
|  | Network</span><br> | ||||||
|  | <br style="font-weight: bold; font-style: italic;"> | ||||||
|  | <span style="font-weight: bold; font-style: italic;">Current | ||||||
|  | Connections:</span><br> | ||||||
|  | </small><big> | ||||||
|  | </big> | ||||||
|  | <table | ||||||
|  | style="border: 1px solid black; text-align: left; border-collapse: collapse;" | ||||||
|  | cellpadding="2" cellspacing="0"> | ||||||
|  | <tbody> | ||||||
|  | <?php | ||||||
|  | $output = shell_exec('/media/html/qth-nq4t/hotspot13alpha.sh'); | ||||||
|  | echo "$output"; | ||||||
|  | ?> | ||||||
|  | </tbody> | ||||||
|  | </table> | ||||||
|  | <big> | ||||||
|  | </big><small><br style="font-style: italic; font-weight: bold;"> | ||||||
|  | <span style="font-style: italic; font-weight: bold;">Listed connections | ||||||
|  | do not mean I have a radio on or am at a radio.<br>This is especially true | ||||||
|  | for Brandmeister.</span><br | ||||||
|  | style="font-weight: bold; font-style: italic;"> | ||||||
|  | <span style="font-style: italic; font-weight: bold;"> For informational | ||||||
|  | purposes only. | ||||||
|  | </span><br> | ||||||
|  | <br> | ||||||
|  | 73 de NQ4T | ||||||
|  | <br> | ||||||
|  | <?php | ||||||
|  | echo date("Y-m-d") . " @ " . date("H:i:s") . "z"; | ||||||
|  | ?> | ||||||
|  | </small> | ||||||
|  | </div> | ||||||
|  | </body> | ||||||
|  | </html> | ||||||
| @ -0,0 +1,34 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | #.013 alpha | ||||||
|  | # de NQ4T (nq4tango@gmail.com) | ||||||
|  | 
 | ||||||
|  | # SET THE HOSTNAME OR IP OF YOUR HOTSPOT! | ||||||
|  | pidmr=192.168.1.10 | ||||||
|  | # I HAVE TWO SO I SET TWO | ||||||
|  | #pidstar=192.168.1.11 | ||||||
|  | 
 | ||||||
|  | # grab copy of rendered bm_links.php from hotspot, convert HTML to newline, filter by "TG", remove timeslot info, convert to one line | ||||||
|  | # check contents to see if we need to display 'no groups' message | ||||||
|  | # if you are not using DMR, then comment these two lines out | ||||||
|  | # to comment out, just add a pound-sign to the start of the line, like these comments. | ||||||
|  | 
 | ||||||
|  | dmr=$(curl -s http://$pidmr/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" | ||||||
|  | 
 | ||||||
|  | # do the same for dstar with repeaterinfo.php but just egrep for reflector prefix, strip HTML, keep the first 8 characters | ||||||
|  | # check to see if we need to display not linked | ||||||
|  | # if you are not using D-Star, comment these next two lines out. if you don't, the script will take longer to run. | ||||||
|  | 
 | ||||||
|  | #dstar=$(curl -s http://$pidstar/mmdvmhost/repeaterinfo.php | egrep "REF|XRF|DCS|XLX" | sed 's/<[^>]\+>//g' | cut -b 1-8) | ||||||
|  | #[ -z "$dstar" ] && dstar="Not Linked" | ||||||
|  | 
 | ||||||
|  | # HTML for table cells on hotspot.php page. These are all one line even if they look like two in your editor. | ||||||
|  | 
 | ||||||
|  | # This is for a 2x2 table using DMR and D-Star | ||||||
|  | 
 | ||||||
|  | #printf "<tr><td style=\"vertical-align: top; font-family: Verdana; font-weight: bold; text-align: right;\" width=\"20%%\"><small>BM TG:</small></td>\n<td style=\"vertical-align: top;\"><small>$dmr</small><br></td></tr>\n<tr><td style=\"vertical-align: top; font-family: Verdana; font-weight: bold; text-align: right;\" width=\"20%%\"><small>D-Star:</small></td>\n<td style=\"vertical-align: top;\"><small>$dstar</small><br></td></tr>\n" | ||||||
|  | # This is for a DMR only display. | ||||||
|  | printf "<tr><td style=\"vertical-align: top; font-family: Verdana; font-weight: bold; text-align: right;\"><small>BM TG:</small></td>\n<td style=\"vertical-align: top;\"><small style=\"font-style: italic;\">$dmr</small><br></td></tr>\n" | ||||||
|  | 
 | ||||||
|  | # This is for a D-STar Only Display | ||||||
|  | # printf "<tr><td style=\"vertical-align: top; font-family: Verdana; font-weight: bold; text-align: right;\"><small>D-Star:</small></td>\n<td style=\"vertical-align: top;\"><small style=\"font-style: italic;\">$dstar</small><br></td></tr>\n" | ||||||
					Loading…
					
					
				
		Reference in New Issue