From b8f6ac9d0a55a60e29141fe1abbfef0e4fd4bc5f Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Sat, 8 May 2021 14:54:20 -0500 Subject: [PATCH] Add ability to uninstall apps (beta) --- .../standard/usr/bin/mynode_post_upgrade.sh | 832 +++++++++--------- .../standard/usr/bin/mynode_uninstall_app.sh | 4 +- .../usr/share/mynode/mynode_functions.sh | 18 + .../var/www/mynode/application_info.py | 91 ++ rootfs/standard/var/www/mynode/device_info.py | 55 -- rootfs/standard/var/www/mynode/settings.py | 21 + .../var/www/mynode/static/css/mynode.css | 14 + .../var/www/mynode/templates/manage_apps.html | 46 +- 8 files changed, 608 insertions(+), 473 deletions(-) create mode 100644 rootfs/standard/usr/share/mynode/mynode_functions.sh diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index 0b2324e8..63b76df2 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -1,6 +1,7 @@ #!/bin/bash source /usr/share/mynode/mynode_config.sh +source /usr/share/mynode/mynode_functions.sh source /usr/share/mynode/mynode_app_versions.sh set -x @@ -15,6 +16,12 @@ echo "upgrading" > $MYNODE_STATUS_FILE # Shut down main services to save memory and CPU /usr/bin/mynode_stop_critical_services.sh +# Check if upgrades use tor +TORIFY="" +if [ -f /mnt/hdd/mynode/settings/torify_apt_get ]; then + TORIFY="torify" +fi + # Delete ramlog to prevent ram issues (remake necessary folders) rm -rf /var/log/* mkdir -p /var/log/nginx @@ -23,171 +30,169 @@ if [ $IS_RASPI = 1 ]; then log2ram stop || true fi -# Create any necessary users -useradd -m -s /bin/bash joinmarket || true +# Skip base upgrades if we are doing an app install / uninstall +if ! skip_base_upgrades ; then -# Setup bitcoin user folders -mkdir -p /home/bitcoin/.mynode/ -chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ + # Create any necessary users + useradd -m -s /bin/bash joinmarket || true -# User updates and settings -adduser admin bitcoin -grep "joinmarket" /etc/sudoers || (echo 'joinmarket ALL=(ALL) NOPASSWD:ALL' | EDITOR='tee -a' visudo) + # Setup bitcoin user folders + mkdir -p /home/bitcoin/.mynode/ + chown -R bitcoin:bitcoin /home/bitcoin/.mynode/ + + # User updates and settings + adduser admin bitcoin + grep "joinmarket" /etc/sudoers || (echo 'joinmarket ALL=(ALL) NOPASSWD:ALL' | EDITOR='tee -a' visudo) + + # Migrate from version file to version+install combo + /usr/bin/mynode_migrate_version_files.sh + + + # Stop and disable any old services + systemctl disable https || true + systemctl stop https || true + systemctl disable tls_proxy || true + systemctl stop tls_proxy || true + + # Create dhparam.pem (do before dpkg configure since its needed for nginx) + /usr/bin/mynode_gen_dhparam.sh + + + # Check if any dpkg installs have failed and correct + dpkg --configure -a + + + # Add sources + apt-get -y install apt-transport-https + DEBIAN_VERSION=$(lsb_release -c | awk '{ print $2 }') + # Tor + grep -qxF "deb https://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" /etc/apt/sources.list || echo "deb https://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" >> /etc/apt/sources.list + grep -qxF "deb-src https://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" /etc/apt/sources.list || echo "deb-src https://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" >> /etc/apt/sources.list + # Raspbian mirrors + #if [ $IS_RASPI = 1 ]; then + # grep -qxF "deb http://plug-mirror.rcac.purdue.edu/raspbian/ ${DEBIAN_VERSION} main" /etc/apt/sources.list || echo "deb http://plug-mirror.rcac.purdue.edu/raspbian/ ${DEBIAN_VERSION} main" >> /etc/apt/sources.list + # grep -qxF "deb http://mirrors.ocf.berkeley.edu/raspbian/raspbian ${DEBIAN_VERSION} main" /etc/apt/sources.list || echo "deb http://mirrors.ocf.berkeley.edu/raspbian/raspbian ${DEBIAN_VERSION} main" >> /etc/apt/sources.list + #fi + + # Import Keys + set +e + curl https://keybase.io/roasbeef/pgp_keys.asc | gpg --import + curl https://keybase.io/bitconner/pgp_keys.asc | gpg --import + curl https://keybase.io/guggero/pgp_keys.asc | gpg --import # Pool + 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 + curl https://samouraiwallet.com/pgp.txt | gpg --import # two keys from Samourai team + gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys DE23E73BFA8A0AD5587D2FCDE80D2F3F311FD87E #loopd + $TORIFY curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --import # tor + gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add - # tor + set -e + + + # Check for updates (might auto-install all updates later) + export DEBIAN_FRONTEND=noninteractive + $TORIFY apt-get update + + # Freeze any packages we don't want to update + if [ $IS_X86 = 1 ]; then + apt-mark hold grub* + fi + apt-mark hold redis-server + + # Upgrade packages + $TORIFY apt-get -y upgrade + + # Install any new software + $TORIFY apt-get -y install apt-transport-https + $TORIFY apt-get -y install fonts-dejavu + $TORIFY apt-get -y install pv sysstat network-manager unzip pkg-config libfreetype6-dev libpng-dev + $TORIFY apt-get -y install libatlas-base-dev libffi-dev libssl-dev glances python3-bottle + $TORIFY apt-get -y -qq install apt-transport-https ca-certificates + $TORIFY apt-get -y install libgmp-dev automake libtool libltdl-dev libltdl7 + $TORIFY apt-get -y install xorg chromium openbox lightdm openjdk-11-jre libevent-dev ncurses-dev + $TORIFY apt-get -y install libudev-dev libusb-1.0-0-dev python3-venv gunicorn sqlite3 libsqlite3-dev + $TORIFY apt-get -y install torsocks python3-requests libsystemd-dev libjpeg-dev zlib1g-dev psmisc + $TORIFY apt-get -y install hexyl libbz2-dev + + # Install device specific packages + if [ $IS_X86 = 1 ]; then + $TORIFY apt-get -y install cloud-init + fi + + # Make sure some software is removed + apt-get -y purge ntp # (conflicts with systemd-timedatectl) + apt-get -y purge chrony # (conflicts with systemd-timedatectl) + + + # Install nginx + mkdir -p /var/log/nginx || true + $TORIFY apt-get -y install nginx || true + # Install may fail, so we need to edit the default config file and reconfigure + rm -f /etc/nginx/modules-enabled/50-mod-* || true + echo "" > /etc/nginx/sites-available/default + dpkg --configure -a + + # Install any pip software + pip2 install tzupdate virtualenv pysocks redis qrcode image subprocess32 --no-cache-dir + + + # Update Python3 to 3.7.X + PYTHON_VERSION=3.7.8 + CURRENT_PYTHON3_VERSION=$(python3 --version) + if [[ "$CURRENT_PYTHON3_VERSION" != *"Python ${PYTHON_VERSION}"* ]]; then + mkdir -p /opt/download + cd /opt/download + rm -rf Python-* + + wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz -O python.tar.xz + tar xf python.tar.xz + + cd Python-* + ./configure + make -j4 + make install + cd ~ + else + echo "Python up to date" + fi + + + # Install any pip3 software + pip3 install --upgrade pip setuptools wheel + pip3 install gnureadline --no-cache-dir + pip3 install lndmanage==0.11.0 --no-cache-dir # Install lndmanage (keep up to date with LND) + pip3 install docker-compose --no-cache-dir + pip3 install pipenv --no-cache-dir + pip3 install bcrypt --no-cache-dir + pip3 install pysocks --no-cache-dir + pip3 install redis --no-cache-dir + pip3 install systemd --no-cache-dir + + + # Install Docker + if [ ! -f /usr/bin/docker ]; then + rm -f /tmp/docker_install.sh + wget https://get.docker.com -O /tmp/docker_install.sh + sed -i 's/sleep 20/sleep 1/' /tmp/docker_install.sh + /bin/bash /tmp/docker_install.sh + fi + + # Use systemd for managing Docker + rm -f /etc/init.d/docker + rm -f /etc/systemd/system/multi-user.target.wants/docker.service + systemctl -f enable docker.service + + groupadd docker || true + usermod -aG docker admin + usermod -aG docker bitcoin + usermod -aG docker root + + + # Install node packages -# Check if upgrades use tor -TORIFY="" -if [ -f /mnt/hdd/mynode/settings/torify_apt_get ]; then - TORIFY="torify" fi -# Migrate from version file to version+install combo -/usr/bin/mynode_migrate_version_files.sh - - -# Stop and disable any old services -systemctl disable https || true -systemctl stop https || true -systemctl disable tls_proxy || true -systemctl stop tls_proxy || true - -# Create dhparam.pem (do before dpkg configure since its needed for nginx) -/usr/bin/mynode_gen_dhparam.sh - - -# Check if any dpkg installs have failed and correct -dpkg --configure -a - - -# Add sources -apt-get -y install apt-transport-https -DEBIAN_VERSION=$(lsb_release -c | awk '{ print $2 }') -# Tor -grep -qxF "deb https://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" /etc/apt/sources.list || echo "deb https://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" >> /etc/apt/sources.list -grep -qxF "deb-src https://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" /etc/apt/sources.list || echo "deb-src https://deb.torproject.org/torproject.org ${DEBIAN_VERSION} main" >> /etc/apt/sources.list -# Raspbian mirrors -#if [ $IS_RASPI = 1 ]; then -# grep -qxF "deb http://plug-mirror.rcac.purdue.edu/raspbian/ ${DEBIAN_VERSION} main" /etc/apt/sources.list || echo "deb http://plug-mirror.rcac.purdue.edu/raspbian/ ${DEBIAN_VERSION} main" >> /etc/apt/sources.list -# grep -qxF "deb http://mirrors.ocf.berkeley.edu/raspbian/raspbian ${DEBIAN_VERSION} main" /etc/apt/sources.list || echo "deb http://mirrors.ocf.berkeley.edu/raspbian/raspbian ${DEBIAN_VERSION} main" >> /etc/apt/sources.list -#fi - -# Import Keys -set +e -curl https://keybase.io/roasbeef/pgp_keys.asc | gpg --import -curl https://keybase.io/bitconner/pgp_keys.asc | gpg --import -curl https://keybase.io/guggero/pgp_keys.asc | gpg --import # Pool -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 -curl https://samouraiwallet.com/pgp.txt | gpg --import # two keys from Samourai team -gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys DE23E73BFA8A0AD5587D2FCDE80D2F3F311FD87E #loopd -$TORIFY curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --import # tor -gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add - # tor -set -e - - -# Check for updates (might auto-install all updates later) -export DEBIAN_FRONTEND=noninteractive -$TORIFY apt-get update - -# Freeze any packages we don't want to update -if [ $IS_X86 = 1 ]; then - apt-mark hold grub* -fi -apt-mark hold redis-server - -# Upgrade packages -$TORIFY apt-get -y upgrade - -# Install any new software -$TORIFY apt-get -y install apt-transport-https -$TORIFY apt-get -y install fonts-dejavu -$TORIFY apt-get -y install pv sysstat network-manager unzip pkg-config libfreetype6-dev libpng-dev -$TORIFY apt-get -y install libatlas-base-dev libffi-dev libssl-dev glances python3-bottle -$TORIFY apt-get -y -qq install apt-transport-https ca-certificates -$TORIFY apt-get -y install libgmp-dev automake libtool libltdl-dev libltdl7 -$TORIFY apt-get -y install xorg chromium openbox lightdm openjdk-11-jre libevent-dev ncurses-dev -$TORIFY apt-get -y install libudev-dev libusb-1.0-0-dev python3-venv gunicorn sqlite3 libsqlite3-dev -$TORIFY apt-get -y install torsocks python3-requests libsystemd-dev libjpeg-dev zlib1g-dev psmisc -$TORIFY apt-get -y install hexyl libbz2-dev - -# Install device specific packages -if [ $IS_X86 = 1 ]; then - $TORIFY apt-get -y install cloud-init -fi - -# Make sure some software is removed -apt-get -y purge ntp # (conflicts with systemd-timedatectl) -apt-get -y purge chrony # (conflicts with systemd-timedatectl) - - -# Install nginx -mkdir -p /var/log/nginx || true -$TORIFY apt-get -y install nginx || true -# Install may fail, so we need to edit the default config file and reconfigure -rm -f /etc/nginx/modules-enabled/50-mod-* || true -echo "" > /etc/nginx/sites-available/default -dpkg --configure -a - -# Install any pip software -pip2 install tzupdate virtualenv pysocks redis qrcode image subprocess32 --no-cache-dir - - -# Update Python3 to 3.7.X -PYTHON_VERSION=3.7.8 -CURRENT_PYTHON3_VERSION=$(python3 --version) -if [[ "$CURRENT_PYTHON3_VERSION" != *"Python ${PYTHON_VERSION}"* ]]; then - mkdir -p /opt/download - cd /opt/download - rm -rf Python-* - - wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz -O python.tar.xz - tar xf python.tar.xz - - cd Python-* - ./configure - make -j4 - make install - cd ~ -else - echo "Python up to date" -fi - - -# Install any pip3 software -pip3 install --upgrade pip setuptools wheel -pip3 install gnureadline --no-cache-dir -pip3 install lndmanage==0.11.0 --no-cache-dir # Install lndmanage (keep up to date with LND) -pip3 install docker-compose --no-cache-dir -pip3 install pipenv --no-cache-dir -pip3 install bcrypt --no-cache-dir -pip3 install pysocks --no-cache-dir -pip3 install redis --no-cache-dir -pip3 install systemd --no-cache-dir - - -# Install Docker -if [ ! -f /usr/bin/docker ]; then - rm -f /tmp/docker_install.sh - wget https://get.docker.com -O /tmp/docker_install.sh - sed -i 's/sleep 20/sleep 1/' /tmp/docker_install.sh - /bin/bash /tmp/docker_install.sh -fi - -# Use systemd for managing Docker -rm -f /etc/init.d/docker -rm -f /etc/systemd/system/multi-user.target.wants/docker.service -systemctl -f enable docker.service - -groupadd docker || true -usermod -aG docker admin -usermod -aG docker bitcoin -usermod -aG docker root - - -# Install node packages - - # Upgrade BTC echo "Upgrading BTC..." ARCH="UNKNOWN" @@ -391,53 +396,57 @@ if [ "$CURRENT" != "$LIT_VERSION" ]; then fi # Install LndHub -LNDHUB_UPGRADE_URL=https://github.com/BlueWallet/LndHub/archive/$LNDHUB_VERSION.tar.gz -CURRENT="" -if [ -f $LNDHUB_VERSION_FILE ]; then - CURRENT=$(cat $LNDHUB_VERSION_FILE) -fi -if [ "$CURRENT" != "$LNDHUB_VERSION" ]; then - cd /opt/mynode - rm -rf LndHub +if should_install_app "lndhub" ; then + LNDHUB_UPGRADE_URL=https://github.com/BlueWallet/LndHub/archive/$LNDHUB_VERSION.tar.gz + CURRENT="" + if [ -f $LNDHUB_VERSION_FILE ]; then + CURRENT=$(cat $LNDHUB_VERSION_FILE) + fi + if [ "$CURRENT" != "$LNDHUB_VERSION" ]; then + cd /opt/mynode + rm -rf LndHub - wget $LNDHUB_UPGRADE_URL - tar -xzf ${LNDHUB_VERSION}.tar.gz - rm -f ${LNDHUB_VERSION}.tar.gz - mv LndHub-* LndHub - chown -R bitcoin:bitcoin LndHub + wget $LNDHUB_UPGRADE_URL + tar -xzf ${LNDHUB_VERSION}.tar.gz + rm -f ${LNDHUB_VERSION}.tar.gz + mv LndHub-* LndHub + chown -R bitcoin:bitcoin LndHub - cd LndHub - sudo -u bitcoin npm install --only=production - sudo -u bitcoin ln -s /home/bitcoin/.lnd/tls.cert tls.cert - sudo -u bitcoin ln -s /home/bitcoin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon admin.macaroon - echo $LNDHUB_VERSION > $LNDHUB_VERSION_FILE + cd LndHub + sudo -u bitcoin npm install --only=production + sudo -u bitcoin ln -s /home/bitcoin/.lnd/tls.cert tls.cert + sudo -u bitcoin ln -s /home/bitcoin/.lnd/data/chain/bitcoin/mainnet/admin.macaroon admin.macaroon + echo $LNDHUB_VERSION > $LNDHUB_VERSION_FILE + fi + cd ~ fi -cd ~ # Install Caravan -CARAVAN_UPGRADE_URL=https://github.com/unchained-capital/caravan/archive/$CARAVAN_VERSION.tar.gz -CURRENT="" -if [ -f $CARAVAN_VERSION_FILE ]; then - CURRENT=$(cat $CARAVAN_VERSION_FILE) -fi -if [ "$CURRENT" != "$CARAVAN_VERSION" ] || [ ! -f $CARAVAN_SETTINGS_UPDATE_FILE ]; then - cd /opt/mynode - rm -rf caravan +if should_install_app "caravan" ; then + CARAVAN_UPGRADE_URL=https://github.com/unchained-capital/caravan/archive/$CARAVAN_VERSION.tar.gz + CURRENT="" + if [ -f $CARAVAN_VERSION_FILE ]; then + CURRENT=$(cat $CARAVAN_VERSION_FILE) + fi + if [ "$CURRENT" != "$CARAVAN_VERSION" ] || [ ! -f $CARAVAN_SETTINGS_UPDATE_FILE ]; then + cd /opt/mynode + rm -rf caravan - rm -f caravan.tar.gz - wget $CARAVAN_UPGRADE_URL -O caravan.tar.gz - tar -xzf caravan.tar.gz - rm -f caravan.tar.gz - mv caravan-* caravan - chown -R bitcoin:bitcoin caravan + rm -f caravan.tar.gz + wget $CARAVAN_UPGRADE_URL -O caravan.tar.gz + tar -xzf caravan.tar.gz + rm -f caravan.tar.gz + mv caravan-* caravan + chown -R bitcoin:bitcoin caravan - cd caravan - sudo -u bitcoin npm install --only=production - echo $CARAVAN_VERSION > $CARAVAN_VERSION_FILE - touch $CARAVAN_SETTINGS_UPDATE_FILE + cd caravan + sudo -u bitcoin npm install --only=production + echo $CARAVAN_VERSION > $CARAVAN_VERSION_FILE + touch $CARAVAN_SETTINGS_UPDATE_FILE + fi + cd ~ fi -cd ~ # Install cors proxy (my fork) @@ -504,227 +513,242 @@ if [ ! -f /usr/include/secp256k1_ecdh.h ]; then fi # Upgrade JoinMarket -echo "Upgrading JoinMarket..." # Old -if [ $IS_RASPI = 1 ] || [ $IS_X86 = 1 ]; then - JOINMARKET_UPGRADE_URL=https://github.com/JoinMarket-Org/joinmarket-clientserver/archive/$JOINMARKET_VERSION.tar.gz - CURRENT="" - if [ -f $JOINMARKET_VERSION_FILE ]; then - CURRENT=$(cat $JOINMARKET_VERSION_FILE) - fi - if [ "$CURRENT" != "$JOINMARKET_VERSION" ]; then - # Download and build JoinMarket - cd /opt/mynode - - # Backup old version in case config / wallet was stored within folder - if [ ! -d /opt/mynode/jm_backup ] && [ -d /opt/mynode/joinmarket-clientserver ]; then - cp -R /opt/mynode/joinmarket-clientserver /opt/mynode/jm_backup - chown -R bitcoin:bitcoin /opt/mynode/jm_backup +if should_install_app "joinmarket" ; then + echo "Upgrading JoinMarket..." # Old + if [ $IS_RASPI = 1 ] || [ $IS_X86 = 1 ]; then + JOINMARKET_UPGRADE_URL=https://github.com/JoinMarket-Org/joinmarket-clientserver/archive/$JOINMARKET_VERSION.tar.gz + CURRENT="" + if [ -f $JOINMARKET_VERSION_FILE ]; then + CURRENT=$(cat $JOINMARKET_VERSION_FILE) fi + if [ "$CURRENT" != "$JOINMARKET_VERSION" ]; then + # Download and build JoinMarket + cd /opt/mynode - rm -rf joinmarket-clientserver + # Backup old version in case config / wallet was stored within folder + if [ ! -d /opt/mynode/jm_backup ] && [ -d /opt/mynode/joinmarket-clientserver ]; then + cp -R /opt/mynode/joinmarket-clientserver /opt/mynode/jm_backup + chown -R bitcoin:bitcoin /opt/mynode/jm_backup + fi - sudo -u bitcoin wget $JOINMARKET_UPGRADE_URL -O joinmarket.tar.gz - sudo -u bitcoin tar -xvf joinmarket.tar.gz - sudo -u bitcoin rm joinmarket.tar.gz - mv joinmarket-clientserver-* joinmarket-clientserver + rm -rf joinmarket-clientserver - cd joinmarket-clientserver + sudo -u bitcoin wget $JOINMARKET_UPGRADE_URL -O joinmarket.tar.gz + sudo -u bitcoin tar -xvf joinmarket.tar.gz + sudo -u bitcoin rm joinmarket.tar.gz + mv joinmarket-clientserver-* joinmarket-clientserver - # Apply Patch to fix cryptography dependency - #sed -i "s/'txtorcon', 'pyopenssl'/'txtorcon', 'cryptography==3.3.2', 'pyopenssl'/g" jmdaemon/setup.py || true + cd joinmarket-clientserver - # Install - yes | ./install.sh --without-qt + # Apply Patch to fix cryptography dependency + #sed -i "s/'txtorcon', 'pyopenssl'/'txtorcon', 'cryptography==3.3.2', 'pyopenssl'/g" jmdaemon/setup.py || true - echo $JOINMARKET_VERSION > $JOINMARKET_VERSION_FILE + # Install + yes | ./install.sh --without-qt + + echo $JOINMARKET_VERSION > $JOINMARKET_VERSION_FILE + fi fi fi echo "Upgrading JoinInBox..." -if [ $IS_RASPI = 1 ] || [ $IS_X86 = 1 ]; then - JOININBOX_UPGRADE_URL=https://github.com/openoms/joininbox/archive/$JOININBOX_VERSION.tar.gz - CURRENT="" - if [ -f $JOININBOX_VERSION_FILE ]; then - CURRENT=$(cat $JOININBOX_VERSION_FILE) - fi - if [ "$CURRENT" != "$JOININBOX_VERSION" ]; then - # Download and build JoinInBox - cd /home/joinmarket - - # Delete all non-hidden files - rm -rf * - rm -rf joininbox-* +if should_install_app "joininbox" ; then + if [ $IS_RASPI = 1 ] || [ $IS_X86 = 1 ]; then + JOININBOX_UPGRADE_URL=https://github.com/openoms/joininbox/archive/$JOININBOX_VERSION.tar.gz + CURRENT="" + if [ -f $JOININBOX_VERSION_FILE ]; then + CURRENT=$(cat $JOININBOX_VERSION_FILE) + fi + if [ "$CURRENT" != "$JOININBOX_VERSION" ]; then + # Download and build JoinInBox + cd /home/joinmarket + + # Delete all non-hidden files + rm -rf * + rm -rf joininbox-* - sudo -u joinmarket wget $JOININBOX_UPGRADE_URL -O joininbox.tar.gz - sudo -u joinmarket tar -xvf joininbox.tar.gz - sudo -u joinmarket rm joininbox.tar.gz - mv joininbox-* joininbox + sudo -u joinmarket wget $JOININBOX_UPGRADE_URL -O joininbox.tar.gz + sudo -u joinmarket tar -xvf joininbox.tar.gz + sudo -u joinmarket rm joininbox.tar.gz + mv joininbox-* joininbox - chmod -R +x ./joininbox/ - sudo -u joinmarket cp -rf ./joininbox/scripts/* . + chmod -R +x ./joininbox/ + sudo -u joinmarket cp -rf ./joininbox/scripts/* . - # Apply patches - echo "" > set.password.sh - echo "" > standalone/expand.rootfs.sh - sudo -u joinmarket cp /usr/share/joininbox/menu.update.sh /home/joinmarket/menu.update.sh - sudo -u joinmarket sed -i "s|/home/joinmarket/menu.config.sh|echo 'mynode skip config'|g" /home/joinmarket/start.joininbox.sh + # Apply patches + echo "" > set.password.sh + echo "" > standalone/expand.rootfs.sh + sudo -u joinmarket cp /usr/share/joininbox/menu.update.sh /home/joinmarket/menu.update.sh + sudo -u joinmarket sed -i "s|/home/joinmarket/menu.config.sh|echo 'mynode skip config'|g" /home/joinmarket/start.joininbox.sh - # Install - sudo -u joinmarket bash -c "cd /home/joinmarket/; ./install.joinmarket.sh install" || true + # Install + sudo -u joinmarket bash -c "cd /home/joinmarket/; ./install.joinmarket.sh install" || true - echo $JOININBOX_VERSION > $JOININBOX_VERSION_FILE + echo $JOININBOX_VERSION > $JOININBOX_VERSION_FILE + fi fi fi - # Install Whirlpool -WHIRLPOOL_UPGRADE_URL=https://code.samourai.io/whirlpool/whirlpool-client-cli/uploads/$WHIRLPOOL_UPLOAD_FILE_ID/whirlpool-client-cli-$WHIRLPOOL_VERSION-run.jar -WHIRLPOOL_SIG_URL=https://code.samourai.io/whirlpool/whirlpool-client-cli/uploads/$WHIRLPOOL_UPLOAD_SIG_ID/whirlpool-client-cli-$WHIRLPOOL_VERSION-run.jar.sig.asc -CURRENT="" -if [ -f $WHIRLPOOL_VERSION_FILE ]; then - CURRENT=$(cat $WHIRLPOOL_VERSION_FILE) -fi -if [ "$CURRENT" != "$WHIRLPOOL_VERSION" ]; then - sudo -u bitcoin mkdir -p /opt/mynode/whirlpool - cd /opt/mynode/whirlpool - sudo rm -rf *.jar - sudo -u bitcoin wget -O whirlpool.jar $WHIRLPOOL_UPGRADE_URL +if should_install_app "whirlpool" ; then + WHIRLPOOL_UPGRADE_URL=https://code.samourai.io/whirlpool/whirlpool-client-cli/uploads/$WHIRLPOOL_UPLOAD_FILE_ID/whirlpool-client-cli-$WHIRLPOOL_VERSION-run.jar + WHIRLPOOL_SIG_URL=https://code.samourai.io/whirlpool/whirlpool-client-cli/uploads/$WHIRLPOOL_UPLOAD_SIG_ID/whirlpool-client-cli-$WHIRLPOOL_VERSION-run.jar.sig.asc + CURRENT="" + if [ -f $WHIRLPOOL_VERSION_FILE ]; then + CURRENT=$(cat $WHIRLPOOL_VERSION_FILE) + fi + if [ "$CURRENT" != "$WHIRLPOOL_VERSION" ]; then + sudo -u bitcoin mkdir -p /opt/mynode/whirlpool + cd /opt/mynode/whirlpool + sudo rm -rf *.jar + sudo -u bitcoin wget -O whirlpool.jar $WHIRLPOOL_UPGRADE_URL - wget -O whirlpool.asc $WHIRLPOOL_SIG_URL - gpg --verify whirlpool.asc + wget -O whirlpool.asc $WHIRLPOOL_SIG_URL + gpg --verify whirlpool.asc - echo $WHIRLPOOL_VERSION > $WHIRLPOOL_VERSION_FILE + echo $WHIRLPOOL_VERSION > $WHIRLPOOL_VERSION_FILE + fi fi # Upgrade RTL -RTL_UPGRADE_URL=https://github.com/Ride-The-Lightning/RTL/archive/$RTL_VERSION.tar.gz -RTL_UPGRADE_ASC_URL=https://github.com/Ride-The-Lightning/RTL/releases/download/$RTL_VERSION/$RTL_VERSION.tar.gz.asc -CURRENT="" -if [ -f $RTL_VERSION_FILE ]; then - CURRENT=$(cat $RTL_VERSION_FILE) -fi -if [ "$CURRENT" != "$RTL_VERSION" ]; then - cd /opt/mynode - rm -rf RTL +if should_install_app "rtl" ; then + RTL_UPGRADE_URL=https://github.com/Ride-The-Lightning/RTL/archive/$RTL_VERSION.tar.gz + RTL_UPGRADE_ASC_URL=https://github.com/Ride-The-Lightning/RTL/releases/download/$RTL_VERSION/$RTL_VERSION.tar.gz.asc + CURRENT="" + if [ -f $RTL_VERSION_FILE ]; then + CURRENT=$(cat $RTL_VERSION_FILE) + fi + if [ "$CURRENT" != "$RTL_VERSION" ]; then + cd /opt/mynode + rm -rf RTL - sudo -u bitcoin wget $RTL_UPGRADE_URL -O RTL.tar.gz - #sudo -u bitcoin wget $RTL_UPGRADE_ASC_URL -O RTL.tar.gz.asc + 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 - #if [ $? == 0 ]; then - if [ true ]; then - sudo -u bitcoin tar -xvf RTL.tar.gz - sudo -u bitcoin rm RTL.tar.gz - sudo -u bitcoin mv RTL-* RTL - cd RTL - sudo -u bitcoin NG_CLI_ANALYTICS=false npm install --only=production + #gpg --verify RTL.tar.gz.asc RTL.tar.gz + #if [ $? == 0 ]; then + if [ true ]; then + sudo -u bitcoin tar -xvf RTL.tar.gz + sudo -u bitcoin rm RTL.tar.gz + sudo -u bitcoin mv RTL-* RTL + cd RTL + sudo -u bitcoin NG_CLI_ANALYTICS=false npm install --only=production - echo $RTL_VERSION > $RTL_VERSION_FILE - else - echo "ERROR UPGRADING RTL - GPG FAILED" + echo $RTL_VERSION > $RTL_VERSION_FILE + else + echo "ERROR UPGRADING RTL - GPG FAILED" + fi fi fi # Upgrade BTC RPC Explorer -BTCRPCEXPLORER_UPGRADE_URL=https://github.com/janoside/btc-rpc-explorer/archive/$BTCRPCEXPLORER_VERSION.tar.gz -CURRENT="" -if [ -f $BTCRPCEXPLORER_VERSION_FILE ]; then - CURRENT=$(cat $BTCRPCEXPLORER_VERSION_FILE) -fi -if [ "$CURRENT" != "$BTCRPCEXPLORER_VERSION" ]; then - cd /opt/mynode - rm -rf btc-rpc-explorer - sudo -u bitcoin wget $BTCRPCEXPLORER_UPGRADE_URL -O btc-rpc-explorer.tar.gz - sudo -u bitcoin tar -xvf btc-rpc-explorer.tar.gz - sudo -u bitcoin rm btc-rpc-explorer.tar.gz - sudo -u bitcoin mv btc-rpc-* btc-rpc-explorer - cd btc-rpc-explorer - sudo -u bitcoin npm install --only=production +if should_install_app "btcrpcexplorer" ; then + BTCRPCEXPLORER_UPGRADE_URL=https://github.com/janoside/btc-rpc-explorer/archive/$BTCRPCEXPLORER_VERSION.tar.gz + CURRENT="" + if [ -f $BTCRPCEXPLORER_VERSION_FILE ]; then + CURRENT=$(cat $BTCRPCEXPLORER_VERSION_FILE) + fi + if [ "$CURRENT" != "$BTCRPCEXPLORER_VERSION" ]; then + cd /opt/mynode + rm -rf btc-rpc-explorer + sudo -u bitcoin wget $BTCRPCEXPLORER_UPGRADE_URL -O btc-rpc-explorer.tar.gz + sudo -u bitcoin tar -xvf btc-rpc-explorer.tar.gz + sudo -u bitcoin rm btc-rpc-explorer.tar.gz + sudo -u bitcoin mv btc-rpc-* btc-rpc-explorer + cd btc-rpc-explorer + sudo -u bitcoin npm install --only=production - echo $BTCRPCEXPLORER_VERSION > $BTCRPCEXPLORER_VERSION_FILE + echo $BTCRPCEXPLORER_VERSION > $BTCRPCEXPLORER_VERSION_FILE + fi fi # Upgrade LNBits -# Find URL by going to https://github.com/lnbits/lnbits/releases and finding the exact commit for the mynode tag -LNBITS_UPGRADE_URL=https://github.com/lnbits/lnbits/archive/$LNBITS_VERSION.tar.gz -CURRENT="" -if [ -f $LNBITS_VERSION_FILE ]; then - CURRENT=$(cat $LNBITS_VERSION_FILE) -fi -if [ "$CURRENT" != "$LNBITS_VERSION" ]; then - cd /opt/mynode - rm -rf lnbits - sudo -u bitcoin wget $LNBITS_UPGRADE_URL -O lnbits.tar.gz - sudo -u bitcoin tar -xvf lnbits.tar.gz - sudo -u bitcoin rm lnbits.tar.gz - sudo -u bitcoin mv lnbits-* lnbits - cd lnbits +if should_install_app "lnbits" ; then + # Find URL by going to https://github.com/lnbits/lnbits/releases and finding the exact commit for the mynode tag + LNBITS_UPGRADE_URL=https://github.com/lnbits/lnbits/archive/$LNBITS_VERSION.tar.gz + CURRENT="" + if [ -f $LNBITS_VERSION_FILE ]; then + CURRENT=$(cat $LNBITS_VERSION_FILE) + fi + if [ "$CURRENT" != "$LNBITS_VERSION" ]; then + cd /opt/mynode + rm -rf lnbits + sudo -u bitcoin wget $LNBITS_UPGRADE_URL -O lnbits.tar.gz + sudo -u bitcoin tar -xvf lnbits.tar.gz + sudo -u bitcoin rm lnbits.tar.gz + sudo -u bitcoin mv lnbits-* lnbits + cd lnbits - # Copy over config file - cp /usr/share/mynode/lnbits.env /opt/mynode/lnbits/.env - chown bitcoin:bitcoin /opt/mynode/lnbits/.env + # Copy over config file + cp /usr/share/mynode/lnbits.env /opt/mynode/lnbits/.env + chown bitcoin:bitcoin /opt/mynode/lnbits/.env - # 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 + # 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 - echo $LNBITS_VERSION > $LNBITS_VERSION_FILE + echo $LNBITS_VERSION > $LNBITS_VERSION_FILE + fi fi # Upgrade Specter Desktop -CURRENT="" -if [ -f $SPECTER_VERSION_FILE ]; then - CURRENT=$(cat $SPECTER_VERSION_FILE) -fi -if [ "$CURRENT" != "$SPECTER_VERSION" ]; then - cd /opt/mynode - rm -rf specter - mkdir -p specter - chown -R bitcoin:bitcoin specter - cd specter - - # Make venv - if [ ! -d env ]; then - sudo -u bitcoin python3 -m venv env +if should_install_app "specter" ; then + CURRENT="" + if [ -f $SPECTER_VERSION_FILE ]; then + CURRENT=$(cat $SPECTER_VERSION_FILE) fi - source env/bin/activate - pip3 install ecdsa===0.13.3 - pip3 install cryptoadvance.specter===$SPECTER_VERSION --upgrade - deactivate + if [ "$CURRENT" != "$SPECTER_VERSION" ]; then + cd /opt/mynode + rm -rf specter + mkdir -p specter + chown -R bitcoin:bitcoin specter + cd specter - echo $SPECTER_VERSION > $SPECTER_VERSION_FILE + # Make venv + if [ ! -d env ]; then + sudo -u bitcoin python3 -m venv env + fi + source env/bin/activate + pip3 install ecdsa===0.13.3 + pip3 install cryptoadvance.specter===$SPECTER_VERSION --upgrade + deactivate + + echo $SPECTER_VERSION > $SPECTER_VERSION_FILE + fi fi # Upgrade Thunderhub -THUNDERHUB_UPGRADE_URL=https://github.com/apotdevin/thunderhub/archive/$THUNDERHUB_VERSION.tar.gz -CURRENT="" -if [ -f $THUNDERHUB_VERSION_FILE ]; then - CURRENT=$(cat $THUNDERHUB_VERSION_FILE) -fi -if [ "$CURRENT" != "$THUNDERHUB_VERSION" ]; then - cd /opt/mynode - rm -rf thunderhub - sudo -u bitcoin wget $THUNDERHUB_UPGRADE_URL -O thunderhub.tar.gz - sudo -u bitcoin tar -xvf thunderhub.tar.gz - sudo -u bitcoin rm thunderhub.tar.gz - sudo -u bitcoin mv thunderhub-* thunderhub - cd thunderhub +if should_install_app "thunderhub" ; then + THUNDERHUB_UPGRADE_URL=https://github.com/apotdevin/thunderhub/archive/$THUNDERHUB_VERSION.tar.gz + CURRENT="" + if [ -f $THUNDERHUB_VERSION_FILE ]; then + CURRENT=$(cat $THUNDERHUB_VERSION_FILE) + fi + if [ "$CURRENT" != "$THUNDERHUB_VERSION" ]; then + cd /opt/mynode + rm -rf thunderhub + sudo -u bitcoin wget $THUNDERHUB_UPGRADE_URL -O thunderhub.tar.gz + sudo -u bitcoin tar -xvf thunderhub.tar.gz + sudo -u bitcoin rm thunderhub.tar.gz + sudo -u bitcoin mv thunderhub-* thunderhub + cd thunderhub - sudo -u bitcoin npm install # --only=production # (can't build with only production) - sudo -u bitcoin npm run build - sudo -u bitcoin npx next telemetry disable + sudo -u bitcoin npm install # --only=production # (can't build with only production) + sudo -u bitcoin npm run build + sudo -u bitcoin npx next telemetry disable - # Setup symlink to service files - rm -f /opt/mynode/thunderhub/.env.local - sudo ln -s /mnt/hdd/mynode/thunderhub/.env.local /opt/mynode/thunderhub/.env.local + # Setup symlink to service files + rm -f /opt/mynode/thunderhub/.env.local + sudo ln -s /mnt/hdd/mynode/thunderhub/.env.local /opt/mynode/thunderhub/.env.local - echo $THUNDERHUB_VERSION > $THUNDERHUB_VERSION_FILE + echo $THUNDERHUB_VERSION > $THUNDERHUB_VERSION_FILE + fi fi @@ -767,53 +791,57 @@ fi # Upgrade CKbunker -CKBUNKER_UPGRADE_URL=https://github.com/Coldcard/ckbunker/archive/$CKBUNKER_VERSION.tar.gz -CURRENT="" -if [ -f $CKBUNKER_VERSION_FILE ]; then - CURRENT=$(cat $CKBUNKER_VERSION_FILE) -fi -if [ "$CURRENT" != "$CKBUNKER_VERSION" ]; then - cd /opt/mynode - rm -rf ckbunker - - sudo -u bitcoin wget $CKBUNKER_UPGRADE_URL -O ckbunker.tar.gz - sudo -u bitcoin tar -xvf ckbunker.tar.gz - sudo -u bitcoin rm ckbunker.tar.gz - sudo -u bitcoin mv ckbunker-* ckbunker - cd ckbunker - - # Make venv - if [ ! -d env ]; then - sudo -u bitcoin python3 -m venv env +if should_install_app "ckbunker" ; then + CKBUNKER_UPGRADE_URL=https://github.com/Coldcard/ckbunker/archive/$CKBUNKER_VERSION.tar.gz + CURRENT="" + if [ -f $CKBUNKER_VERSION_FILE ]; then + CURRENT=$(cat $CKBUNKER_VERSION_FILE) fi - source env/bin/activate - pip3 install -r requirements.txt - pip3 install --editable . - deactivate + if [ "$CURRENT" != "$CKBUNKER_VERSION" ]; then + cd /opt/mynode + rm -rf ckbunker - echo $CKBUNKER_VERSION > $CKBUNKER_VERSION_FILE + sudo -u bitcoin wget $CKBUNKER_UPGRADE_URL -O ckbunker.tar.gz + sudo -u bitcoin tar -xvf ckbunker.tar.gz + sudo -u bitcoin rm ckbunker.tar.gz + sudo -u bitcoin mv ckbunker-* ckbunker + cd ckbunker + + # Make venv + if [ ! -d env ]; then + sudo -u bitcoin python3 -m venv env + fi + source env/bin/activate + pip3 install -r requirements.txt + pip3 install --editable . + deactivate + + echo $CKBUNKER_VERSION > $CKBUNKER_VERSION_FILE + fi fi # Upgrade Sphinx Relay -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 +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 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 + sudo -u bitcoin npm install - echo $SPHINXRELAY_VERSION > $SPHINXRELAY_VERSION_FILE + echo $SPHINXRELAY_VERSION > $SPHINXRELAY_VERSION_FILE + fi fi diff --git a/rootfs/standard/usr/bin/mynode_uninstall_app.sh b/rootfs/standard/usr/bin/mynode_uninstall_app.sh index 74c66368..0f136bff 100755 --- a/rootfs/standard/usr/bin/mynode_uninstall_app.sh +++ b/rootfs/standard/usr/bin/mynode_uninstall_app.sh @@ -8,13 +8,11 @@ source /usr/share/mynode/mynode_app_versions.sh # Make sure we have an app argument if [ "$#" -ne 1 ]; then - echo "Usage: mynode_reinstall_app.sh " + echo "Usage: mynode_uninstall_app.sh " exit 1 fi APP="$1" -# Shut down main services to save memory and CPU and stop app being reinstalled -/usr/bin/mynode_stop_critical_services.sh # Delete the app's version file and install file rm -f /home/bitcoin/.mynode/${APP}_version || true diff --git a/rootfs/standard/usr/share/mynode/mynode_functions.sh b/rootfs/standard/usr/share/mynode/mynode_functions.sh new file mode 100644 index 00000000..4b2b7e75 --- /dev/null +++ b/rootfs/standard/usr/share/mynode/mynode_functions.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +function should_install_app { + if [ -f /home/bitcoin/.mynode/install_${1} ]; then + return 0 + fi + if [ -f /mnt/hdd/mynode/settings/install_${1} ]; then + return 0 + fi + return 1 +} + +function skip_base_upgrades { + if [ -f /tmp/skip_base_upgrades ]; then + return 0 + fi + return 1 +} \ No newline at end of file diff --git a/rootfs/standard/var/www/mynode/application_info.py b/rootfs/standard/var/www/mynode/application_info.py index 218429a4..020bbfe7 100644 --- a/rootfs/standard/var/www/mynode/application_info.py +++ b/rootfs/standard/var/www/mynode/application_info.py @@ -13,9 +13,82 @@ import os mynode_applications = None # Utility functions +def reinstall_app(app): + if not is_upgrade_running(): + mark_upgrade_started() + + # Clear app data + clear_application_cache() + + os.system("touch /tmp/skip_base_upgrades") + os.system("sync") + + # Reinstall + os.system("mkdir -p /home/admin/upgrade_logs") + file1 = "/home/admin/upgrade_logs/reinstall_{}.txt".format(app) + file2 = "/home/admin/upgrade_logs/upgrade_log_latest.txt" + cmd = "/usr/bin/mynode_reinstall_app.sh {} 2>&1 | tee {} {}".format(app,file1, file2) + subprocess.call(cmd, shell=True) + + # Sync + os.system("sync") + time.sleep(1) + + # Reboot + reboot_device() + +def uninstall_app(app): + # Make sure app is disabled + disable_service(app) + + # Clear app data + clear_application_cache() + + # Uninstall App + os.system("mkdir -p /home/admin/upgrade_logs") + file1 = "/home/admin/upgrade_logs/uninstall_{}.txt".format(app) + file2 = "/home/admin/upgrade_logs/uninstall_log_latest.txt" + cmd = "/usr/bin/mynode_uninstall_app.sh {} 2>&1 | tee {} {}".format(app,file1, file2) + subprocess.call(cmd, shell=True) + + # Sync + os.system("sync") + def is_installed(current_version): return current_version != "not installed" +def get_app_current_version(short_name): + version = "unknown" + filename1 = "/home/bitcoin/.mynode/"+short_name+"_version" + filename2 = "/mnt/hdd/mynode/settings/"+short_name+"_version" + if os.path.isfile(filename1): + version = get_file_contents(filename1) + elif os.path.isfile(filename2): + version = get_file_contents(filename2) + else: + version = "not installed" + + # For versions that are hashes, shorten them + version = version[0:16] + + return version + +def get_app_latest_version(app): + version = "unknown" + filename1 = "/home/bitcoin/.mynode/"+app+"_version_latest" + filename2 = "/mnt/hdd/mynode/settings/"+app+"_version_latest" + if os.path.isfile(filename1): + version = get_file_contents(filename1) + elif os.path.isfile(filename2): + version = get_file_contents(filename2) + else: + version = "error" + + # For versions that are hashes, shorten them + version = version[0:16] + + return version + def create_application(name="NAME", short_name="SHORT_NAME", app_tile_name=None, @@ -125,6 +198,7 @@ def initialize_applications(): short_name="rtl", app_tile_name="RTL", app_tile_default_status_text="Lightning Wallet", + can_uninstall=True, show_on_homepage=True, requires_lightning=True, supports_testnet=True, @@ -146,6 +220,7 @@ def initialize_applications(): name="BTCPay Server", short_name="btcpayserver", app_tile_default_status_text="Merchant Tool", + can_uninstall=True, requires_lightning=True, show_on_homepage=True, homepage_order=13 @@ -154,6 +229,7 @@ def initialize_applications(): name="Mempool", short_name="mempool", app_tile_default_status_text="Mempool Viewer", + can_uninstall=True, show_on_homepage=True, supports_testnet=True, requires_docker_image_installation=True, @@ -163,6 +239,7 @@ def initialize_applications(): name="LND Hub", short_name="lndhub", app_tile_default_status_text="BlueWallet Backend", + can_uninstall=True, requires_lightning=True, show_on_homepage=True, homepage_order=15 @@ -182,6 +259,7 @@ def initialize_applications(): short_name="btcrpcexplorer", app_tile_name="Explorer", app_tile_default_status_text="BTC RPC Explorer", + can_uninstall=True, requires_bitcoin=True, show_on_homepage=True, supports_testnet=True, @@ -195,6 +273,7 @@ def initialize_applications(): app_tile_button_href="/dojo", app_tile_default_status_text="Mixing Tool", app_tile_running_status_text="Running", + can_uninstall=True, show_on_application_page=True, show_on_homepage=True, requires_electrs=True, @@ -208,6 +287,7 @@ def initialize_applications(): app_tile_button_href="/whirlpool", app_tile_default_status_text="Mixing Tool", app_tile_running_status_text="Running", + can_uninstall=True, show_on_homepage=True, homepage_order=23 )) @@ -217,6 +297,7 @@ def initialize_applications(): app_tile_button_text="Info", app_tile_button_href="/joininbox", app_tile_default_status_text="JoinMarket Mixing", + can_uninstall=True, show_on_homepage=True, homepage_order=24, can_enable_disable=False, @@ -231,6 +312,7 @@ def initialize_applications(): name="Thunderhub", short_name="thunderhub", app_tile_default_status_text="Lightning Wallet", + can_uninstall=True, requires_lightning=True, supports_testnet=True, show_on_homepage=True, @@ -244,6 +326,7 @@ def initialize_applications(): app_tile_button_text="Info", app_tile_button_href="/caravan", app_tile_default_status_text="Multisig Tool", + can_uninstall=True, show_on_homepage=True, homepage_order=31, supports_testnet=True, @@ -254,6 +337,7 @@ def initialize_applications(): short_name="specter", requires_bitcoin=True, app_tile_default_status_text="Multisig Tool", + can_uninstall=True, show_on_homepage=True, homepage_order=32, supports_testnet=True, @@ -264,6 +348,7 @@ def initialize_applications(): short_name="ckbunker", requires_bitcoin=True, app_tile_default_status_text="Coldcard Signing Tool", + can_uninstall=True, show_on_homepage=True, homepage_order=33, supports_testnet=True, @@ -276,6 +361,7 @@ def initialize_applications(): app_tile_button_href="/sphinxrelay", app_tile_default_status_text="Sphinx Chat Backend", app_tile_running_status_text="Running", + can_uninstall=True, requires_lightning=True, show_on_homepage=True, homepage_order=34, @@ -286,6 +372,7 @@ def initialize_applications(): short_name="lnbits", requires_lightning=True, app_tile_default_status_text="Lightning Wallet", + can_uninstall=True, show_on_homepage=True, homepage_order=35, is_premium=True @@ -344,6 +431,10 @@ def update_applications(): for app in mynode_applications: update_application(app) +def clear_application_cache(): + global mynode_applications + mynode_applications = None + def get_all_applications(order_by="none"): global mynode_applications diff --git a/rootfs/standard/var/www/mynode/device_info.py b/rootfs/standard/var/www/mynode/device_info.py index 4728fafb..1cc8a2e6 100644 --- a/rootfs/standard/var/www/mynode/device_info.py +++ b/rootfs/standard/var/www/mynode/device_info.py @@ -223,61 +223,6 @@ def has_checkin_error(): return os.path.isfile("/tmp/check_in_error") -#================================== -# Manage Apps -#================================== -def get_app_current_version(app): - version = "unknown" - filename1 = "/home/bitcoin/.mynode/"+app+"_version" - filename2 = "/mnt/hdd/mynode/settings/"+app+"_version" - if os.path.isfile(filename1): - version = get_file_contents(filename1) - elif os.path.isfile(filename2): - version = get_file_contents(filename2) - else: - version = "not installed" - - # For versions that are hashes, shorten them - version = version[0:16] - - return version - -def get_app_latest_version(app): - version = "unknown" - filename1 = "/home/bitcoin/.mynode/"+app+"_version_latest" - filename2 = "/mnt/hdd/mynode/settings/"+app+"_version_latest" - if os.path.isfile(filename1): - version = get_file_contents(filename1) - elif os.path.isfile(filename2): - version = get_file_contents(filename2) - else: - version = "error" - - # For versions that are hashes, shorten them - version = version[0:16] - - return version - - -# This is going to be the "old" way to install apps -def reinstall_app(app): - if not is_upgrade_running(): - mark_upgrade_started() - - # Upgrade - os.system("mkdir -p /home/admin/upgrade_logs") - file1 = "/home/admin/upgrade_logs/reinstall_{}.txt".format(app) - file2 = "/home/admin/upgrade_logs/upgrade_log_latest.txt" - cmd = "/usr/bin/mynode_reinstall_app.sh {} 2>&1 | tee {} {}".format(app,file1, file2) - subprocess.call(cmd, shell=True) - - # Sync - os.system("sync") - time.sleep(1) - - # Reboot - reboot_device() - #================================== # Reseller Info #================================== diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index 8e7cc1e8..80753188 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -815,6 +815,27 @@ def reinstall_app_page(): } return render_template('reboot.html', **templateData) +@mynode_settings.route("/settings/uninstall-app") +def uninstall_app_page(): + check_logged_in() + + # Check application specified + if not request.args.get("app"): + flash("No application specified", category="error") + return redirect("/apps") + + # Check application name is valid + app = request.args.get("app") + if not is_application_valid(app): + flash("Application is invalid", category="error") + return redirect("/apps") + + # Un-install app + uninstall_app(app) + + flash("Application Uninstalled", category="message") + return redirect("/apps") + @mynode_settings.route("/settings/toggle-uploader") def toggle_uploader_page(): check_logged_in() diff --git a/rootfs/standard/var/www/mynode/static/css/mynode.css b/rootfs/standard/var/www/mynode/static/css/mynode.css index 70cc21b9..92f456ad 100644 --- a/rootfs/standard/var/www/mynode/static/css/mynode.css +++ b/rootfs/standard/var/www/mynode/static/css/mynode.css @@ -532,6 +532,20 @@ a:link.ui-button, a:visited.ui-button, .ui-button { background-color: #d7d7d7; } +.install_button { + background-color: #99dd9d !important; +} +.install_button:hover { + background-color: #90d090 !important; +} + +.uninstall_button { + background-color: #ffaaaa !important; +} +.uninstall_button:hover { + background-color: #f0a0a0 !important; +} + .mynode_button_small { font-size: 12px !important; } diff --git a/rootfs/standard/var/www/mynode/templates/manage_apps.html b/rootfs/standard/var/www/mynode/templates/manage_apps.html index e8ce0bcc..71af0079 100644 --- a/rootfs/standard/var/www/mynode/templates/manage_apps.html +++ b/rootfs/standard/var/www/mynode/templates/manage_apps.html @@ -6,6 +6,7 @@