From 8245224d55bb6e9cbc76e35376e25877a4a000aa Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Thu, 13 May 2021 22:50:05 -0500 Subject: [PATCH] Add pyblock app --- rootfs/standard/usr/bin/mynode-pyblock | 6 ++ .../standard/usr/bin/mynode_post_upgrade.sh | 76 +++++++++++++----- rootfs/standard/usr/bin/mynode_startup.sh | 1 + .../usr/share/mynode/mynode_app_versions.sh | 4 + .../var/www/mynode/application_info.py | 15 ++++ rootfs/standard/var/www/mynode/mynode.py | 2 + rootfs/standard/var/www/mynode/pyblock.py | 23 ++++++ .../var/www/mynode/static/images/pyblock.png | Bin 0 -> 4139 bytes .../var/www/mynode/templates/pyblock.html | 55 +++++++++++++ setup/setup_device.sh | 4 + 10 files changed, 165 insertions(+), 21 deletions(-) create mode 100755 rootfs/standard/usr/bin/mynode-pyblock create mode 100644 rootfs/standard/var/www/mynode/pyblock.py create mode 100644 rootfs/standard/var/www/mynode/static/images/pyblock.png create mode 100644 rootfs/standard/var/www/mynode/templates/pyblock.html diff --git a/rootfs/standard/usr/bin/mynode-pyblock b/rootfs/standard/usr/bin/mynode-pyblock new file mode 100755 index 00000000..dcb8f337 --- /dev/null +++ b/rootfs/standard/usr/bin/mynode-pyblock @@ -0,0 +1,6 @@ +#!/bin/bash + +# mynode-pyblock +# This script needs to be run with sudo so it can run as the bitcoin user + +sudo -u bitcoin bash -c "cd /opt/mynode/pyblock/; source env/bin/activate; python3 PyBlock.py" \ No newline at end of file diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index ccc5943a..cdd78429 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -824,6 +824,61 @@ if should_install_app "ckbunker" ; then fi fi + +# Upgrade Sphinx Relay +if should_install_app "sphinxrelay" ; then + SPHINXRELAY_UPGRADE_URL=https://github.com/stakwork/sphinx-relay/archive/$SPHINXRELAY_VERSION.tar.gz + CURRENT="" + if [ -f $SPHINXRELAY_VERSION_FILE ]; then + CURRENT=$(cat $SPHINXRELAY_VERSION_FILE) + fi + if [ "$CURRENT" != "$SPHINXRELAY_VERSION" ]; then + cd /opt/mynode + rm -rf sphinxrelay + + sudo -u bitcoin wget $SPHINXRELAY_UPGRADE_URL -O sphinx-relay.tar.gz + sudo -u bitcoin tar -xvf sphinx-relay.tar.gz + sudo -u bitcoin rm sphinx-relay.tar.gz + sudo -u bitcoin mv sphinx-relay-* sphinxrelay + cd sphinxrelay + + sudo -u bitcoin npm install + + echo $SPHINXRELAY_VERSION > $SPHINXRELAY_VERSION_FILE + fi +fi + + +# Upgrade pyblock +if should_install_app "pyblock" ; then + PYBLOCK_UPGRADE_URL=https://github.com/curly60e/pyblock/archive/refs/tags/$PYBLOCK_VERSION.tar.gz + CURRENT="" + if [ -f $PYBLOCK_VERSION_FILE ]; then + CURRENT=$(cat $PYBLOCK_VERSION_FILE) + fi + if [ "$CURRENT" != "$PYBLOCK_VERSION" ]; then + cd /opt/mynode + rm -rf pyblock + + sudo -u bitcoin wget $PYBLOCK_UPGRADE_URL -O pyblock.tar.gz + sudo -u bitcoin tar -xvf pyblock.tar.gz + sudo -u bitcoin rm pyblock.tar.gz + sudo -u bitcoin mv pyblock-* pyblock + cd pyblock + + # Make venv + if [ ! -d env ]; then + sudo -u bitcoin python3 -m venv env + fi + source env/bin/activate + pip3 install -r requirements.txt + deactivate + + echo $PYBLOCK_VERSION > $PYBLOCK_VERSION_FILE + fi +fi + + # Upgrade WARden if should_install_app "warden" ; then WARDEN_UPGRADE_URL=https://github.com/pxsocs/warden/archive/refs/tags/$WARDEN_VERSION.tar.gz @@ -854,28 +909,7 @@ if should_install_app "warden" ; then fi -# Upgrade Sphinx Relay -if should_install_app "sphinxrelay" ; then - SPHINXRELAY_UPGRADE_URL=https://github.com/stakwork/sphinx-relay/archive/$SPHINXRELAY_VERSION.tar.gz - CURRENT="" - if [ -f $SPHINXRELAY_VERSION_FILE ]; then - CURRENT=$(cat $SPHINXRELAY_VERSION_FILE) - fi - if [ "$CURRENT" != "$SPHINXRELAY_VERSION" ]; then - cd /opt/mynode - rm -rf sphinxrelay - sudo -u bitcoin wget $SPHINXRELAY_UPGRADE_URL -O sphinx-relay.tar.gz - sudo -u bitcoin tar -xvf sphinx-relay.tar.gz - sudo -u bitcoin rm sphinx-relay.tar.gz - sudo -u bitcoin mv sphinx-relay-* sphinxrelay - cd sphinxrelay - - sudo -u bitcoin npm install - - echo $SPHINXRELAY_VERSION > $SPHINXRELAY_VERSION_FILE - fi -fi # Upgrade Tor diff --git a/rootfs/standard/usr/bin/mynode_startup.sh b/rootfs/standard/usr/bin/mynode_startup.sh index 4c145e86..3c4398e2 100755 --- a/rootfs/standard/usr/bin/mynode_startup.sh +++ b/rootfs/standard/usr/bin/mynode_startup.sh @@ -793,6 +793,7 @@ echo $LNDCONNECT_VERSION > $LNDCONNECT_LATEST_VERSION_FILE echo $CKBUNKER_VERSION > $CKBUNKER_LATEST_VERSION_FILE echo $SPHINXRELAY_VERSION > $SPHINXRELAY_LATEST_VERSION_FILE echo $WEBSSH2_VERSION > $WEBSSH2_LATEST_VERSION_FILE +echo $PYBLOCK_VERSION > $PYBLOCK_LATEST_VERSION_FILE echo $WARDEN_VERSION > $WARDEN_LATEST_VERSION_FILE # Weird hacks diff --git a/rootfs/standard/usr/share/mynode/mynode_app_versions.sh b/rootfs/standard/usr/share/mynode/mynode_app_versions.sh index 9a123247..e71dc985 100644 --- a/rootfs/standard/usr/share/mynode/mynode_app_versions.sh +++ b/rootfs/standard/usr/share/mynode/mynode_app_versions.sh @@ -105,6 +105,10 @@ SPHINXRELAY_VERSION="v2.0.13" SPHINXRELAY_VERSION_FILE=/home/bitcoin/.mynode/sphinxrelay_version SPHINXRELAY_LATEST_VERSION_FILE=/home/bitcoin/.mynode/sphinxrelay_version_latest +PYBLOCK_VERSION="v0.9.7.3" +PYBLOCK_VERSION_FILE=/home/bitcoin/.mynode/pyblock_version +PYBLOCK_LATEST_VERSION_FILE=/home/bitcoin/.mynode/pyblock_version_latest + WARDEN_VERSION="0.91" WARDEN_VERSION_FILE=/home/bitcoin/.mynode/warden_version WARDEN_LATEST_VERSION_FILE=/home/bitcoin/.mynode/warden_version_latest diff --git a/rootfs/standard/var/www/mynode/application_info.py b/rootfs/standard/var/www/mynode/application_info.py index 2c40b8e5..95214c23 100644 --- a/rootfs/standard/var/www/mynode/application_info.py +++ b/rootfs/standard/var/www/mynode/application_info.py @@ -388,6 +388,19 @@ def initialize_applications(): homepage_order=41, is_premium=False )) + apps.append(create_application( + name="PyBlock", + short_name="pyblock", + requires_lightning=True, + app_tile_default_status_text="Blockchain Info", + app_tile_button_text="Info", + app_tile_button_href="/pyblock", + can_uninstall=True, + can_enable_disable=False, + show_on_homepage=True, + homepage_order=42, + is_premium=False + )) apps.append(create_application( name="Web SSH", short_name="webssh2", @@ -558,6 +571,8 @@ def get_application_status_color_special(short_name): return get_lnd_status_color() elif short_name == "joininbox": return "clear" + elif short_name == "pyblock": + return "clear" elif short_name == "whirlpool": if not os.path.isfile("/mnt/hdd/mynode/whirlpool/whirlpool-cli-config.properties"): return "yellow" diff --git a/rootfs/standard/var/www/mynode/mynode.py b/rootfs/standard/var/www/mynode/mynode.py index 10456e1d..8868d015 100644 --- a/rootfs/standard/var/www/mynode/mynode.py +++ b/rootfs/standard/var/www/mynode/mynode.py @@ -9,6 +9,7 @@ from dojo import mynode_dojo from joininbox import mynode_joininbox from caravan import mynode_caravan from sphinxrelay import mynode_sphinxrelay +from pyblock import mynode_pyblock from manage_apps import mynode_manage_apps from tor import mynode_tor from vpn import mynode_vpn @@ -84,6 +85,7 @@ app.register_blueprint(mynode_dojo) app.register_blueprint(mynode_joininbox) app.register_blueprint(mynode_caravan) app.register_blueprint(mynode_sphinxrelay) +app.register_blueprint(mynode_pyblock) app.register_blueprint(mynode_manage_apps) app.register_blueprint(mynode_tor) app.register_blueprint(mynode_electrum_server) diff --git a/rootfs/standard/var/www/mynode/pyblock.py b/rootfs/standard/var/www/mynode/pyblock.py new file mode 100644 index 00000000..903c243b --- /dev/null +++ b/rootfs/standard/var/www/mynode/pyblock.py @@ -0,0 +1,23 @@ +from flask import Blueprint, render_template, redirect, request, flash, send_from_directory +from user_management import check_logged_in +from device_info import read_ui_settings +from systemctl_info import * +import os +import time +import subprocess +import os + +mynode_pyblock = Blueprint('mynode_pyblock',__name__) + +### Page functions +@mynode_pyblock.route("/pyblock") +def pyblock_page(): + check_logged_in() + + # Load page + templateData = { + "title": "myNode PyBlock", + "ui_settings": read_ui_settings(), + } + return render_template('pyblock.html', **templateData) + diff --git a/rootfs/standard/var/www/mynode/static/images/pyblock.png b/rootfs/standard/var/www/mynode/static/images/pyblock.png new file mode 100644 index 0000000000000000000000000000000000000000..8182516e10ed2cd4a4a39b6c2b22e7077a51121f GIT binary patch literal 4139 zcmZ`+c|4Te+dub=F_WQ2*^4HnWGPAtVI(rjl07k0#K=;{zD|l3OSZ@|Otwt+vJ^(+ zQ79$P*w>M=J+c(CCGS1GfB(+CU*~+zIoI{Qmhb(*)cBkLp9CKOK!9j))(ij$euV&r z7k=1z7hZ=yBFVbCrbJy`{7rAK>tuIl0Av$F6EqE)Oobv%%%i0((He!PoC=La&g$){ z;?pa{xkXw@ULdWbjU*Ck~P{|2lpGgMWLAaB2`ej#A* z*UW-tens(hc2AS@e!8mL8(aHKo;qS?-dWnUATg}-vvIA_IW zxlk<{f)WB!#0!k-bxt$MyE9iF>@SurdOP{{+ClsH)r6UcEnb<}BiPf&uNIguz7@P$ z(a~(U`(+M8&_wW@rO~sHeP1g+1V+EKDt$4bxrS|03w2JLsfKEP6>9@2-w-xs5tLy7}ERb>|>+2F^&{>>#lGV6R$(H`zH{0L8>hmloYvOkp*x>Q@e;=@J1>?ed_58WB zV2gXuna`47$+nvYmnZ-n+0VV8fP8H~Scvu^8tI|OQQILL0`1=T1Qv<==-K$_dU<#_ zd-?!fZ|5sM&Q5rLvX3kN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lT3uT$7$(I!gc@z+8g$BQ zzWs5M7Pj=;n3lD>MXE+;&fsnMAq=%5;36e4F0OVOYf|*XF~_OuUSF3_?dCFZ`gGmU z9c3!pwd=SL$Jkq81r9wIH@PNoB|gVsPu5-@LjU)A&B0e$6ooB3Fr18&>~H3fAp%J5 zc&3#$d;fMqE($=VS`UtS$QWSZGJQ89HNqiu5B};j8WuBB+5FI`&EF0Pm#5-{fz?hX zL_TtiUrD5hqag@EPln>Zicq_E;6d}jyu=*-JJf_qMuJ;g*G8R^v5J}A#SbwENU2mA zOj>(E)gFuMr`!kuz~UCsSNt&Ah2#EU^Vmc;$Get1oi zc{(?sSZCL_mP=$6m*u%Mf8R7U?*IP(Y_FHYrLyyPA6v+b;f^8d8J{gZ;~4ROQYRC$ literal 0 HcmV?d00001 diff --git a/rootfs/standard/var/www/mynode/templates/pyblock.html b/rootfs/standard/var/www/mynode/templates/pyblock.html new file mode 100644 index 00000000..9227ad8f --- /dev/null +++ b/rootfs/standard/var/www/mynode/templates/pyblock.html @@ -0,0 +1,55 @@ + + + {{ title }} + {% include 'includes/head.html' %} + + + {% include 'includes/logo_header.html' %} +
+ home  +
+ + {% include 'includes/message_display.html' %} + +
PyBlock
+
+ +
+
+
Status
+
Ready
+
+
+ + +
+
Instructions to setup PyBlock
+
    +
  1. PyBlock is a tool for viewing and interacting with your node.
  2. +
  3. To get started, you need access to the Linux terminal of your myNode device.
  4. +
      +
    • A guide to access the Linux terminal is available on mynodebtc.com - guide
    • +
    +
  5. Once you have terminal access, run the following command:
  6. +
      +
    • sudo mynode-pyblock
    • +
    +
  7. Enter your myNode password when prompted.
  8. +
  9. The first time running PyBlock, you will be prompted for various node information.
  10. +
      +
    • For more information on filling it out, see the PyBlock GitHub page.
    • +
    +
  11. Enjoy PyBlock!
  12. +
+ +

+ + +
+ + diff --git a/setup/setup_device.sh b/setup/setup_device.sh index 5b8aa738..16903589 100755 --- a/setup/setup_device.sh +++ b/setup/setup_device.sh @@ -868,6 +868,10 @@ if [ "$CURRENT" != "$SPHINXRELAY_VERSION" ]; then fi +# SKIPPING PYBLOCK - OPTIONAL APP +# SKIPPING WARDEN - OPTIONAL APP + + # Make sure we are using legacy iptables update-alternatives --set iptables /usr/sbin/iptables-legacy || true update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy || true