parent
e749704b77
commit
d28bdf5780
@ -1,33 +0,0 @@
|
||||
##### DASH #####
|
||||
|
||||
This is the minimum viable dashboard to be useful. It provides the
|
||||
following information, refreshed every 30s:
|
||||
|
||||
* Node Callsign
|
||||
* Node TX Frequency
|
||||
* Node IP Address
|
||||
* Currently Linked Reflector
|
||||
|
||||
It also has a button to disconnect the currently connected reflector, and a text
|
||||
field and button to connect to another reflector. Only the first 7 characters
|
||||
entered here will be used, the rest will be discarded. If the reflector entered
|
||||
is not valid (or not included in the gwys.txt file) the command will still run
|
||||
but have no effect.
|
||||
|
||||
To access the dashboard, simply point a browser at the Hotspot's IP address or
|
||||
at http://<hostname>.local/ (on the same subnet).
|
||||
|
||||
|
||||
To install, run the following command after the main installation:
|
||||
|
||||
sudo make installdash
|
||||
|
||||
Note that this will install the PIP package for Python3 if not installed, and
|
||||
it will also install the libconf Python module. These are not uninstalled by the
|
||||
uninstall script, but as these are idempotent commands, there is no issue running
|
||||
the install if they are already present.
|
||||
|
||||
|
||||
To uninstall, run the following:
|
||||
|
||||
sudo make uninstalldash
|
||||
@ -0,0 +1,34 @@
|
||||
##### DASHBOARD.README #####
|
||||
|
||||
A web-based dashboard can be enabled. You can supply your own index.php file,
|
||||
or a functional dashboard can be provide. If no index.php file is in the
|
||||
build directroy when try to install the dashboard, the installation will fail.
|
||||
To get started, copy the "example.php" file to "index.php".
|
||||
|
||||
The example.php file is a good place to start, if you want to create your own
|
||||
by adding features to your dashboard. This dashboard include a <form> with
|
||||
a button to send any URCALL to your gateway.
|
||||
|
||||
To install, run the following command after you have created an index.php file:
|
||||
|
||||
sudo make installdash
|
||||
|
||||
Note that this will install a php web server and all necessary packaged needed
|
||||
for the server. To uninstall, run the following:
|
||||
|
||||
sudo make uninstalldash
|
||||
|
||||
These installed packaged are not uninstalled by the uninstall script. It will
|
||||
only shut down the php web server.
|
||||
|
||||
Likewise, the index.php file will not be erased in the build directory when you
|
||||
uninstall the dashboard, so if you've done a "git pull" and have noticed that
|
||||
there was a new example.php file downloaded, you may want to copy the newer
|
||||
example.php file to index.php.
|
||||
|
||||
One the dashboard server is running, simply point a browser at the Hotspot's IP
|
||||
address or at http://<hostname>.local/ (on the same subnet).
|
||||
|
||||
Please note that this is a very simple server and is not recommended for the
|
||||
world wide web. If you want a robust dashboard accessible from the web, you
|
||||
will want to use a robust server, like apache, and a different index.php file.
|
||||
@ -1,121 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
import socket
|
||||
import datetime
|
||||
import csv
|
||||
import configparser
|
||||
import json
|
||||
import requests
|
||||
import subprocess
|
||||
from time import sleep
|
||||
|
||||
# HTML to send to browser
|
||||
html = """<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>QnetGateway D-Star Hotspot</title>
|
||||
<meta http-equiv="refresh" content="30, url=http://{0}" >
|
||||
</head>
|
||||
<h2>QnetGateway D-Star Hotspot</h2>
|
||||
|
||||
<p>This status page shows the Callsign, Frequency, IP address and Connected Reflector for the QnetGateway D-Star Hotspot.</p>
|
||||
<p><strong>Callsign:</strong> {1}<br>
|
||||
<strong>Modem:</strong> {2}<br>
|
||||
<strong>Frequency:</strong> {3}MHz<br>
|
||||
<strong>IP Address:</strong> {4}<br>
|
||||
<strong>External IP Address:</strong> {5}<br>
|
||||
<strong>Reflector:</strong> {6}</p>
|
||||
<form>
|
||||
<strong>Note:</strong> Please enter a valid 7 character reflector code.</br>
|
||||
<strong>Link Reflector: </strong> <input type="text" name="LINK"> <input type="submit" value="Link Reflector"></br>
|
||||
</form>
|
||||
<form>
|
||||
<strong>Unlink Reflector: </strong> <button name="UNLINK" value="UL" type="submit">Unlink Reflector</button>
|
||||
</form>
|
||||
</html>
|
||||
"""
|
||||
data = []
|
||||
def get_ip():
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
try:
|
||||
# doesn't even have to be reachable
|
||||
s.connect(('10.255.255.255', 1))
|
||||
IP = s.getsockname()[0]
|
||||
except:
|
||||
IP = '127.0.0.1'
|
||||
finally:
|
||||
s.close()
|
||||
return IP
|
||||
|
||||
def get_data():
|
||||
global data
|
||||
data = []
|
||||
reflector = "Unlinked"
|
||||
with open('/usr/local/etc/rptr_status') as csvfile:
|
||||
readCSV = csv.reader(csvfile, delimiter=',')
|
||||
for row in readCSV:
|
||||
reflector = row[1] + row[2]
|
||||
data.append(cs)
|
||||
data.append(modem)
|
||||
data.append(freq)
|
||||
data.append(intip)
|
||||
data.append(extip)
|
||||
data.append(reflector)
|
||||
return data
|
||||
|
||||
def get_MMDVM():
|
||||
MMDVM_config = configparser.ConfigParser()
|
||||
MMDVM_config.read('/usr/local/etc/MMDVM.qn')
|
||||
rawfreq = MMDVM_config['Info']['txfrequency']
|
||||
freq = float(rawfreq)/1000000
|
||||
return freq
|
||||
|
||||
intip = get_ip()
|
||||
extip = requests.get('https://ipapi.co/json/').json()['ip']
|
||||
|
||||
cfg = dict()
|
||||
with open('/usr/local/etc/qn.cfg', 'r') as f:
|
||||
for line in f:
|
||||
if line.strip()[0] == "#":
|
||||
continue
|
||||
kv = line.strip().split("=")
|
||||
cfg[kv[0]] = kv[1].strip("'")
|
||||
|
||||
cs = cfg['ircddb_login']
|
||||
for module in ( 'a', 'b', 'c' ):
|
||||
key = 'module_' + module
|
||||
if key in cfg:
|
||||
modem = cfg[key]
|
||||
if modem == 'mmdvmhost':
|
||||
freq = get_MMDVM()
|
||||
elif key + "_tx_frequency" in cfg:
|
||||
freq = cfg[key + "_tx_frequency"]
|
||||
elif key + "_frequency" in cfg:
|
||||
freq = cfg[key + "_frequency"]
|
||||
else:
|
||||
freq = 0.0
|
||||
break
|
||||
|
||||
#Setup Socket WebServer
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.bind(('', 80))
|
||||
s.listen(5)
|
||||
while True:
|
||||
conn, addr = s.accept()
|
||||
request = conn.recv(1024)
|
||||
request = str(request)
|
||||
UNLINK = request.find('/?UNLINK=UL')
|
||||
if UNLINK == 6:
|
||||
unlink = "/usr/local/bin/qnremote " + module + " " + cs + " U"
|
||||
subprocess.Popen(unlink.split())
|
||||
sleep(8)
|
||||
LINK = request.find('/?LINK=')
|
||||
if LINK == 6:
|
||||
refl = request[13:20].upper()
|
||||
link = "/usr/local/bin/qnremote " + module + " " + cs + " " + refl + "L"
|
||||
subprocess.Popen(link.split())
|
||||
sleep(8)
|
||||
|
||||
data = get_data()
|
||||
response = html.format(data[3], data[0], data[1], data[2], data[3], data[4], data[5])
|
||||
conn.send(bytes(response, "UTF-8"))
|
||||
conn.close()
|
||||
@ -1,6 +0,0 @@
|
||||
# Cronjob to kick off dash
|
||||
|
||||
SHELL=/bin/sh
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
@reboot root /bin/sleep 30 && /usr/bin/python3 /usr/local/bin/qng-info.py
|
||||
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=QnetGateway Dashboard
|
||||
Requires=network.target
|
||||
After=systemd-user-session.service network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/usr/local/etc/www
|
||||
ExecStart=/usr/bin/php -S 0.0.0.0:80
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Loading…
Reference in new issue