From 030ac88be5260d973d81eecc5b2c515697b1267a Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 18 Mar 2019 00:46:15 +0100 Subject: [PATCH] fixing rpcpassword after repair --- home.admin/50copyHDD.sh | 35 ++++++++++++++++++++--------------- home.admin/50torrentHDD.sh | 2 ++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/home.admin/50copyHDD.sh b/home.admin/50copyHDD.sh index 65c20d7..d11dd5a 100755 --- a/home.admin/50copyHDD.sh +++ b/home.admin/50copyHDD.sh @@ -20,15 +20,6 @@ case $CHOICE in *) exit 1;; esac -if [ -d "/mnt/hdd/bitcoin" ]; then - dialog --title "Prepare Copy" --yesno "Do you want to delete the old/local blockchain data now?" 8 60 - response=$? - echo "response(${response})" - case $response in - 1) exit 1 ;; - esac -fi - # additional prep if this is used to replace corrupted blockchain if [ "${setupStep}" = "100" ]; then # make sure services are not running @@ -38,12 +29,24 @@ if [ "${setupStep}" = "100" ]; then sudo cp -f /mnt/hdd/bitcoin/bitcoin.conf /home/admin/assets/bitcoin.conf fi -# delete all IN bitcoin directory but not itself if it exists -# so that possibel link to /home/bitcoin/.bitcoin nicht beschädigt wird -# also keep debug logs for repair script -sudo mv /mnt/hdd/bitcoin/debug.log /home/admin/debug.log 2>/dev/null -sudo rm -rfv /mnt/hdd/bitcoin/* 2>/dev/null -sudo mv /home/admin/debug.log /mnt/hdd/bitcoin/debug.log 2>/dev/null +if [ -d "/mnt/hdd/bitcoin" ]; then + dialog --title "Fresh or Repair" --yesno "Do you want to delete the old/local blockchain data now?" 8 60 + response=$? + echo "response(${response})" + if [ "${$response}" = "1" ]; then + echo "OK - keep old blockchain - just try to repair by copying over it" + sleep 3 + else + echo "OK - delete old blockchain" + # delete all IN bitcoin directory but not itself if it exists + # so that possibel link to /home/bitcoin/.bitcoin nicht beschädigt wird + # also keep debug logs for repair script + sudo mv /mnt/hdd/bitcoin/debug.log /home/admin/debug.log 2>/dev/null + sudo rm -rfv /mnt/hdd/bitcoin/* 2>/dev/null + sudo mv /home/admin/debug.log /mnt/hdd/bitcoin/debug.log 2>/dev/null + sleep 3 + fi +fi # make sure /mnt/hdd/bitcoin exists sudo mkdir /mnt/hdd/bitcoin 2>/dev/null @@ -143,7 +146,9 @@ echo "*********************************************" # if started after intial setup - quit here if [ "${setupStep}" = "100" ]; then sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf + rpcpass=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep 'bitcoind.rpcpass' | cut -d "=" -f2) sudo chown bitcoin:bitcoin /mnt/hdd/bitcoin/bitcoin.conf + sudo sed -i "s/^rpcpassword=.*/rpcpassword=${rpcpass}/g" /mnt/hdd/bitcoin/bitcoin.conf 2>/dev/null sudo systemctl enable bitcoind echo "DONE - rebooting: sudo shutdown -r now" sudo shutdown -r now diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 904d3c1..8ddd3a4 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -288,6 +288,8 @@ date +%s if [ "${setupStep}" = "100" ]; then sudo cp /home/admin/assets/${network}.conf /mnt/hdd/${network}/${network}.conf + rpcpass=$(sudo cat /mnt/hdd/lnd/lnd.conf | grep "${network}d.rpcpass" | cut -d "=" -f2) + sudo sed -i "s/^rpcpassword=.*/rpcpassword=${rpcpass}/g" /mnt/hdd/${network}/${network}.conf 2>/dev/null sudo chown -R bitcoin:bitcoin /mnt/hdd/${network}/ sudo systemctl enable ${network}d echo "DONE - rebooting: sudo shutdown -r now"