diff --git a/home.admin/config.scripts/blitz.debug.sh b/home.admin/config.scripts/blitz.debug.sh index 243fff338..f6dca3930 100755 --- a/home.admin/config.scripts/blitz.debug.sh +++ b/home.admin/config.scripts/blitz.debug.sh @@ -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" diff --git a/home.admin/config.scripts/blitz.fatpack.sh b/home.admin/config.scripts/blitz.fatpack.sh index c41bcc5a7..f2a7ee163 100755 --- a/home.admin/config.scripts/blitz.fatpack.sh +++ b/home.admin/config.scripts/blitz.fatpack.sh @@ -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 diff --git a/home.admin/config.scripts/blitz.web.api.sh b/home.admin/config.scripts/blitz.web.api.sh index 71ff121c0..03478bd58 100644 --- a/home.admin/config.scripts/blitz.web.api.sh +++ b/home.admin/config.scripts/blitz.web.api.sh @@ -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 diff --git a/home.admin/config.scripts/blitz.web.ui.sh b/home.admin/config.scripts/blitz.web.ui.sh index df59e7c64..4710ebf48 100755 --- a/home.admin/config.scripts/blitz.web.ui.sh +++ b/home.admin/config.scripts/blitz.web.ui.sh @@ -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) diff --git a/home.admin/config.scripts/bonus.electrs.sh b/home.admin/config.scripts/bonus.electrs.sh index 7cacd05f5..7232149be 100755 --- a/home.admin/config.scripts/bonus.electrs.sh +++ b/home.admin/config.scripts/bonus.electrs.sh @@ -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