diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index 57367afb..11cc5e3a 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -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 diff --git a/rootfs/standard/var/www/mynode/device_info.py b/rootfs/standard/var/www/mynode/device_info.py index 2645194e..6cf363c5 100644 --- a/rootfs/standard/var/www/mynode/device_info.py +++ b/rootfs/standard/var/www/mynode/device_info.py @@ -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" \ No newline at end of file diff --git a/rootfs/standard/var/www/mynode/mynode.py b/rootfs/standard/var/www/mynode/mynode.py index 2ffc4868..bb3c5d0b 100644 --- a/rootfs/standard/var/www/mynode/mynode.py +++ b/rootfs/standard/var/www/mynode/mynode.py @@ -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: diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index 0837fb00..b4f4fb82 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -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, diff --git a/rootfs/standard/var/www/mynode/static/css/mynode.css b/rootfs/standard/var/www/mynode/static/css/mynode.css index 7ff055cf..52ad32f8 100644 --- a/rootfs/standard/var/www/mynode/static/css/mynode.css +++ b/rootfs/standard/var/www/mynode/static/css/mynode.css @@ -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%; diff --git a/rootfs/standard/var/www/mynode/templates/settings.html b/rootfs/standard/var/www/mynode/templates/settings.html index a49a8dd7..c3e39133 100644 --- a/rootfs/standard/var/www/mynode/templates/settings.html +++ b/rootfs/standard/var/www/mynode/templates/settings.html @@ -455,33 +455,57 @@