From 5ab15413b71bfbca72c94d510170dbb8d803b4c3 Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Sat, 8 Feb 2020 20:20:35 -0600 Subject: [PATCH] Add loopd --- CHANGELOG | 5 +++ rootfs/standard/etc/logrotate.d/rsyslog | 1 + rootfs/standard/etc/rsyslog.d/loopd.conf | 2 + .../{lnd_admin.service => loopd.service} | 16 +++---- .../standard/usr/bin/mynode_docker_images.sh | 2 + .../usr/bin/mynode_lnd_admin_files.sh | 4 +- .../standard/usr/bin/mynode_post_upgrade.sh | 41 ++++++++++++++++++ .../standard/usr/bin/mynode_reinstall_app.sh | 4 ++ .../var/www/mynode/templates/settings.html | 1 + setup/setup_device.sh | 42 +++++++++++++++++++ 10 files changed, 108 insertions(+), 10 deletions(-) create mode 100644 rootfs/standard/etc/rsyslog.d/loopd.conf rename rootfs/standard/etc/systemd/system/{lnd_admin.service => loopd.service} (51%) diff --git a/CHANGELOG b/CHANGELOG index 63f8ffb7..11d7f01a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +=== v0.1.87 === +- Roll back tor update +- Add Lightning Loop v0.4.0 +- Improve mempoolspace consistency + === v0.1.86 === - Upgrade tor to v4.2.5 - Fix boot issue for VMs that don't have USB diff --git a/rootfs/standard/etc/logrotate.d/rsyslog b/rootfs/standard/etc/logrotate.d/rsyslog index 3aaf0b3e..b7b1cb71 100644 --- a/rootfs/standard/etc/logrotate.d/rsyslog +++ b/rootfs/standard/etc/logrotate.d/rsyslog @@ -3,6 +3,7 @@ /var/log/flask /var/log/lndhub.log /var/log/lnd.log +/var/log/loopd.log /var/log/lnd_backup.log /var/log/lnd_admin.log /var/log/mynode.log diff --git a/rootfs/standard/etc/rsyslog.d/loopd.conf b/rootfs/standard/etc/rsyslog.d/loopd.conf new file mode 100644 index 00000000..c9a7a4a4 --- /dev/null +++ b/rootfs/standard/etc/rsyslog.d/loopd.conf @@ -0,0 +1,2 @@ +if $programname == 'loopd' then /var/log/loopd.log +& stop \ No newline at end of file diff --git a/rootfs/standard/etc/systemd/system/lnd_admin.service b/rootfs/standard/etc/systemd/system/loopd.service similarity index 51% rename from rootfs/standard/etc/systemd/system/lnd_admin.service rename to rootfs/standard/etc/systemd/system/loopd.service index ac0cfc83..c6fe234a 100644 --- a/rootfs/standard/etc/systemd/system/lnd_admin.service +++ b/rootfs/standard/etc/systemd/system/loopd.service @@ -1,26 +1,26 @@ -# LND Admin service -# /etc/systemd/system/admin_admin.service +# loopd service +# /etc/systemd/system/loopd.service [Unit] -Description=LND Admin -Wants=bitcoind.service -After=bitcoind.service +Description=loopd +Wants=lnd.service +After=lnd.service [Service] ExecStartPre=/usr/bin/wait_on_lnd.sh -WorkingDirectory=/opt/mynode/lnd-admin -ExecStart=/usr/bin/npm start +ExecStart=loopd User=bitcoin Group=bitcoin Type=simple +KillMode=process LimitNOFILE=128000 TimeoutSec=240 Restart=always RestartSec=60 StandardOutput=syslog StandardError=syslog -SyslogIdentifier=lnd_admin +SyslogIdentifier=loopd [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/rootfs/standard/usr/bin/mynode_docker_images.sh b/rootfs/standard/usr/bin/mynode_docker_images.sh index f5fa072c..a0e2f633 100755 --- a/rootfs/standard/usr/bin/mynode_docker_images.sh +++ b/rootfs/standard/usr/bin/mynode_docker_images.sh @@ -28,6 +28,8 @@ while [ 1 ]; do CURRENT=$(cat $WEBSSH2_UPGRADE_URL_FILE) fi if [ "$CURRENT" != "$WEBSSH2_UPGRADE_URL" ]; then + docker rmi webssh2 || true + cd /opt/mynode rm -rf webssh2 wget $WEBSSH2_UPGRADE_URL -O webssh2.tar.gz diff --git a/rootfs/standard/usr/bin/mynode_lnd_admin_files.sh b/rootfs/standard/usr/bin/mynode_lnd_admin_files.sh index eafd27ad..286fbec7 100755 --- a/rootfs/standard/usr/bin/mynode_lnd_admin_files.sh +++ b/rootfs/standard/usr/bin/mynode_lnd_admin_files.sh @@ -26,12 +26,12 @@ while true; do # Copy LND files to admin folder cp -f $LND_TLS_CERT_FILE /home/admin/.lnd/ - cp -f $LND_ADMIN_MACAROON_FILE /home/admin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon + cp -f /mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/*.macaroon /home/admin/.lnd/data/chain/bitcoin/mainnet/ chown -R admin:admin /home/admin/.lnd/ echo "Updated admin copy of LND files!" # Wait for changes - inotifywait -e modify -e create -e delete $LND_TLS_CERT_FILE $LND_ADMIN_MACAROON_FILE + inotifywait -e modify -e create -e delete $LND_TLS_CERT_FILE /mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/*.macaroon done # Should never exit diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index 3afad36a..56c01069 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -50,6 +50,7 @@ curl https://keybase.io/roasbeef/pgp_keys.asc | gpg --import curl https://raw.githubusercontent.com/JoinMarket-Org/joinmarket-clientserver/master/pubkeys/AdamGibson.asc | gpg --import gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 01EA5486DE18A882D4C2684590C8019E36C2E964 curl https://keybase.io/suheb/pgp_keys.asc | gpg --import +gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys DE23E73BFA8A0AD5587D2FCDE80D2F3F311FD87E #loopd set -e # Install docker @@ -162,6 +163,45 @@ if [ "$CURRENT" != "$LND_UPGRADE_URL" ]; then fi fi +# Upgrade Loopd +echo "Upgrading loopd..." +LOOP_VERSION="v0.4.0-beta" +LOOP_ARCH="loop-linux-armv7" +if [ $IS_X86 = 1 ]; then + LOOP_ARCH="loop-linux-amd64" +fi +LOOP_UPGRADE_URL=https://github.com/lightninglabs/loop/releases/download/$LOOP_VERSION/$LOOP_ARCH-$LOOP_VERSION.tar.gz +LOOP_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.loop_url +LOOP_UPGRADE_MANIFEST_URL=https://github.com/lightninglabs/loop/releases/download/$LOOP_VERSION/manifest-$LOOP_VERSION.txt +LOOP_UPGRADE_MANIFEST_SIG_URL=https://github.com/lightninglabs/loop/releases/download/$LOOP_VERSION/manifest-$LOOP_VERSION.txt.sig +CURRENT="" +if [ -f $LOOP_UPGRADE_URL_FILE ]; then + CURRENT=$(cat $LOOP_UPGRADE_URL_FILE) +fi +if [ "$CURRENT" != "$LOOP_UPGRADE_URL" ]; then + # Download and install Loop + rm -rf /opt/download + mkdir -p /opt/download + cd /opt/download + + wget $LOOP_UPGRADE_URL + wget $LOOP_UPGRADE_MANIFEST_URL + wget $LOOP_UPGRADE_MANIFEST_SIG_URL + + gpg --verify manifest-*.txt.sig + if [ $? == 0 ]; then + # Install Loop + tar -xzf loop-*.tar.gz + mv $LOOP_ARCH-$LOOP_VERSION loop + install -m 0755 -o root -g root -t /usr/local/bin loop/* + + # Mark current version + echo $LOOP_UPGRADE_URL > $LOOP_UPGRADE_URL_FILE + else + echo "ERROR UPGRADING LND - GPG FAILED" + fi +fi + # Install LndHub LNDHUB_VERSION="v1.1.3" LNDHUB_UPGRADE_URL=https://github.com/BlueWallet/LndHub/archive/${LNDHUB_VERSION}.tar.gz @@ -388,6 +428,7 @@ systemctl enable glances systemctl enable netdata systemctl enable webssh2 systemctl enable tor +systemctl enable loopd # Disable any old services systemctl disable hitch diff --git a/rootfs/standard/usr/bin/mynode_reinstall_app.sh b/rootfs/standard/usr/bin/mynode_reinstall_app.sh index b7019925..f4d7bf6d 100755 --- a/rootfs/standard/usr/bin/mynode_reinstall_app.sh +++ b/rootfs/standard/usr/bin/mynode_reinstall_app.sh @@ -17,6 +17,8 @@ if [ "$APP" = "bitcoin" ]; then rm -f /home/bitcoin/.mynode/.btc_url elif [ "$APP" = "lnd" ]; then rm -f /home/bitcoin/.mynode/.lnd_url +elif [ "$APP" = "loopd" ]; then + rm -f /home/bitcoin/.mynode/.loop_url elif [ "$APP" = "lndhub" ]; then rm -f /home/bitcoin/.mynode/.lndhub_url elif [ "$APP" = "rtl" ]; then @@ -35,6 +37,8 @@ elif [ "$APP" = "lndconnect" ]; then rm -f /home/bitcoin/.mynode/.lndconnect_url elif [ "$APP" = "webssh2" ]; then rm -f /mnt/hdd/mynode/settings/webssh2_url + systemctl stop webssh2 + docker rmi webssh2 else echo "UNKNOWN APP: $APP" exit 1 diff --git a/rootfs/standard/var/www/mynode/templates/settings.html b/rootfs/standard/var/www/mynode/templates/settings.html index 42fb1b2f..63dd33bf 100644 --- a/rootfs/standard/var/www/mynode/templates/settings.html +++ b/rootfs/standard/var/www/mynode/templates/settings.html @@ -817,6 +817,7 @@ + diff --git a/setup/setup_device.sh b/setup/setup_device.sh index 17160128..ebecbb74 100755 --- a/setup/setup_device.sh +++ b/setup/setup_device.sh @@ -126,6 +126,7 @@ curl https://keybase.io/roasbeef/pgp_keys.asc | gpg --import curl https://raw.githubusercontent.com/JoinMarket-Org/joinmarket-clientserver/master/pubkeys/AdamGibson.asc | gpg --import gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 01EA5486DE18A882D4C2684590C8019E36C2E964 curl https://keybase.io/suheb/pgp_keys.asc | gpg --import +gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys DE23E73BFA8A0AD5587D2FCDE80D2F3F311FD87E #loopd # Update python3 to 3.7.X PYTHON3_VERSION=$(python3 --version) @@ -276,6 +277,46 @@ if [ "$CURRENT" != "$LND_UPGRADE_URL" ]; then fi cd ~ +# Install Loopd +echo "Upgrading loopd..." +LOOP_VERSION="v0.4.0-beta" +LOOP_ARCH="loop-linux-armv7" +if [ $IS_X86 = 1 ]; then + LOOP_ARCH="loop-linux-amd64" +fi +LOOP_UPGRADE_URL=https://github.com/lightninglabs/loop/releases/download/$LOOP_VERSION/$LOOP_ARCH-$LOOP_VERSION.tar.gz +LOOP_UPGRADE_URL_FILE=/home/bitcoin/.mynode/.loop_url +LOOP_UPGRADE_MANIFEST_URL=https://github.com/lightninglabs/loop/releases/download/$LOOP_VERSION/manifest-$LOOP_VERSION.txt +LOOP_UPGRADE_MANIFEST_SIG_URL=https://github.com/lightninglabs/loop/releases/download/$LOOP_VERSION/manifest-$LOOP_VERSION.txt.sig +CURRENT="" +if [ -f $LOOP_UPGRADE_URL_FILE ]; then + CURRENT=$(cat $LOOP_UPGRADE_URL_FILE) +fi +if [ "$CURRENT" != "$LOOP_UPGRADE_URL" ]; then + # Download and install Loop + rm -rf /opt/download + mkdir -p /opt/download + cd /opt/download + + wget $LOOP_UPGRADE_URL + wget $LOOP_UPGRADE_MANIFEST_URL + wget $LOOP_UPGRADE_MANIFEST_SIG_URL + + gpg --verify manifest-*.txt.sig + if [ $? == 0 ]; then + # Install Loop + tar -xzf loop-*.tar.gz + mv $LOOP_ARCH-$LOOP_VERSION loop + install -m 0755 -o root -g root -t /usr/local/bin loop/* + + # Mark current version + echo $LOOP_UPGRADE_URL > $LOOP_UPGRADE_URL_FILE + else + echo "ERROR UPGRADING LND - GPG FAILED" + fi +fi + + # Setup "install" location for some apps mkdir -p /opt/mynode chown -R bitcoin:bitcoin /opt/mynode @@ -495,6 +536,7 @@ systemctl enable www systemctl enable drive_check systemctl enable bitcoind systemctl enable lnd +systemctl enable loopd systemctl enable lnd_unlock systemctl enable lnd_backup systemctl enable lnd_admin_files