Fix Electrs Fatpack/WebUI (#4438)

This commit is contained in:
/rootzoll 2024-02-25 13:38:27 +01:00 committed by GitHub
parent ec67c362f7
commit 440b788bd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 67 additions and 24 deletions

View file

@ -308,6 +308,8 @@ if [ "${ElectRS}" == "on" ]; then
echo
echo "*** ElectRS Status ***"
sudo /home/admin/config.scripts/bonus.electrs.sh status
echo "*** ElectRS Status-Sync ***"
sudo /home/admin/config.scripts/bonus.electrs.sh status-sync
echo
else
echo "- Electrum Rust Server is OFF by config"

View file

@ -108,6 +108,8 @@ echo "* Adding Code&Compile for WEBUI-APP: BTC RPC EXPLORER"
/home/admin/config.scripts/bonus.btc-rpc-explorer.sh install || exit 1
echo "* Adding Code&Compile for WEBUI-APP: MEMPOOL"
/home/admin/config.scripts/bonus.mempool.sh install || exit 1
echo "* Adding Code&Compile for WEBUI-APP: ELECTRS"
/home/admin/config.scripts/bonus.electrs.sh install || exit 1
# set default display to LCD
sudo /home/admin/config.scripts/blitz.display.sh set-display lcd

View file

@ -214,7 +214,10 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "# WARNING! The given API repo is not available:"
echo "# user(${GITHUB_USER}) repo(${GITHUB_REPO}) branch(${GITHUB_BRANCH})"
echo "# WORKING WITH FALLBACK REPO - USE JUST FOR DEVELOPMENT - DONT USE IN PRODUCTION"
GITHUB_BRANCH="${FALLACK_BRANCH}"
echo "# SO WORKING WITH FALLBACK REPO:"
echo "# user(${GITHUB_USER}) repo(${GITHUB_REPO}) branch(${GITHUB_BRANCH})"
echo "# USE JUST FOR DEVELOPMENT - DONT USE IN PRODUCTION"
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
sleep 10

View file

@ -101,11 +101,13 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "# WARNING! The given WebUI repo is not available:"
echo "# user(${GITHUB_USER}) repo(${GITHUB_REPO}) branch(${GITHUB_BRANCH})"
echo "# WORKING WITH FALLBACK REPO - USE JUST FOR DEVELOPMENT - DONT USE IN PRODUCTION"
GITHUB_BRANCH="${FALLACK_BRANCH}"
echo "# SO WORKING WITH FALLBACK REPO:"
echo "# user(${GITHUB_USER}) repo(${GITHUB_REPO}) branch(${GITHUB_BRANCH})"
echo "# USE JUST FOR DEVELOPMENT - DONT USE IN PRODUCTION"
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
sleep 10
GITHUB_BRANCH="${FALLACK_BRANCH}"
fi
# re-check (if case its fallback)

View file

@ -9,6 +9,7 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "bonus.electrs.sh status -> dont call in loops"
echo "bonus.electrs.sh status-sync"
echo "bonus.electrs.sh [on|off|menu|update]"
echo "bonus.electrs.sh [install|uninstall]"
echo "installs the version $ELECTRSVERSION"
exit 1
fi
@ -33,14 +34,16 @@ if [ "$1" = "status" ]; then
echo "configured=1"
else
echo "configured=0"
fi
serviceInstalled=$(sudo systemctl status electrs --no-page 2>/dev/null | grep -c "electrs.service - Electrs")
echo "serviceInstalled=${serviceInstalled}"
if [ ${serviceInstalled} -eq 0 ]; then
echo "infoSync='Service not installed'"
fi
if id "electrs" &>/dev/null; then
echo "installed=1"
else
echo "installed=0"
fi
serviceInstalled=$(sudo systemctl status electrs --no-page 2>/dev/null | grep -c "electrs.service - Electrs")
serviceRunning=$(sudo systemctl status electrs --no-page 2>/dev/null | grep -c "active (running)")
echo "serviceRunning=${serviceRunning}"
if [ ${serviceRunning} -eq 1 ]; then
@ -84,13 +87,13 @@ if [ "$1" = "status" ]; then
# check Nginx
nginxTest=$(sudo nginx -t 2>&1 | grep -c "test is successful")
echo "nginxTest=$nginxTest"
fi
exit 0
fi
# give sync-status (can be called regularly)
if [ "$1" = "status-sync" ] || [ "$1" = "status" ]; then
if [ "$1" = "status-sync" ]; then
serviceRunning=$(sudo systemctl status electrs --no-page 2>/dev/null | grep -c "active (running)")
echo "serviceRunning=${serviceRunning}"
@ -148,7 +151,7 @@ if [ "$1" = "menu" ]; then
echo "# collecting status info ... (please wait)"
source <(sudo /home/admin/config.scripts/bonus.electrs.sh status showAddress)
if [ ${serviceInstalled} -eq 0 ]; then
if [ ${configured} -eq 0 ]; then
echo "# FAIL not installed"
exit 1
fi
@ -261,16 +264,15 @@ fi
echo "# Making sure services are not running"
sudo systemctl stop electrs 2>/dev/null
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# uninstall
if [ "$1" = "install" ]; then
echo "# INSTALL ELECTRS"
isInstalled=$(sudo ls /etc/systemd/system/electrs.service 2>/dev/null | grep -c 'electrs.service')
if [ ${isInstalled} -eq 0 ]; then
# cleanup
sudo rm -f /home/electrs/.electrs/config.toml
if id "electrs" &>/dev/null; then
echo "# user electrs exists already (codebase is installed)"
else
echo "# Installing codebase"
echo
echo "# Creating the electrs user"
echo
@ -304,6 +306,27 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo
sudo mkdir /mnt/hdd/app-storage/electrs 2>/dev/null
sudo chown -R electrs:electrs /mnt/hdd/app-storage/electrs
fi
exit 0
fi
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "# ACTIVATING ELECTRS"
isInstalled=$(sudo ls /etc/systemd/system/electrs.service 2>/dev/null | grep -c 'electrs.service')
if [ ${isInstalled} -eq 0 ]; then
# cleanup
sudo rm -f /home/electrs/.electrs/config.toml
if id "electrs" &>/dev/null; then
echo "# user electrs exists already (codebase is installed)"
else
echo "# Installing codebase"
/home/admin/config.scripts/bonus.electrs.sh install || exit 1
fi
echo
echo "# Getting RPC credentials from the bitcoin.conf"
@ -479,10 +502,24 @@ WantedBy=multi-user.target
exit 0
fi
# uninstall
if [ "$1" = "uninstall" ]; then
echo "# UNINSTALL ELECTRS"
if [ "${ElectRS}" = "on" ]; then
echo "# FAIL: First switch ElectRS off before uninstalling."
exit 1
fi
echo "# remove user and home directory"
sudo userdel -rf electrs
exit 0
fi
# switch off
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "# REMOVING ELECTRS"
echo "# DEACTIVATING ELECTRS"
# if second parameter is "deleteindex"
if [ "$2" == "deleteindex" ]; then
@ -514,13 +551,10 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo ufw delete allow 50001
sudo ufw delete allow 50002
# delete user and home directory
sudo userdel -rf electrs
# setting value in raspiblitz config
/home/admin/config.scripts/blitz.conf.sh set ElectRS "off"
echo "# OK ElectRS removed."
echo "# OK ElectRS off."
exit 0
fi