mirror of https://github.com/kf7eel/hbnet.git
fix pi-star generation script
This commit is contained in:
parent
2b3301db33
commit
81c33fe416
|
|
@ -1106,9 +1106,11 @@ def hbnet_web_service():
|
|||
content = content + '''
|
||||
<div class="card">
|
||||
<div class="card-header" style="text-align: center;"><h4>ID: ''' + str(i[0]) + '''</h4></div>
|
||||
<div class="card-body"><pre>rpi-rw; wget -O /root/auto_pistar.py "<a href="''' + str(url) + '/get_script?dmr_id=' + str(i[0]) + '&number=' + str(link_num) + '''">''' + str(url) + '/get_script?dmr_id=' + str(i[0]) + '&number=' + str(link_num) + '''</a>"; chmod +x /root/auto_pistar.py; python3 /root/auto_pistar.py; pistar-update</pre></div>
|
||||
<div class="card-body"><pre>cd /root; rpi-rw; curl "<a href="''' + str(url) + '/get_script?dmr_id=' + str(i[0]) + '&number=' + str(link_num) + '''">''' + str(url) + '/get_script?dmr_id=' + str(i[0]) + '&number=' + str(link_num) + '''</a>" >> DMR_Hosts.txt; pistar-update</pre></div>
|
||||
</div>
|
||||
'''
|
||||
# <div class="card-body"><pre>rpi-rw; wget -O /root/auto_pistar.py "<a href="''' + str(url) + '/get_script?dmr_id=' + str(i[0]) + '&number=' + str(link_num) + '''">''' + str(url) + '/get_script?dmr_id=' + str(i[0]) + '&number=' + str(link_num) + '''</a>"; chmod +x /root/auto_pistar.py; python3 /root/auto_pistar.py; pistar-update</pre></div>
|
||||
|
||||
#else:
|
||||
# content = content + '''\n<p style="text-align: center;">Error</p>'''
|
||||
|
||||
|
|
@ -7185,7 +7187,6 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
|||
@app.route('/api/<user>/<key>', methods=['POST'])
|
||||
def api_endpoint(user, key):
|
||||
api_data = request.json
|
||||
print(api_data)
|
||||
try:
|
||||
u = User.query.filter(User.username == user).first()
|
||||
if key in u.api_keys:
|
||||
|
|
|
|||
|
|
@ -2,42 +2,10 @@
|
|||
|
||||
def gen_script(dmr_id, svr_lst):
|
||||
auth_contents = ''
|
||||
header = '''
|
||||
## DMR_hosts.txt, generated by HBNet.
|
||||
|
||||
########################################################################################################
|
||||
### Name DMR-ID IP/Hostname Password Port #
|
||||
########################################################################################################
|
||||
\n'''
|
||||
for i in svr_lst:
|
||||
## print(i[1])
|
||||
auth_contents = auth_contents + str(i[0]) + '''\t\t\t\t''' + str(dmr_id) + '''\t''' + i[1] + '''\t\t\t\t''' + i[2] + '''\t\t''' + str(i[3]) + '\n'
|
||||
## print(header)
|
||||
## print(auth_contents)
|
||||
|
||||
|
||||
## return header + auth_contents
|
||||
|
||||
auth_contents = auth_contents + str(i[0]) + '''\t\t\t''' + str(dmr_id) + '''\t''' + i[1] + '''\t\t\t''' + i[2] + '''\t\t''' + str(i[3]) + '\n'
|
||||
output = '''
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
os.chdir('/root')
|
||||
if Path('/root/DMR_Hosts.txt').is_file():
|
||||
print('DMR_Hosts.txt exists, adding entries...')
|
||||
with open('/root/DMR_Hosts.txt', 'a') as dmr_hosts:
|
||||
dmr_hosts.write("""''' + auth_contents + '''""")
|
||||
dmr_hosts.close()
|
||||
|
||||
else:
|
||||
Path('/root/DMR_Hosts.txt').touch()
|
||||
print('DMR_Hosts.txt does not exist, creating...')
|
||||
with open('/root/DMR_Hosts.txt', 'w') as dmr_hosts:
|
||||
dmr_hosts.write("""''' + header + auth_contents + '""")' + '''
|
||||
dmr_hosts.close()
|
||||
print('DMR Host file updates.')'''
|
||||
print(output)
|
||||
# Generated by HBNet \n
|
||||
''' + auth_contents + '''
|
||||
'''
|
||||
return output
|
||||
|
||||
|
|
|
|||
|
|
@ -6,21 +6,15 @@
|
|||
<div class="panel-heading" style="text-align: center;"><h4>Pi-Star Instructions</h4></div>
|
||||
<div class="panel-body">
|
||||
<p> </p>
|
||||
A script to enable the use of this network on a Pi-Star device is available. This script will automatically add information, including your generated passphrase and each Master/Proxy instance
|
||||
on this network, to your device's DMR_Hosts.txt. This will allow you to connect to this network in the Pi-Star configuration page.
|
||||
<p>This page generates a script to enable the use of this network on a Pi-Star device. This script will automatically add information, including your generated passphrase and each Master/Proxy instance available on this network, to your device's DMR_Hosts.txt. This will allow you to connect to this network in the Pi-Star configuration page.</p>
|
||||
<p> </p>
|
||||
|
||||
A script(s) is generated for each of your DMR IDs when you load this page. Each link/command is valid for only one use. If you need execute a command again,
|
||||
simply reload the page to get a fresh link.
|
||||
<p>A script that can be copied and pasted is generated for each of your DMR IDs when you load this page. Each script/command contains a link that is valid for only one use. If you need execute a command again, simply reload the page to get a fresh link.</p>
|
||||
<p> </p>
|
||||
<hr />
|
||||
<p> </p>
|
||||
|
||||
<p><strong>1</strong>: Log into your Pi-Star device via SSH. <br />
|
||||
<strong>2</strong>: Become <strong>root</strong> user. DMR_Hosts.txt is stored in /root, thus you need to be root to modify it.
|
||||
<pre>sudo su</pre><br />
|
||||
<strong>3</strong>: Decide which DMR ID you want Pi-Star to login with. Copy and past one of the commands below to update DMR_Hosts.txt. Each command is specific to a DMR ID.<br />
|
||||
|
||||
<p><strong>1</strong>: Log into your Pi-Star device via SSH. <br /> <strong>2</strong>: Become <strong>root</strong> user.</p>
|
||||
<pre>sudo su</pre>
|
||||
<p><strong>3</strong>: Decide which DMR ID you want Pi-Star to login with. Copy and past one of the commands below to update DMR_Hosts.txt. Each command is specific to a DMR ID. <strong>You only need to execute ONE of the commands below.</strong></p>
|
||||
<p> </p>
|
||||
|
||||
{{markup_content}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue