mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-26 03:28:04 +02:00
5029 clean (#5126)
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
#!/bin/bash
|
||||
echo ""
|
||||
extraParameter="$1"
|
||||
forceParameter="$2"
|
||||
if [ "${extraParameter}" = "-all" ]; then
|
||||
|
||||
echo "## This will DELETE ALL DATA & POSSIBLE FUNDS from the HDD ##"
|
||||
echo "# Press ENTER to really continue - CTRL+c to CANCEL (last chance)"
|
||||
read key
|
||||
|
||||
echo "# stopping services ... (please wait)"
|
||||
echo "# - swap"
|
||||
sudo dphys-swapfile swapoff
|
||||
echo "# - background"
|
||||
sudo systemctl stop background 2>/dev/null
|
||||
echo "# - lnd"
|
||||
sudo systemctl stop lnd.service 2>/dev/null
|
||||
echo "# - blockchain"
|
||||
sudo systemctl stop bitcoind.service 2>/dev/null
|
||||
|
||||
# delete plain all on HDD
|
||||
echo "# cleaning HDD ... (please wait)"
|
||||
sudo rm -rfv /mnt/hdd/*
|
||||
|
||||
elif [ "${extraParameter}" = "-blockchain" ]; then
|
||||
|
||||
if [ "${forceParameter}" != "-force" ]; then
|
||||
echo "# This will DELETE JUST your blockchain from the HDD."
|
||||
echo "# --> It will keep your LND data and other setups."
|
||||
echo "# --> You will get presented re-download options."
|
||||
echo "# Press ENTER to really continue - CTRL+c to CANCEL (last chance)"
|
||||
read key
|
||||
fi
|
||||
|
||||
echo "# stopping services ... (please wait)"
|
||||
sudo systemctl stop bitcoind.service 2>/dev/null
|
||||
|
||||
echo "selective blockchain data ... (please wait)"
|
||||
|
||||
# conf & wallet files are in /mnt/hdd/app-data/bitcoin - so delete all in storage
|
||||
sudo rm -r -f /mnt/hdd/app-storage/bitcoin/*
|
||||
sudo /home/admin/config.scripts/blitz.data.sh link
|
||||
|
||||
echo "OK Blockchain data deleted, restart needed - you may want now run: /home/admin/98repairBlockchain.sh"
|
||||
|
||||
else
|
||||
|
||||
echo "## This will DELETE your personal data & POSSIBLE FUNDS from the HDD ##"
|
||||
echo "--> It will keep Blockchain data - so you dont have to download/copy again."
|
||||
echo "Press ENTER to really continue - CTRL+c to CANCEL (last chance)"
|
||||
read key
|
||||
|
||||
echo "stopping services ... (please wait)"
|
||||
sudo dphys-swapfile swapoff
|
||||
sudo systemctl stop background 2>/dev/null
|
||||
sudo systemctl stop bitcoind.service 2>/dev/null
|
||||
|
||||
# just delete selective
|
||||
echo "selective delete ... (please wait)"
|
||||
|
||||
# bitcoin mainnet (clean working files)
|
||||
sudo rm -f /mnt/hdd/app-storage/bitcoin/* 2>/dev/null
|
||||
sudo rm -f /mnt/hdd/app-storage/bitcoin/.* 2>/dev/null
|
||||
sudo rm -f -r /mnt/hdd/app-storage/bitcoin/indexes 2>/dev/null
|
||||
|
||||
# delete all directories in /mnt/hdd/app-storage - but not the "bitcoin" folder
|
||||
sudo mv /mnt/hdd/app-storage/bitcoin /mnt/hdd/app-data/bitcoin-temp 2>/dev/null
|
||||
sudo rm -f -r /mnt/hdd/app-storage/* 2>/dev/null
|
||||
sudo mv /mnt/hdd/app-data/bitcoin-temp /mnt/hdd/app-storage/bitcoin 2>/dev/null
|
||||
|
||||
# delete rest of all data
|
||||
sudo rm -f -r /mnt/hdd/hdd/app-data 2>/dev/null
|
||||
sudo rm -f -r /mnt/disk_storage/app-data 2>/dev/null
|
||||
sudo rm -f -r /mnt/disk_data/app-data 2>/dev/null
|
||||
sudo rm -f -r /mnt/disk_storage/temp 2>/dev/null
|
||||
fi
|
||||
|
||||
echo "*************************"
|
||||
echo "OK - the HDD is now clean"
|
||||
echo "*************************"
|
||||
echo "reboot -> sudo shutdown -r now"
|
||||
echo "power off -> sudo shutdown now"
|
@@ -163,6 +163,26 @@ function release() {
|
||||
fi
|
||||
}
|
||||
|
||||
# command: clean
|
||||
function clean() {
|
||||
firstPARAM=$1
|
||||
echo "- deletes all data from drive - just keeps blocks and chainstate (LOSS OF FUNDS POSSIBLE!)"
|
||||
source <(/home/admin/_cache.sh get state)
|
||||
if [ "$state" != "waitsetup" ]; then
|
||||
echo "error='can only be called on fresh sd card image - before setup or recover'"
|
||||
exit 1
|
||||
fi
|
||||
source <(sudo /home/admin/config.scripts/blitz.data.sh status)
|
||||
if [ "${storageDevice}" = "" ]; then
|
||||
echo "error='no storage device'"
|
||||
exit 1
|
||||
fi
|
||||
confirmMsg clean
|
||||
if [ $confirm -eq 1 ]; then
|
||||
sudo /home/admin/config.scripts/blitz.data.sh clean STORAGE "${storageDevice}"
|
||||
fi
|
||||
}
|
||||
|
||||
# command: fatpack
|
||||
function fatpack() {
|
||||
echo "Command to be called only on a fresh stopped minimal build to re-pack installs."
|
||||
|
@@ -7,7 +7,7 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
>&2 echo "# blitz.data.sh setup STOARGE [device] combinedData=[0|1] addSystemPartition=[0|1]"
|
||||
>&2 echo "# blitz.data.sh setup SYSTEM [device]"
|
||||
>&2 echo "# blitz.data.sh setup DATA [device]"
|
||||
>&2 echo "# blitz.data.sh clean STOARGE [device] combinedData=[0|1] addSystemPartition=[0|1]"
|
||||
>&2 echo "# blitz.data.sh clean STOARGE [device] combinedData=[0|1]"
|
||||
>&2 echo "# blitz.data.sh clean SYSTEM [device]"
|
||||
>&2 echo "# blitz.data.sh clean DATA [device]"
|
||||
>&2 echo "# blitz.data.sh copy-system [device] [system|storage]"
|
||||
@@ -1142,6 +1142,7 @@ if [ "$action" = "link" ]; then
|
||||
mkdir -p "${dataMountedPath}/app-data/bitcoin"
|
||||
chown bitcoin:bitcoin "${dataMountedPath}/app-data/bitcoin"
|
||||
if [ -d "${storageMountedPath}/bitcoin" ]; then
|
||||
/home/admin/_cache.sh set message "hdd-migrate"
|
||||
echo "# moving old data from ${storageMountedPath}/bitcoin to ${storageMountedPath}/app-storage/bitcoin"
|
||||
rsync -a --remove-source-files --prune-empty-dirs ${storageMountedPath}/bitcoin/ ${storageMountedPath}/app-storage/bitcoin/
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -1180,6 +1181,7 @@ if [ "$action" = "link" ]; then
|
||||
mkdir -p "${dataMountedPath}/app-data/lnd"
|
||||
chown bitcoin:bitcoin "${dataMountedPath}/app-data/lnd"
|
||||
if [ -d "${storageMountedPath}/lnd" ]; then
|
||||
/home/admin/_cache.sh set message "hdd-migrate"
|
||||
echo "# moving old data from ${storageMountedPath}/lnd to ${dataMountedPath}/app-data/lnd"
|
||||
rsync -a --remove-source-files --prune-empty-dirs ${storageMountedPath}/lnd/ ${dataMountedPath}/app-data/lnd/
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -1202,6 +1204,7 @@ if [ "$action" = "link" ]; then
|
||||
mkdir -p "${dataMountedPath}/app-data/tor"
|
||||
chown debian-tor:debian-tor "${dataMountedPath}/app-data/tor"
|
||||
if [ -d "${storageMountedPath}/tor" ]; then
|
||||
/home/admin/_cache.sh set message "hdd-migrate"
|
||||
echo "# moving old data from ${storageMountedPath}/tor to ${dataMountedPath}/app-data/tor"
|
||||
rsync -a --remove-source-files --prune-empty-dirs ${storageMountedPath}/tor/ ${dataMountedPath}/app-data/tor/
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -1896,7 +1899,7 @@ if [ "$action" = "setup" ]; then
|
||||
echo "storagePartition='${actionDevicePartitionBase}3'"
|
||||
echo "# storagePartition(${actionDevicePartitionBase}3)" >> ${logFile}
|
||||
|
||||
# STORAGE without System partition (if addSystemPartition=0 or not set)
|
||||
# STORAGE without System partition (if addSystemPartition=0)
|
||||
elif [ "${actionType}" = "STORAGE" ] && [ ${actionCreateSystemPartition} -eq 0 ]; then
|
||||
echo "# STORAGE partitioning (no boot)" >> ${logFile}
|
||||
|
||||
@@ -2225,16 +2228,23 @@ if [ "$action" = "recover" ] || [ "$action" = "clean" ]; then
|
||||
fi
|
||||
# in both setups /mnt/disk_storage/app-storage should exist
|
||||
# delete all data in /mnt/disk_storage except for /mnt/disk_storage/app-storage
|
||||
echo "# Cleaning storage partition - preserving app-storage" >> ${logFile}
|
||||
# Cleaning storage partition - preserving app-storage
|
||||
echo "# Cleaning storage partition - preserving blockchain (blocks & chainstate)" >> ${logFile}
|
||||
|
||||
# DEBUG: Log partition count before cleaning operations
|
||||
beforeCleaningCount=$(partx -g /dev/"${actionDevice}" 2>/dev/null | wc -l)
|
||||
echo "# DEBUG CLEAN STORAGE: Partition count before cleaning operations: ${beforeCleaningCount}" >> ${logFile}
|
||||
|
||||
# TODO: This is not working yet .. refactor later
|
||||
find /mnt/disk_storage -maxdepth 1 -not -name "app-storage" -not -name "." -not -name ".." -exec rm -rf {} \;
|
||||
find /mnt/disk_storage/app-storage -maxdepth 1 -not -name "bitcoin" -not -name "." -not -name ".." -exec rm -rf {} \;
|
||||
find /mnt/disk_storage/app-storage/bitcoin -maxdepth 1 -not -name "blocks" -name "chainstate" -not -name "." -not -name ".." -exec rm -rf {} \;
|
||||
# Alte Logik löschte versehentlich chainstate. Neu:
|
||||
# 1. Auf Root der Partition alles löschen außer app-storage
|
||||
find /mnt/disk_storage -mindepth 1 -maxdepth 1 \
|
||||
-not -name "app-storage" -exec rm -rf {} \;
|
||||
# 2. In app-storage alles löschen außer bitcoin
|
||||
find /mnt/disk_storage/app-storage -mindepth 1 -maxdepth 1 \
|
||||
-not -name "bitcoin" -exec rm -rf {} \;
|
||||
# 3. In bitcoin alles löschen außer blocks und chainstate (beides behalten)
|
||||
if [ -d /mnt/disk_storage/app-storage/bitcoin ]; then
|
||||
find /mnt/disk_storage/app-storage/bitcoin -mindepth 1 -maxdepth 1 \
|
||||
-not -name "blocks" -not -name "chainstate" -exec rm -rf {} \;
|
||||
fi
|
||||
|
||||
# Logging nach Cleanup
|
||||
ls -la /mnt/disk_storage >> ${logFile}
|
||||
ls -la /mnt/disk_storage/app-storage >> ${logFile}
|
||||
ls -la /mnt/disk_storage/app-storage/bitcoin >> ${logFile}
|
||||
|
@@ -27,9 +27,11 @@ activateBitcoinOverTor()
|
||||
deactivateBitcoinOverTor
|
||||
|
||||
sudo chmod 777 "/home/bitcoin/.${network}/${network}.conf"
|
||||
sudo sed -i "s/^onlynet=.*//g" "/home/bitcoin/.${network}/${network}.conf"
|
||||
echo "Adding Tor config to the the ${network}.conf ..."
|
||||
sudo sed -i "s/^torpassword=.*//g" "/home/bitcoin/.${network}/${network}.conf"
|
||||
echo "onlynet=onion" | sudo tee -a "/home/bitcoin/.${network}/${network}.conf"
|
||||
echo "onlynet=i2p" | sudo tee -a "/home/bitcoin/.${network}/${network}.conf"
|
||||
echo "proxy=127.0.0.1:9050" | sudo tee -a "/home/bitcoin/.${network}/${network}.conf"
|
||||
echo "main.bind=127.0.0.1" | sudo tee -a "/home/bitcoin/.${network}/${network}.conf"
|
||||
echo "test.bind=127.0.0.1" | sudo tee -a "/home/bitcoin/.${network}/${network}.conf"
|
||||
@@ -51,7 +53,7 @@ activateBitcoinOverTor()
|
||||
|
||||
deactivateBitcoinOverTor()
|
||||
{
|
||||
# always make sure also to remove old settings
|
||||
# alte/tor-bezogene Settings entfernen
|
||||
sudo sed -i "s/^onlynet=.*//g" "/home/bitcoin/.${network}/${network}.conf"
|
||||
sudo sed -i "s/^main.addnode=.*//g" "/home/bitcoin/.${network}/${network}.conf"
|
||||
sudo sed -i "s/^test.addnode=.*//g" "/home/bitcoin/.${network}/${network}.conf"
|
||||
@@ -60,8 +62,14 @@ deactivateBitcoinOverTor()
|
||||
sudo sed -i "s/^test.bind=.*//g" "/home/bitcoin/.${network}/${network}.conf"
|
||||
sudo sed -i "s/^dnsseed=.*//g" "/home/bitcoin/.${network}/${network}.conf"
|
||||
sudo sed -i "s/^dns=.*//g" "/home/bitcoin/.${network}/${network}.conf"
|
||||
|
||||
# explizit only IPv4 & IPv6
|
||||
echo "onlynet=ipv4" | sudo tee -a "/home/bitcoin/.${network}/${network}.conf" >/dev/null
|
||||
echo "onlynet=ipv6" | sudo tee -a "/home/bitcoin/.${network}/${network}.conf" >/dev/null
|
||||
|
||||
# remove empty lines
|
||||
sudo sed -i '/^ *$/d' "/home/bitcoin/.${network}/${network}.conf"
|
||||
|
||||
sudo cp "/home/bitcoin/.${network}/${network}.conf" "/home/admin/.${network}/${network}.conf"
|
||||
sudo chown admin:admin "/home/admin/.${network}/${network}.conf"
|
||||
}
|
||||
@@ -167,7 +175,7 @@ EOF
|
||||
/home/admin/config.scripts/blitz.conf.sh set runBehindTor "off"
|
||||
|
||||
# remove "debug=tor" from bitcoin.conf
|
||||
sudo sed -i '/^debug=tor$/d' /mnt/hdd/app-databitcoin/bitcoin.conf
|
||||
sudo sed -i '/^debug=tor$/d' /mnt/hdd/app-data/bitcoin/bitcoin.conf
|
||||
|
||||
# deactivate bitcoin over tor (function call)
|
||||
deactivateBitcoinOverTor
|
||||
|
@@ -197,20 +197,17 @@ if [ "${setupPhase}" = "setup" ]; then
|
||||
|
||||
# handle existing blockchain data # CLOSED FOR REPAIR #5029
|
||||
existingBlockchain=""
|
||||
#if [ "${system_setup_storageBlockchainGB}" != "" ] && [ "${system_setup_storageBlockchainGB}" != "0" ]; then
|
||||
# allow, when not bootFromStorage
|
||||
#if [ "${system_setup_bootFromStorage}" == "0" ]; then
|
||||
# echo "# Existing blockchain can be used - cannot be moved to new drive layout"
|
||||
# existingBlockchain="BITCOIN"
|
||||
if [ "${menuresult}" = "0" ] && [ "${system_setup_storageBlockchainGB}" != "" ] && [ "${system_setup_storageBlockchainGB}" != "0" ]; then
|
||||
echo "# Existing blockchain can be used - cannot be moved to new drive layout"
|
||||
existingBlockchain="BITCOIN"
|
||||
# allow, when bootFromStorage & storage already has 3 partitions (new drive layout)
|
||||
#elif [ "${system_setup_bootFromStorage}" == "1" ] && [ "${system_setup_storagePartitionsCount}" == "3" ] ; then
|
||||
# echo "# Existing blockchain can be used - already new drive layout"
|
||||
# existingBlockchain="BITCOIN"
|
||||
elif [ "${system_setup_storagePartitionsCount}" == "3" ]; then
|
||||
echo "# Existing blockchain can be used - already new drive layout"
|
||||
existingBlockchain="BITCOIN"
|
||||
# otherwise - dont use existing blockchain
|
||||
# else
|
||||
# echo "# Existing blockchain will not be used - to allow transfere to new drive layout"
|
||||
# fi
|
||||
#fi
|
||||
else
|
||||
echo "# Existing blockchain will not be used - to allow transfere to new drive layout"
|
||||
fi
|
||||
|
||||
# ask user about possible existing blockchain and formatting HDD
|
||||
if [ "${menuresult}" != "6" ]; then
|
||||
|
@@ -274,6 +274,13 @@ elif [ "${eventID}" == "waitsetup" ] && [ "${mode}" == "ssh" ]; then
|
||||
Please wait ...
|
||||
" 5 22
|
||||
|
||||
elif [ "${eventID}" == "waitprovision" ] && [ "${contentString}" == "hdd-migrate" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
Changing Data Layout of HDD/SSD/NVMe
|
||||
Can take looooooong time - just wait.
|
||||
" 6 44
|
||||
|
||||
elif [ "${eventID}" == "waitprovision" ]; then
|
||||
|
||||
dialog --backtitle "${backtitle}" --cr-wrap --infobox "
|
||||
|
Reference in New Issue
Block a user