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>
This commit is contained in:
openoms
2024-01-15 19:43:33 +01:00
committed by GitHub
parent ce89ac53fa
commit af65af5e14

View File

@@ -2,7 +2,7 @@
# https://github.com/mempool/mempool # https://github.com/mempool/mempool
pinnedVersion="v2.4.0" pinnedVersion="v2.5.0"
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
@@ -135,37 +135,33 @@ if [ "$1" = "install" ]; then
sudo adduser --system --group --home /home/mempool mempool sudo adduser --system --group --home /home/mempool mempool
# install mempool # install mempool
cd /home/mempool cd /home/mempool || exit 1
sudo -u mempool git clone https://github.com/mempool/mempool.git 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 git reset --hard $pinnedVersion
sudo -u mempool /home/admin/config.scripts/blitz.git-verify.sh "${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" || exit 1 sudo -u mempool /home/admin/config.scripts/blitz.git-verify.sh "${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" || exit 1
echo "# npm install for mempool explorer (frontend)" echo "# npm install for mempool explorer (frontend)"
cd frontend cd frontend || exit 1
sudo -u mempool NG_CLI_ANALYTICS=false npm install --no-optional if ! sudo -u mempool NG_CLI_ANALYTICS=false npm ci; then
if ! [ $? -eq 0 ]; then
echo "FAIL - npm install did not run correctly, aborting" echo "FAIL - npm install did not run correctly, aborting"
exit 1 exit 1
fi fi
sudo -u mempool NG_CLI_ANALYTICS=false npm run build if ! sudo -u mempool NG_CLI_ANALYTICS=false npm run build; then
if ! [ $? -eq 0 ]; then
echo "FAIL - npm run build did not run correctly, aborting (1)" echo "FAIL - npm run build did not run correctly, aborting (1)"
exit 1 exit 1
fi fi
echo "# npm install for mempool explorer (backend)" echo "# npm install for mempool explorer (backend)"
cd ../backend/ cd ../backend/ || exit 1
sudo -u mempool NG_CLI_ANALYTICS=false npm install --no-optional if ! sudo -u mempool NG_CLI_ANALYTICS=false npm ci; then
if ! [ $? -eq 0 ]; then
echo "# FAIL - npm install did not run correctly, aborting" echo "# FAIL - npm install did not run correctly, aborting"
echo "result='failed npm install'" echo "result='failed npm install'"
exit 1 exit 1
fi fi
sudo -u mempool NG_CLI_ANALYTICS=false npm run build if ! sudo -u mempool NG_CLI_ANALYTICS=false npm run build; then
if ! [ $? -eq 0 ]; then
echo "# FAIL - npm run build did not run correctly, aborting (2)" echo "# FAIL - npm run build did not run correctly, aborting (2)"
echo "result='failed npm run build'" echo "result='failed npm run build'"
exit 1 exit 1
@@ -198,7 +194,10 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
isInstalled=$(compgen -u | grep -c mempool) isInstalled=$(compgen -u | grep -c mempool)
if [ "${isInstalled}" == "0" ]; then if [ "${isInstalled}" == "0" ]; then
echo "# Install code base first ...." 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 fi
echo "# *** Activate MEMPOOL ***" echo "# *** Activate MEMPOOL ***"
@@ -262,7 +261,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
EOF EOF
sudo mv /var/cache/raspiblitz/mempool-config.json /home/mempool/mempool/backend/mempool-config.json sudo mv /var/cache/raspiblitz/mempool-config.json /home/mempool/mempool/backend/mempool-config.json
sudo chown mempool:mempool /home/mempool/mempool/backend/mempool-config.json sudo chown mempool:mempool /home/mempool/mempool/backend/mempool-config.json
cd /home/mempool/mempool/frontend cd /home/mempool/mempool/frontend || exit 1
sudo mkdir -p /mnt/hdd/app-storage/mempool/cache sudo mkdir -p /mnt/hdd/app-storage/mempool/cache
sudo chown mempool:mempool /mnt/hdd/app-storage/mempool/cache sudo chown mempool:mempool /mnt/hdd/app-storage/mempool/cache
@@ -368,7 +367,6 @@ EOF
echo "result='OK'" echo "result='OK'"
exit 0 exit 0
fi fi
# switch off # switch off
@@ -422,7 +420,7 @@ fi
if [ "$1" = "update" ]; then if [ "$1" = "update" ]; then
echo "*** Checking Mempool Explorer Version ***" echo "*** Checking Mempool Explorer Version ***"
cd /home/mempool/mempool cd /home/mempool/mempool || exit 1
localVersion=$(git describe --tag) localVersion=$(git describe --tag)
updateVersion=$(curl --header "X-GitHub-Api-Version:2022-11-28" -s https://api.github.com/repos/mempool/mempool/releases/latest | grep tag_name | head -1 | cut -d '"' -f4) updateVersion=$(curl --header "X-GitHub-Api-Version:2022-11-28" -s https://api.github.com/repos/mempool/mempool/releases/latest | grep tag_name | head -1 | cut -d '"' -f4)
@@ -440,29 +438,24 @@ if [ "$1" = "update" ]; then
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
sudo -u mempool NG_CLI_ANALYTICS=false npm install
if ! [ $? -eq 0 ]; then
echo "FAIL - npm install did not run correctly, aborting" echo "FAIL - npm install did not run correctly, aborting"
exit 1 exit 1
fi fi
sudo -u mempool NG_CLI_ANALYTICS=false npm run build if ! sudo -u mempool NG_CLI_ANALYTICS=false npm run build; then
if ! [ $? -eq 0 ]; then
echo "FAIL - npm run build did not run correctly, aborting (3)" echo "FAIL - npm run build did not run correctly, aborting (3)"
exit 1 exit 1
fi fi
echo "# npm install for mempool explorer (frontend)" echo "# npm install for mempool explorer (frontend)"
cd ../frontend cd ../frontend || exit 1
sudo -u mempool NG_CLI_ANALYTICS=false npm install if ! sudo -u mempool NG_CLI_ANALYTICS=false npm ci; then
if ! [ $? -eq 0 ]; then
echo "FAIL - npm install did not run correctly, aborting" echo "FAIL - npm install did not run correctly, aborting"
exit 1 exit 1
fi fi
sudo -u mempool NG_CLI_ANALYTICS=false npm run build if ! sudo -u mempool NG_CLI_ANALYTICS=false npm run build; then
if ! [ $? -eq 0 ]; then
echo "FAIL - npm run build did not run correctly, aborting (4)" echo "FAIL - npm run build did not run correctly, aborting (4)"
exit 1 exit 1
fi fi
@@ -470,13 +463,12 @@ if [ "$1" = "update" ]; then
sudo mv /home/admin/mempool-config.json /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 sudo chown mempool:mempool /home/mempool/mempool/backend/mempool-config.json
# Restore frontend files # Restore frontend files
cd /home/mempool/mempool/frontend cd /home/mempool/mempool/frontend || exit 1
sudo rsync -I -av --delete dist/mempool/ /var/www/mempool/ sudo rsync -I -av --delete dist/mempool/ /var/www/mempool/
sudo chown -R www-data:www-data /var/www/mempool sudo chown -R www-data:www-data /var/www/mempool
cd /home/mempool/mempool cd /home/mempool/mempool || exit 1
# Reinstall the mempool configuration for nginx # Reinstall the mempool configuration for nginx
cp nginx.conf nginx-mempool.conf /etc/nginx/nginx.conf cp nginx.conf nginx-mempool.conf /etc/nginx/nginx.conf
@@ -486,7 +478,6 @@ if [ "$1" = "update" ]; then
echo "Removing unnecessary modules..." echo "Removing unnecessary modules..."
npm prune --production npm prune --production
echo "*** Restarting Mempool ***" echo "*** Restarting Mempool ***"
sudo systemctl start mempool sudo systemctl start mempool