#1128 adding REPAIR options to delete indexes

This commit is contained in:
rootzoll 2020-05-01 21:40:25 +02:00
parent 3ce0d31e37
commit d0a24b295e
4 changed files with 65 additions and 24 deletions

View File

@ -471,6 +471,33 @@ if [ "${ElectRS}" != "${choice}" ]; then
echo "ElectRS Setting changed .."
anychange=1
extraparameter=""
if [ "${choice}" = "on" ]; then
# check on HDD size
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
if [ ${hddGigaBytes} -lt 800 ]; then
whiptail --title " HDD/SSD TOO SMALL " --msgbox "\
Since v1.5 we recommend at least a 1TB HDD/SSD if you want to run ElectRS.\n
This is due to the eletcrum index that will grow over time and needs space.\n
To migrate to a bigger HDD/SSD check RaspiBlitz README on 'migration'.\n
" 14 50
else
/home/admin/config.scripts/bonus.electrs.sh on ${extraparameter}
errorOnInstall=$?
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start electrs
whiptail --title " Installed ElectRS Server " --msgbox "\
The index database needs to be created before Electrum Server can be used.\n
This can take hours/days depending on your RaspiBlitz. Monitor the progress on the LCD.\n
When finished use the new 'ELECTRS' entry in Main Menu for more info.\n
" 14 50
else
l1="!!! FAIL on ElectRS install !!!"
l2="Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.electrs.sh on"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
fi
if [ "${choice}" = "off" ]; then
whiptail --title "Delete Electrum Index?" \
--yes-button "Keep Index" \
@ -479,24 +506,9 @@ if [ "${ElectRS}" != "${choice}" ]; then
if [ $? -eq 1 ]; then
extraparameter="deleteindex"
fi
fi
/home/admin/config.scripts/bonus.electrs.sh ${choice} ${extraparameter}
errorOnInstall=$?
if [ "${choice}" = "on" ]; then
if [ ${errorOnInstall} -eq 0 ]; then
sudo systemctl start electrs
whiptail --title " Installed ElectRS Server " --msgbox "\
The index database needs to be created before Electrum Server can be used.\n
This can take hours/days depending on your RaspiBlitz. Monitor the progress on the LCD.\n
When finished use the new 'ELECTRS' entry in Main Menu for more info.\n
" 14 50
else
l1="!!! FAIL on ElectRS install !!!"
l2="Try manual install on terminal after reboot with:"
l3="/home/admin/config.scripts/bonus.electrs.sh on"
dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65
fi
fi
/home/admin/config.scripts/bonus.electrs.sh off ${extraparameter}
fi
else
echo "ElectRS Setting unchanged."
fi

View File

@ -72,7 +72,9 @@ OPTIONS=(HARDWARE "Run Hardwaretest" \
RESET-CHAIN "Delete Blockchain & Re-Download" \
RESET-LND "Delete LND & start new node/wallet" \
RESET-HDD "Delete HDD Data but keep Blockchain" \
RESET-ALL "Delete HDD completly to start fresh"
RESET-ALL "Delete HDD completly to start fresh" \
DELETE-ELEC "Delete Electrum Index" \
DELETE-INDEX "Delete Bitcoin Transaction-Index"
)
CHOICE=$(whiptail --clear --title "Repair Options" --menu "" 15 62 8 "${OPTIONS[@]}" 2>&1 >/dev/tty)
@ -153,6 +155,14 @@ case $CHOICE in
sudo shutdown now
exit 1;
;;
DELETE-ELEC)
/home/admin/bonus.scripts/bonus.electrs.sh off deleteindex
exit 1;
;;
DELETE-INDEX)
/home/admin/bonus.scripts/network.txindex.sh delete
exit 1;
;;
COPY-SOURCE)
copyHost
;;

View File

@ -143,7 +143,7 @@ Check 'sudo nginx -t' for a detailed error message.
# Options (available without TOR)
OPTIONS=( \
CONNECT "How to Connect" \
INDEX "Delete/Rebuild Index" \
INDEX "Delete&Rebuild Index" \
STATUS "ElectRS Status Info"
)
@ -455,6 +455,12 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
# setting value in raspiblitz config
sudo sed -i "s/^ElectRS=.*/ElectRS=off/g" /mnt/hdd/raspiblitz.conf
# if second parameter is "deleteindex"
if [ "$2" == "deleteindex" ]; then
echo "# deleting electrum index"
sudo rm -rf /mnt/hdd/app-storage/electrs/
fi
isInstalled=$(sudo ls /etc/systemd/system/electrs.service 2>/dev/null | grep -c 'electrs.service')
if [ ${isInstalled} -eq 1 ]; then
@ -470,10 +476,6 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo rm -rf /home/electrs/.rustup
sudo rm -rf /home/electrs/.profile
if [ "$2" == "deleteindex" ]; then
sudo rm -rf /mnt/hdd/app-storage/electrs/
fi
echo "# OK ElectRS removed."
## Disable BTCEXP_ADDRESS_API if BTC-RPC-Explorer is active

View File

@ -88,5 +88,22 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
exit 0
fi
###################
# delete (and make sure all using apps are deinstalled)
# on version update check all bonus scripts that this network.txindex.sh on
###################
if [ "$1" = "delete" ]; then
echo "# deinstalling apps needing txindex ..."
sudo -u admin /home/admin/config.scripts/bonus.btc-rpc-explorer.sh off
echo "# changing config ..."
sudo systemctl stop ${network}d
sudo sed -i "s/^txindex=.*/txindex=0/g" /mnt/hdd/${network}/${network}.conf
echo "# deleting tx index ..."
sudo rm -r /mnt/hdd/${network}/indexes/txindex
sudo systemctl restart ${network}d
exit 0
fi
echo "FAIL - Unknown Parameter $1"
exit 1