From 81c33fe416c8429282a72d0ff74dbc514549f416 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Fri, 25 Feb 2022 16:11:56 -0800 Subject: [PATCH] fix pi-star generation script --- web/app.py | 5 +++-- web/gen_script_template.py | 40 ++++------------------------------ web/templates/pi-star_gen.html | 16 +++++--------- 3 files changed, 12 insertions(+), 49 deletions(-) diff --git a/web/app.py b/web/app.py index 7a52867..681f65a 100644 --- a/web/app.py +++ b/web/app.py @@ -1106,9 +1106,11 @@ def hbnet_web_service(): content = content + '''

ID: ''' + str(i[0]) + '''

-
rpi-rw; wget -O /root/auto_pistar.py "''' + str(url) + '/get_script?dmr_id=' + str(i[0]) + '&number=' + str(link_num) + '''"; chmod +x /root/auto_pistar.py; python3 /root/auto_pistar.py; pistar-update
+
cd /root; rpi-rw; curl "''' + str(url) + '/get_script?dmr_id=' + str(i[0]) + '&number=' + str(link_num) + '''" >> DMR_Hosts.txt; pistar-update
''' +#
rpi-rw; wget -O /root/auto_pistar.py "''' + str(url) + '/get_script?dmr_id=' + str(i[0]) + '&number=' + str(link_num) + '''"; chmod +x /root/auto_pistar.py; python3 /root/auto_pistar.py; pistar-update
+ #else: # content = content + '''\n

Error

''' @@ -7185,7 +7187,6 @@ Name: ''' + p.name + '''  -  Port: ''' + str( @app.route('/api//', 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: diff --git a/web/gen_script_template.py b/web/gen_script_template.py index ef96ad5..317e1a4 100644 --- a/web/gen_script_template.py +++ b/web/gen_script_template.py @@ -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 - diff --git a/web/templates/pi-star_gen.html b/web/templates/pi-star_gen.html index 0e83c23..064c8dc 100644 --- a/web/templates/pi-star_gen.html +++ b/web/templates/pi-star_gen.html @@ -6,21 +6,15 @@

Pi-Star Instructions

 

-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. +

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.

 

- -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. +

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.

 


 

- -

1: Log into your Pi-Star device via SSH.
-2: Become root user. DMR_Hosts.txt is stored in /root, thus you need to be root to modify it. -

sudo su

-3: 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.
- +

1: Log into your Pi-Star device via SSH.
2: Become root user.

+
sudo su
+

3: 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. You only need to execute ONE of the commands below.

 

{{markup_content}}