From e64f412fa1e593ca07e6d01148be948556700921 Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Thu, 4 Mar 2021 22:50:35 -0600 Subject: [PATCH] Upgrade LNBits to v0.2.0 --- .../etc/nginx/sites-enabled/https_lnbits.conf | 4 +++ .../etc/systemd/system/lnbits.service | 12 ++++--- .../standard/usr/bin/mynode_post_upgrade.sh | 23 ++++++-------- rootfs/standard/usr/share/mynode/lnbits.env | 14 ++++++--- .../usr/share/mynode/mynode_app_versions.sh | 2 +- setup/setup_device.sh | 31 +++++++------------ 6 files changed, 42 insertions(+), 44 deletions(-) diff --git a/rootfs/standard/etc/nginx/sites-enabled/https_lnbits.conf b/rootfs/standard/etc/nginx/sites-enabled/https_lnbits.conf index 12fe1c8c..0f2bcf19 100644 --- a/rootfs/standard/etc/nginx/sites-enabled/https_lnbits.conf +++ b/rootfs/standard/etc/nginx/sites-enabled/https_lnbits.conf @@ -8,6 +8,10 @@ server { access_log /var/log/nginx/access_lnbits.log; error_log /var/log/nginx/error_lnbits.log; + location /static { + root /opt/mynode/lnbits/lnbits; + } + location / { proxy_pass http://127.0.0.1:5000; diff --git a/rootfs/standard/etc/systemd/system/lnbits.service b/rootfs/standard/etc/systemd/system/lnbits.service index 22b9b142..af8c7730 100644 --- a/rootfs/standard/etc/systemd/system/lnbits.service +++ b/rootfs/standard/etc/systemd/system/lnbits.service @@ -10,18 +10,20 @@ After=bitcoind.service lnd.service ExecStartPre=/usr/bin/is_not_shutting_down.sh ExecStartPre=/usr/bin/wait_on_lnd.sh ExecStartPre=/usr/bin/mynode_pre_lnbits.sh -ExecStartPre=/bin/sh -c 'cd /opt/mynode/lnbits && /usr/local/bin/pipenv run flask migrate' -Environment=FLASK_ENV=development +#ExecStartPre=/bin/sh -c 'cd /opt/mynode/lnbits && /usr/local/bin/pipenv run flask migrate' + +ExecStartPre=/bin/sh -c 'cd /opt/mynode/lnbits && ./lnbits_venv/bin/quart migrate' +#Environment=FLASK_ENV=development WorkingDirectory=/opt/mynode/lnbits -ExecStart=/bin/sh -c 'cd /opt/mynode/lnbits && /usr/local/bin/pipenv run flask run --host 0.0.0.0' +ExecStart=/bin/sh -c 'cd /opt/mynode/lnbits && ./lnbits_venv/bin/hypercorn -k trio --bind 0.0.0.0:5000 "lnbits.app:create_app()"' User=bitcoin Group=bitcoin Type=simple -TimeoutSec=240 +TimeoutSec=120 Restart=always -RestartSec=60 +RestartSec=30 StandardOutput=syslog StandardError=syslog SyslogIdentifier=lnbits diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index a848be72..0a08cc31 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -26,6 +26,10 @@ fi # Create any necessary users useradd -m -s /bin/bash joinmarket || true +# Setup bitcoin user folders +mkdir -p /home/bitcoin/.mynode/ +chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ + # User updates and settings grep "joinmarket" /etc/sudoers || (echo 'joinmarket ALL=(ALL) NOPASSWD:ALL' | EDITOR='tee -a' visudo) @@ -555,8 +559,6 @@ if [ "$CURRENT" != "$RTL_VERSION" ]; then cd RTL sudo -u bitcoin NG_CLI_ANALYTICS=false npm install --only=production - mkdir -p /home/bitcoin/.mynode/ - chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $RTL_VERSION > $RTL_VERSION_FILE else echo "ERROR UPGRADING RTL - GPG FAILED" @@ -579,8 +581,6 @@ if [ "$CURRENT" != "$BTCRPCEXPLORER_VERSION" ]; then cd btc-rpc-explorer sudo -u bitcoin npm install --only=production - mkdir -p /home/bitcoin/.mynode/ - chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $BTCRPCEXPLORER_VERSION > $BTCRPCEXPLORER_VERSION_FILE fi @@ -605,15 +605,12 @@ if [ "$CURRENT" != "$LNBITS_VERSION" ]; then cp /usr/share/mynode/lnbits.env /opt/mynode/lnbits/.env chown bitcoin:bitcoin /opt/mynode/lnbits/.env - # Install with python 3.7 (Only use "pipenv install --python 3.7" once or it will rebuild the venv!) - sudo -u bitcoin pipenv --python 3.7 install - sudo -u bitcoin pipenv run pip install python-dotenv - sudo -u bitcoin pipenv run pip install -r requirements.txt - #sudo -u bitcoin pipenv run pip install lnd-grpc # Using REST now (this install takes a LONG time) - sudo -u bitcoin pipenv run flask migrate || true + # Install lnbits + sudo -u bitcoin python3 -m venv lnbits_venv + sudo -u bitcoin ./lnbits_venv/bin/pip install -r requirements.txt + sudo -u bitcoin ./lnbits_venv/bin/quart assets + sudo -u bitcoin ./lnbits_venv/bin/quart migrate - mkdir -p /home/bitcoin/.mynode/ - chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $LNBITS_VERSION > $LNBITS_VERSION_FILE fi @@ -690,8 +687,6 @@ if [ "$CURRENT" != "$LNDCONNECT_VERSION" ]; then mv lndconnect-* lndconnect install -m 0755 -o root -g root -t /usr/local/bin lndconnect/* - mkdir -p /home/bitcoin/.mynode/ - chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $LNDCONNECT_VERSION > $LNDCONNECT_VERSION_FILE fi diff --git a/rootfs/standard/usr/share/mynode/lnbits.env b/rootfs/standard/usr/share/mynode/lnbits.env index 5d27b451..65211bc7 100644 --- a/rootfs/standard/usr/share/mynode/lnbits.env +++ b/rootfs/standard/usr/share/mynode/lnbits.env @@ -1,11 +1,17 @@ -FLASK_APP=lnbits -FLASK_ENV=production +QUART_APP=lnbits.app:create_app() +QUART_ENV=development +QUART_DEBUG=true + +HOST=0.0.0.0 +PORT=5000 + +QUART_APP=lnbits.app:create_app() LNBITS_SITE_TITLE=LNbits -LNBITS_ALLOWED_USERS="all" +LNBITS_ALLOWED_USERS="" LNBITS_DEFAULT_WALLET_NAME="LNbits wallet" LNBITS_DATA_FOLDER="/mnt/hdd/mynode/lnbits" -LNBITS_DISABLED_EXTENSIONS="amilk,events" +LNBITS_DISABLED_EXTENSIONS="amilk" LNBITS_FORCE_HTTPS=0 LNBITS_SERVICE_FEE="0.0" diff --git a/rootfs/standard/usr/share/mynode/mynode_app_versions.sh b/rootfs/standard/usr/share/mynode/mynode_app_versions.sh index 456f3d69..c24ce509 100644 --- a/rootfs/standard/usr/share/mynode/mynode_app_versions.sh +++ b/rootfs/standard/usr/share/mynode/mynode_app_versions.sh @@ -60,7 +60,7 @@ BTCRPCEXPLORER_VERSION="v2.2.0" BTCRPCEXPLORER_VERSION_FILE=/home/bitcoin/.mynode/btcrpcexplorer_version BTCRPCEXPLORER_LATEST_VERSION_FILE=/home/bitcoin/.mynode/btcrpcexplorer_version_latest -LNBITS_VERSION=dd2a282158d5774c2a3c85c164a10709c13ef7b4 # Github hash to download +LNBITS_VERSION=503c981bc970f4ab894f50198dbd6833cae8f6e0 # Github hash to download LNBITS_VERSION_FILE=/home/bitcoin/.mynode/lnbits_version LNBITS_LATEST_VERSION_FILE=/home/bitcoin/.mynode/lnbits_version_latest diff --git a/setup/setup_device.sh b/setup/setup_device.sh index f9a0c057..a6b9a94a 100755 --- a/setup/setup_device.sh +++ b/setup/setup_device.sh @@ -102,6 +102,10 @@ source /tmp/mynode_app_versions.sh # Create any necessary users useradd -m -s /bin/bash joinmarket || true +# Setup bitcoin user folders +mkdir -p /home/bitcoin/.mynode/ +chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ + # Update sources apt-get -y update @@ -310,8 +314,6 @@ if [ "$CURRENT" != "$BTC_VERSION" ]; then sudo -u bitcoin ln -s /mnt/hdd/mynode/lnd /home/bitcoin/.lnd fi mkdir -p /home/admin/.bitcoin - mkdir -p /home/bitcoin/.mynode/ - chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $BTC_VERSION > $BTC_VERSION_FILE fi cd ~ @@ -342,8 +344,6 @@ if [ "$CURRENT" != "$LND_VERSION" ]; then install -m 0755 -o root -g root -t /usr/local/bin lnd/* ln -s /bin/ip /usr/bin/ip || true - mkdir -p /home/bitcoin/.mynode/ - chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $LND_VERSION > $LND_VERSION_FILE fi cd ~ @@ -609,8 +609,6 @@ if [ "$CURRENT" != "$RTL_VERSION" ]; then cd RTL sudo -u bitcoin NG_CLI_ANALYTICS=false npm install --only=production - mkdir -p /home/bitcoin/.mynode/ - chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $RTL_VERSION > $RTL_VERSION_FILE fi @@ -631,8 +629,6 @@ if [ "$CURRENT" != "$BTCRPCEXPLORER_VERSION" ]; then cd btc-rpc-explorer sudo -u bitcoin npm install --only=production - mkdir -p /home/bitcoin/.mynode/ - chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $BTCRPCEXPLORER_VERSION > $BTCRPCEXPLORER_VERSION_FILE fi @@ -654,18 +650,15 @@ if [ "$CURRENT" != "$LNBITS_VERSION" ]; then cd lnbits # Copy over config file - #cp /usr/share/mynode/lnbits.env /opt/mynode/lnbits/.env - #chown bitcoin:bitcoin /opt/mynode/lnbits/.env + cp /usr/share/mynode/lnbits.env /opt/mynode/lnbits/.env + chown bitcoin:bitcoin /opt/mynode/lnbits/.env - # Install with python 3.7 (Only use "pipenv install --python 3.7" once or it will rebuild the venv!) - sudo -u bitcoin pipenv --python 3.7 install - sudo -u bitcoin pipenv run pip install python-dotenv - sudo -u bitcoin pipenv run pip install -r requirements.txt - #sudo -u bitcoin pipenv run pip install lnd-grpc # Using REST now (this install takes a LONG time) - sudo -u bitcoin pipenv run flask migrate || true + # Install lnbits + sudo -u bitcoin python3 -m venv lnbits_venv + sudo -u bitcoin ./lnbits_venv/bin/pip install -r requirements.txt + sudo -u bitcoin ./lnbits_venv/bin/quart assets + sudo -u bitcoin ./lnbits_venv/bin/quart migrate - mkdir -p /home/bitcoin/.mynode/ - chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $LNBITS_VERSION > $LNBITS_VERSION_FILE fi @@ -742,8 +735,6 @@ if [ "$CURRENT" != "$LNDCONNECT_VERSION" ]; then mv lndconnect-* lndconnect install -m 0755 -o root -g root -t /usr/local/bin lndconnect/* - mkdir -p /home/bitcoin/.mynode/ - chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ echo $LNDCONNECT_VERSION > $LNDCONNECT_VERSION_FILE fi