From af65af5e14ed9e41fe0ba592f66f3bf54b4c6f6f Mon Sep 17 00:00:00 2001 From: openoms <43343391+openoms@users.noreply.github.com> Date: Mon, 15 Jan 2024 19:43:33 +0100 Subject: [PATCH] mempool update to v2.5.0 (#4353) * formatting * mempool update to v2.5.0 * fix shellcheck warns * check for command outcomes directly * use npm ci, exit on failed install * use npm ci in update Co-authored-by: Christoph Stenglein <9399034+cstenglein@users.noreply.github.com> --- home.admin/config.scripts/bonus.mempool.sh | 159 ++++++++++----------- 1 file changed, 75 insertions(+), 84 deletions(-) diff --git a/home.admin/config.scripts/bonus.mempool.sh b/home.admin/config.scripts/bonus.mempool.sh index bfc743643..b47bbfc30 100755 --- a/home.admin/config.scripts/bonus.mempool.sh +++ b/home.admin/config.scripts/bonus.mempool.sh @@ -2,7 +2,7 @@ # https://github.com/mempool/mempool -pinnedVersion="v2.4.0" +pinnedVersion="v2.5.0" # command info if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then @@ -135,40 +135,36 @@ if [ "$1" = "install" ]; then sudo adduser --system --group --home /home/mempool mempool # install mempool - cd /home/mempool + cd /home/mempool || exit 1 sudo -u mempool git clone https://github.com/mempool/mempool.git - cd mempool + cd mempool || exit 1 sudo -u mempool git reset --hard $pinnedVersion sudo -u mempool /home/admin/config.scripts/blitz.git-verify.sh "${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" || exit 1 echo "# npm install for mempool explorer (frontend)" - cd frontend - sudo -u mempool NG_CLI_ANALYTICS=false npm install --no-optional - if ! [ $? -eq 0 ]; then - echo "FAIL - npm install did not run correctly, aborting" - exit 1 + cd frontend || exit 1 + if ! sudo -u mempool NG_CLI_ANALYTICS=false npm ci; then + echo "FAIL - npm install did not run correctly, aborting" + exit 1 fi - sudo -u mempool NG_CLI_ANALYTICS=false npm run build - if ! [ $? -eq 0 ]; then - echo "FAIL - npm run build did not run correctly, aborting (1)" - exit 1 + if ! sudo -u mempool NG_CLI_ANALYTICS=false npm run build; then + echo "FAIL - npm run build did not run correctly, aborting (1)" + exit 1 fi echo "# npm install for mempool explorer (backend)" - cd ../backend/ - sudo -u mempool NG_CLI_ANALYTICS=false npm install --no-optional - if ! [ $? -eq 0 ]; then - echo "# FAIL - npm install did not run correctly, aborting" - echo "result='failed npm install'" - exit 1 + cd ../backend/ || exit 1 + if ! sudo -u mempool NG_CLI_ANALYTICS=false npm ci; then + echo "# FAIL - npm install did not run correctly, aborting" + echo "result='failed npm install'" + exit 1 fi - sudo -u mempool NG_CLI_ANALYTICS=false npm run build - if ! [ $? -eq 0 ]; then - echo "# FAIL - npm run build did not run correctly, aborting (2)" - echo "result='failed npm run build'" - exit 1 + if ! sudo -u mempool NG_CLI_ANALYTICS=false npm run build; then + echo "# FAIL - npm run build did not run correctly, aborting (2)" + echo "result='failed npm run build'" + exit 1 fi exit 0 @@ -198,7 +194,10 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then isInstalled=$(compgen -u | grep -c mempool) if [ "${isInstalled}" == "0" ]; then echo "# Install code base first ...." - /home/admin/config.scripts/bonus.mempool.sh install + if ! /home/admin/config.scripts/bonus.mempool.sh install; then + echo "FAIL - install did not run correctly, aborting" + exit 1 + fi fi echo "# *** Activate MEMPOOL ***" @@ -214,7 +213,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then sudo mariadb -e "GRANT ALL PRIVILEGES ON mempool.* TO 'mempool' IDENTIFIED BY 'mempool';" sudo mariadb -e "FLUSH PRIVILEGES;" if [ -f "mariadb-structure.sql" ]; then - mariadb -umempool -pmempool mempool < mariadb-structure.sql + mariadb -umempool -pmempool mempool /var/cache/raspiblitz/mempool-config.json </var/cache/raspiblitz/mempool-config.json < /var/cache/raspiblitz/mempool.service </var/cache/raspiblitz/mempool.service </dev/null - echo "*** Restarting Mempool ***" + echo "*** You are up-to-date on version $localVersion ***" + sudo systemctl restart mempool 2>/dev/null + echo "*** Restarting Mempool ***" else - # Preserve Config - sudo cp backend/mempool-config.json /home/admin + # Preserve Config + sudo cp backend/mempool-config.json /home/admin - sudo -u mempool git fetch - sudo -u mempool git checkout $updateVersion + sudo -u mempool git fetch + sudo -u mempool git checkout $updateVersion - echo "# npm install for mempool explorer (backend)" + echo "# npm install for mempool explorer (backend)" - cd /home/mempool/mempool/backend/ + cd /home/mempool/mempool/backend/ || exit 1 + if ! sudo -u mempool NG_CLI_ANALYTICS=false npm ci; then + echo "FAIL - npm install did not run correctly, aborting" + exit 1 + fi + if ! sudo -u mempool NG_CLI_ANALYTICS=false npm run build; then + echo "FAIL - npm run build did not run correctly, aborting (3)" + exit 1 + fi - sudo -u mempool NG_CLI_ANALYTICS=false npm install - if ! [ $? -eq 0 ]; then - echo "FAIL - npm install did not run correctly, aborting" - exit 1 - fi - sudo -u mempool NG_CLI_ANALYTICS=false npm run build - if ! [ $? -eq 0 ]; then - echo "FAIL - npm run build did not run correctly, aborting (3)" - exit 1 - fi + echo "# npm install for mempool explorer (frontend)" - echo "# npm install for mempool explorer (frontend)" + cd ../frontend || exit 1 + if ! sudo -u mempool NG_CLI_ANALYTICS=false npm ci; then + echo "FAIL - npm install did not run correctly, aborting" + exit 1 + fi + if ! sudo -u mempool NG_CLI_ANALYTICS=false npm run build; then + echo "FAIL - npm run build did not run correctly, aborting (4)" + exit 1 + fi - cd ../frontend - sudo -u mempool NG_CLI_ANALYTICS=false npm install - if ! [ $? -eq 0 ]; then - echo "FAIL - npm install did not run correctly, aborting" - exit 1 - fi - sudo -u mempool NG_CLI_ANALYTICS=false npm run build - if ! [ $? -eq 0 ]; then - echo "FAIL - npm run build did not run correctly, aborting (4)" - exit 1 - fi + sudo mv /home/admin/mempool-config.json /home/mempool/mempool/backend/mempool-config.json + sudo chown mempool:mempool /home/mempool/mempool/backend/mempool-config.json - sudo mv /home/admin/mempool-config.json /home/mempool/mempool/backend/mempool-config.json - sudo chown mempool:mempool /home/mempool/mempool/backend/mempool-config.json + # Restore frontend files + cd /home/mempool/mempool/frontend || exit 1 + sudo rsync -I -av --delete dist/mempool/ /var/www/mempool/ + sudo chown -R www-data:www-data /var/www/mempool + cd /home/mempool/mempool || exit 1 - # Restore frontend files - cd /home/mempool/mempool/frontend - sudo rsync -I -av --delete dist/mempool/ /var/www/mempool/ - sudo chown -R www-data:www-data /var/www/mempool + # Reinstall the mempool configuration for nginx + cp nginx.conf nginx-mempool.conf /etc/nginx/nginx.conf + sudo systemctl restart nginx - cd /home/mempool/mempool + # Remove useless deps + echo "Removing unnecessary modules..." + npm prune --production - # Reinstall the mempool configuration for nginx - cp nginx.conf nginx-mempool.conf /etc/nginx/nginx.conf - sudo systemctl restart nginx - - # Remove useless deps - echo "Removing unnecessary modules..." - npm prune --production - - - echo "*** Restarting Mempool ***" - sudo systemctl start mempool + echo "*** Restarting Mempool ***" + sudo systemctl start mempool fi