mirror of
https://github.com/mynodebtc/mynode.git
synced 2024-12-23 21:18:07 +00:00
Improve settings page layout and info
This commit is contained in:
parent
fbc07a96cb
commit
d878e396a3
|
@ -237,7 +237,7 @@ if [ "$CURRENT" != "$RTL_UPGRADE_URL" ]; then
|
|||
sudo -u bitcoin wget $RTL_UPGRADE_URL -O RTL.tar.gz
|
||||
sudo -u bitcoin wget $RTL_UPGRADE_ASC_URL -O RTL.tar.gz.asc
|
||||
|
||||
gpg --verify RTL.tar.gz.asc RTL.tar.gz
|
||||
#gpg --verify RTL.tar.gz.asc RTL.tar.gz
|
||||
#if [ $? == 0 ]; then
|
||||
if [ true ]; then
|
||||
sudo -u bitcoin tar -xvf RTL.tar.gz
|
||||
|
|
|
@ -35,6 +35,31 @@ def get_latest_version():
|
|||
return latest_version
|
||||
|
||||
|
||||
def get_service_status_code(service_name):
|
||||
code = os.system("systemctl status {} --no-pager".format(service_name))
|
||||
return code
|
||||
|
||||
def get_service_status_basic_text(service_name):
|
||||
code = os.system("systemctl status {} --no-pager".format(service_name))
|
||||
if code == 0:
|
||||
return "Running"
|
||||
return "Error"
|
||||
|
||||
def get_service_status_color(service_name):
|
||||
code = os.system("systemctl status {} --no-pager".format(service_name))
|
||||
if code == 0:
|
||||
return "green"
|
||||
return "red"
|
||||
|
||||
|
||||
def get_journalctl_log(service_name):
|
||||
try:
|
||||
log = subprocess.check_output("journalctl -r --unit={} --no-pager | tail -n 200".format(service_name), shell=True).decode("utf8")
|
||||
except:
|
||||
log = "ERROR"
|
||||
return log
|
||||
|
||||
|
||||
def did_upgrade_fail():
|
||||
return os.path.isfile("/mnt/hdd/mynode/settings/upgrade_error")
|
||||
|
||||
|
@ -293,3 +318,27 @@ def upgrade_device():
|
|||
|
||||
# Reboot
|
||||
reboot_device()
|
||||
|
||||
|
||||
|
||||
#=========================================
|
||||
# Service Status Functions
|
||||
#=========================================
|
||||
def get_docker_image_build_status():
|
||||
status_code = get_service_status_code("docker_images")
|
||||
|
||||
if status_code != 0:
|
||||
return "Failed... Retrying Later"
|
||||
|
||||
if is_installing_docker_images():
|
||||
return "Installing..."
|
||||
else:
|
||||
return "Installation Complete"
|
||||
|
||||
return "Unknown"
|
||||
|
||||
def get_docker_image_build_status_color():
|
||||
status_code = get_service_status_code("docker_images")
|
||||
if status_code != 0:
|
||||
return "red"
|
||||
return "green"
|
|
@ -205,8 +205,8 @@ def index():
|
|||
}
|
||||
return render_template('state.html', **templateData)
|
||||
elif status == STATE_STABLE:
|
||||
bitcoind_status_code = os.system("systemctl status bitcoind --no-pager")
|
||||
lnd_status_code = os.system("systemctl status lnd --no-pager")
|
||||
bitcoind_status_code = get_service_status_code("bitcoind")
|
||||
lnd_status_code = get_service_status_code("lnd")
|
||||
tor_status_color = "gray"
|
||||
bitcoind_status_color = "red"
|
||||
lnd_status_color = "red"
|
||||
|
@ -266,11 +266,7 @@ def index():
|
|||
return render_template('state.html', **templateData)
|
||||
|
||||
# Find tor status
|
||||
status = os.system("systemctl status tor@default --no-pager")
|
||||
if status != 0:
|
||||
tor_status_color = "red"
|
||||
else:
|
||||
tor_status_color = "green"
|
||||
tor_status_color = get_service_status_color("tor@default")
|
||||
|
||||
# Find bitcoind status
|
||||
if bitcoind_status_code != 0:
|
||||
|
@ -307,40 +303,32 @@ def index():
|
|||
# Find lndhub status
|
||||
if is_lndhub_enabled():
|
||||
if lnd_ready:
|
||||
status = os.system("systemctl status lndhub --no-pager")
|
||||
if status != 0:
|
||||
lndhub_status_color = "red"
|
||||
else:
|
||||
lndhub_status_color = "green"
|
||||
lndhub_status_color = get_service_status_color("lndhub")
|
||||
else:
|
||||
lndhub_status_color = "green"
|
||||
|
||||
# Find RTL status
|
||||
if lnd_ready:
|
||||
status = os.system("systemctl status rtl --no-pager")
|
||||
if status != 0:
|
||||
status_code = get_service_status_code("rtl")
|
||||
if status_code != 0:
|
||||
rtl_status_color = "red"
|
||||
else:
|
||||
rtl_status_color = "green"
|
||||
|
||||
# Find electrs status
|
||||
if is_electrs_enabled():
|
||||
status = os.system("systemctl status electrs --no-pager")
|
||||
if status != 0:
|
||||
electrs_status_color = "red"
|
||||
else:
|
||||
electrs_status_color = "green"
|
||||
status_code = get_service_status_code("electrs")
|
||||
electrs_status_color = get_service_status_color("electrs")
|
||||
if status_code == 0:
|
||||
electrs_status = get_electrs_status()
|
||||
|
||||
# Find btc-rpc-explorer status
|
||||
btcrpcexplorer_status = "BTC RPC Explorer"
|
||||
if is_btcrpcexplorer_enabled():
|
||||
if is_electrs_active():
|
||||
status = os.system("systemctl status btc_rpc_explorer --no-pager")
|
||||
if status != 0:
|
||||
btcrpcexplorer_status_color = "red"
|
||||
else:
|
||||
btcrpcexplorer_status_color = "green"
|
||||
btcrpcexplorer_status_color = get_service_status_color("btc_rpc_explorer")
|
||||
status_code = get_service_status_code("btc_rpc_explorer")
|
||||
if status_code == 0:
|
||||
btcrpcexplorer_ready = True
|
||||
else:
|
||||
btcrpcexplorer_status_color = "green"
|
||||
|
@ -348,11 +336,8 @@ def index():
|
|||
|
||||
# Find mempool space status
|
||||
if is_mempoolspace_enabled():
|
||||
status = os.system("systemctl status mempoolspace --no-pager")
|
||||
if status != 0:
|
||||
mempoolspace_status_color = "red"
|
||||
else:
|
||||
mempoolspace_status_color = "green"
|
||||
status_code = get_service_status_code("mempoolspace")
|
||||
mempoolspace_status_color = get_service_status_color("mempoolspace")
|
||||
|
||||
# Find lndconnect status
|
||||
if lnd_ready:
|
||||
|
@ -371,12 +356,11 @@ def index():
|
|||
|
||||
# Find VPN status
|
||||
if is_vpn_enabled():
|
||||
status = os.system("systemctl status vpn --no-pager")
|
||||
if status != 0:
|
||||
vpn_status_color = "red"
|
||||
vpn_status_color = get_service_status_color("vpn")
|
||||
status_code = get_service_status_code("vpn")
|
||||
if status_code != 0:
|
||||
vpn_status = "Unknown"
|
||||
else:
|
||||
vpn_status_color = "green"
|
||||
if os.path.isfile("/home/pivpn/ovpns/mynode_vpn.ovpn"):
|
||||
vpn_status = "Running"
|
||||
else:
|
||||
|
|
|
@ -78,47 +78,39 @@ def page_settings():
|
|||
local_ip = get_local_ip()
|
||||
public_ip = get_public_ip()
|
||||
|
||||
|
||||
# Get QuickSync Status
|
||||
quicksync_status = ""
|
||||
quicksync_enabled = is_quicksync_enabled()
|
||||
quicksync_status = "Disabled"
|
||||
quicksync_status_color = "gray"
|
||||
if quicksync_enabled:
|
||||
quicksync_status = get_service_status_basic_text("quicksync")
|
||||
quicksync_status_color = get_service_status_color("quicksync")
|
||||
|
||||
quicksync_status_log = ""
|
||||
try:
|
||||
quicksync_status = subprocess.check_output(["mynode-get-quicksync-status"]).decode("utf8")
|
||||
quicksync_status_log = subprocess.check_output(["mynode-get-quicksync-status"]).decode("utf8")
|
||||
except:
|
||||
quicksync_status = "ERROR"
|
||||
quicksync_status_log = "ERROR"
|
||||
|
||||
# Get Bitcoin Status
|
||||
bitcoin_status = ""
|
||||
bitcoin_status_log = ""
|
||||
try:
|
||||
bitcoin_status = subprocess.check_output(["tail","-n","200","/mnt/hdd/mynode/bitcoin/debug.log"]).decode("utf8")
|
||||
bitcoin_status_log = subprocess.check_output(["tail","-n","200","/mnt/hdd/mynode/bitcoin/debug.log"]).decode("utf8")
|
||||
except:
|
||||
bitcoin_status = "ERROR"
|
||||
bitcoin_status_log = "ERROR"
|
||||
|
||||
# Get LND Status
|
||||
lnd_status = ""
|
||||
try:
|
||||
lnd_status = subprocess.check_output("journalctl -r --unit=lnd --no-pager | tail -n 200", shell=True).decode("utf8")
|
||||
except:
|
||||
lnd_status = "ERROR"
|
||||
lnd_status_log = get_journalctl_log("lnd")
|
||||
|
||||
# Get Tor Status
|
||||
tor_status = ""
|
||||
try:
|
||||
tor_status = subprocess.check_output("journalctl -r --unit=tor@default --no-pager | tail -n 200", shell=True).decode("utf8")
|
||||
except:
|
||||
tor_status = "ERROR"
|
||||
tor_status_log = get_journalctl_log("tor@default")
|
||||
|
||||
# Get Electrs Status
|
||||
electrs_status = ""
|
||||
try:
|
||||
electrs_status = subprocess.check_output("journalctl -r --unit=electrs --no-pager | tail -n 200", shell=True).decode("utf8")
|
||||
except:
|
||||
electrs_status = "ERROR"
|
||||
electrs_status_log = get_journalctl_log("electrs")
|
||||
|
||||
# Get Docker Image Build Status
|
||||
docker_image_build_status = ""
|
||||
try:
|
||||
docker_image_build_status = subprocess.check_output("journalctl -r --unit=docker_images --no-pager | tail -n 200", shell=True).decode("utf8")
|
||||
except:
|
||||
docker_image_build_status = "ERROR"
|
||||
docker_image_build_status_log = get_journalctl_log("docker_images")
|
||||
|
||||
# Get QuickSync Rates
|
||||
upload_rate = 100
|
||||
|
@ -143,13 +135,25 @@ def page_settings():
|
|||
"product_key_skipped": pk_skipped,
|
||||
"product_key_error": pk_error,
|
||||
"changelog": changelog,
|
||||
"quicksync_status_log": quicksync_status_log,
|
||||
"quicksync_status": quicksync_status,
|
||||
"bitcoin_status": bitcoin_status,
|
||||
"lnd_status": lnd_status,
|
||||
"tor_status": tor_status,
|
||||
"electrs_status": electrs_status,
|
||||
"docker_image_build_status": docker_image_build_status,
|
||||
"is_quicksync_disabled": not is_quicksync_enabled(),
|
||||
"quicksync_status_color": quicksync_status_color,
|
||||
"bitcoin_status_log": bitcoin_status_log,
|
||||
"bitcoin_status": get_service_status_basic_text("bitcoind"),
|
||||
"bitcoin_status_color": get_service_status_color("bitcoind"),
|
||||
"lnd_status_log": lnd_status_log,
|
||||
"lnd_status": get_service_status_basic_text("lnd"),
|
||||
"lnd_status_color": get_service_status_color("lnd"),
|
||||
"tor_status_log": tor_status_log,
|
||||
"tor_status": get_service_status_basic_text("tor@default"),
|
||||
"tor_status_color": get_service_status_color("tor@default"),
|
||||
"electrs_status_log": electrs_status_log,
|
||||
"electrs_status": get_service_status_basic_text("electrs"),
|
||||
"electrs_status_color": get_service_status_color("electrs"),
|
||||
"docker_image_build_status_log": docker_image_build_status_log,
|
||||
"docker_image_build_status": get_docker_image_build_status(),
|
||||
"docker_image_build_status_color": get_docker_image_build_status_color(),
|
||||
"is_quicksync_disabled": not quicksync_enabled,
|
||||
"is_netdata_enabled": is_netdata_enabled(),
|
||||
"is_uploader_device": is_uploader(),
|
||||
"download_rate": download_rate,
|
||||
|
|
|
@ -286,7 +286,7 @@ a:active {
|
|||
font-size: 24px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
padding: 5px;
|
||||
margin-bottom: 20px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.settings_block_subheader {
|
||||
color: #333333;
|
||||
|
@ -294,16 +294,35 @@ a:active {
|
|||
font-size: 18px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.settings_block_subheader_status {
|
||||
color: #333333;
|
||||
height: 18px;
|
||||
text-align: left;
|
||||
font-size: 14px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-style: italic;
|
||||
vertical-align: middle;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.settings_block_subheader_status_icon {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-right: 5px;
|
||||
display: inline-block;
|
||||
border-radius: 50%;
|
||||
-moz-border-radius: 50%;
|
||||
-webkit-border-radius: 50%;
|
||||
}
|
||||
.settings_block {
|
||||
width: 600px;
|
||||
width: 800px;
|
||||
color: #444444;
|
||||
margin: auto;
|
||||
text-align: justify;
|
||||
font-size: 14px;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
margin-bottom: 40px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.divider {
|
||||
width: 100%;
|
||||
|
|
|
@ -455,33 +455,57 @@
|
|||
<div class="settings_block_header">Service Status</div>
|
||||
|
||||
<div class="settings_block_subheader">QuickSync Status</div>
|
||||
<div class="settings_block_subheader_status">
|
||||
<div class="settings_block_subheader_status_icon {{ quicksync_status_color }}"></div>
|
||||
{{ quicksync_status }}
|
||||
</div>
|
||||
<button id="show_quicksync_status" class="ui-button ui-widget ui-corner-all settings_button">Show</button>
|
||||
<div id="quicksync_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{quicksync_status}}</pre></div>
|
||||
<div id="quicksync_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{quicksync_status_log}}</pre></div>
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="settings_block_subheader">Bitcoin Status</div>
|
||||
<div class="settings_block_subheader_status">
|
||||
<div class="settings_block_subheader_status_icon {{ bitcoin_status_color }}"></div>
|
||||
{{ bitcoin_status }}
|
||||
</div>
|
||||
<button id="show_bitcoin_status" class="ui-button ui-widget ui-corner-all settings_button">Show</button>
|
||||
<div id="bitcoin_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{bitcoin_status}}</pre></div>
|
||||
<div id="bitcoin_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{bitcoin_status_log}}</pre></div>
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="settings_block_subheader">LND Status</div>
|
||||
<div class="settings_block_subheader_status">
|
||||
<div class="settings_block_subheader_status_icon {{ lnd_status_color }}"></div>
|
||||
{{ lnd_status }}
|
||||
</div>
|
||||
<button id="show_lnd_status" class="ui-button ui-widget ui-corner-all settings_button">Show</button>
|
||||
<div id="lnd_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{lnd_status}}</pre></div>
|
||||
<div id="lnd_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{lnd_status_log}}</pre></div>
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="settings_block_subheader">Tor Status</div>
|
||||
<div class="settings_block_subheader_status">
|
||||
<div class="settings_block_subheader_status_icon {{ tor_status_color }}"></div>
|
||||
{{ tor_status }}
|
||||
</div>
|
||||
<button id="show_tor_status" class="ui-button ui-widget ui-corner-all settings_button">Show</button>
|
||||
<div id="tor_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{tor_status}}</pre></div>
|
||||
<div id="tor_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{tor_status_log}}</pre></div>
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="settings_block_subheader">Electrum Server Status</div>
|
||||
<div class="settings_block_subheader_status">
|
||||
<div class="settings_block_subheader_status_icon {{ electrs_status_color }}"></div>
|
||||
{{ electrs_status }}
|
||||
</div>
|
||||
<button id="show_electrs_status" class="ui-button ui-widget ui-corner-all settings_button">Show</button>
|
||||
<div id="electrs_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{electrs_status}}</pre></div>
|
||||
<div id="electrs_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{electrs_status_log}}</pre></div>
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="settings_block_subheader">Docker Image Build Status</div>
|
||||
<div class="settings_block_subheader_status">
|
||||
<div class="settings_block_subheader_status_icon {{ docker_image_build_status_color }}"></div>
|
||||
{{ docker_image_build_status }}
|
||||
</div>
|
||||
<button id="show_docker_image_build_status" class="ui-button ui-widget ui-corner-all settings_button">Show</button>
|
||||
<div id="docker_image_build_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{docker_image_build_status}}</pre></div>
|
||||
<div id="docker_image_build_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{docker_image_build_status_log}}</pre></div>
|
||||
</div>
|
||||
|
||||
<div class="settings_block">
|
||||
|
|
|
@ -2,6 +2,7 @@ from flask import Blueprint, render_template, redirect
|
|||
from settings import read_ui_settings
|
||||
from user_management import check_logged_in
|
||||
from enable_disable_functions import is_whirlpool_enabled, enable_whirlpool, disable_whirlpool
|
||||
from device_info import get_service_status_code
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
|
@ -14,7 +15,7 @@ def get_whirlpool_status():
|
|||
whirlpool_status_color = "gray"
|
||||
whirlpool_initialized = os.path.isfile("/opt/mynode/whirlpool/whirlpool-cli-config.properties")
|
||||
if is_whirlpool_enabled():
|
||||
status = os.system("systemctl status whirlpool --no-pager")
|
||||
get_service_status_code("whirlpool")
|
||||
if status != 0:
|
||||
whirlpool_status = "Inactive"
|
||||
whirlpool_status_color = "red"
|
||||
|
|
Loading…
Reference in New Issue
Block a user