This commit is contained in:
openoms 2021-04-17 21:30:50 +01:00
commit 3032410b76
No known key found for this signature in database
GPG Key ID: 5BFB77609B081B65
16 changed files with 226 additions and 479 deletions

View File

@ -338,11 +338,8 @@ $lastLine
"CPU load${load##up*, }" "${tempC}" "${tempF}" \
"${hdd}" "${sync_percentage}"
source /home/admin/stresstest.report 2>/dev/null
if [ ${#undervoltageReports} -gt 0 ] && [ "${undervoltageReports}" != "0" ]; then
echo "${undervoltageReports} undervoltage reports - run 'Hardware Test' in menu"
elif [ ${#powerFAIL} -gt 0 ] && [ ${powerFAIL} -gt 0 ]; then
echo "Weak power supply detected - run 'Hardware Test' in menu"
elif [ ${#ups} -gt 1 ] && [ "${upsStatus}" = "n/a" ]; then
echo "UPS service activated but not running"
else

View File

@ -171,10 +171,6 @@ while :
elif [ "${state}" = "sdtoosmall" ]; then
message="SDCARD TOO SMALL - min 16GB"
# when old data - improve message
elif [ "${state}" = "olddata" ]; then
message="login for manual migration"
# when no HDD - improve message
elif [ "${state}" = "noHDD" ]; then
message="Connect external HDD/SSD"

View File

@ -76,8 +76,8 @@ Do you want to start migration to RaspiBlitz now?
echo "******************************************************"
echo "OK MIGRATION --> will now reboot and update/recover"
echo "******************************************************"
#sudo shutdown -h -r now
#sleep 100
sudo shutdown -h -r now
sleep 100
exit 0
else
echo "******************************************************"
@ -322,50 +322,24 @@ if [ ${#setupStep} -eq 0 ]; then
fi
if [ ${setupStep} -eq 0 ]; then
# check data from boostrap
# TODO: when olddata --> CLEAN OR MANUAL-UPDATE-INFO
if [ "${state}" = "olddata" ]; then
# old data setup
BACKTITLE="RaspiBlitz - Manual Update"
TITLE="⚡ Found old RaspiBlitz Data on HDD ⚡"
MENU="\n ATTENTION: OLD DATA COULD CONTAIN FUNDS\n"
OPTIONS+=(MANUAL "read how to recover your old funds")
HEIGHT=11
else
isRaspbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Raspbian')
if [ ${isRaspbian} -gt 0 ]; then
# show hardware test
/home/admin/05hardwareTest.sh
# start setup
BACKTITLE="RaspiBlitz - Setup"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nChoose how you want to setup your RaspiBlitz: \n "
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \
LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" \
MIGRATION "Upload a Migration File from old RaspiBlitz" )
HEIGHT=12
else
# start setup
BACKTITLE="RaspiBlitz - Setup"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nStart to setup your RaspiBlitz: \n "
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning" \
MIGRATION "Upload a Migration File from old RaspiBlitz")
HEIGHT=11
fi
fi
# start setup
BACKTITLE="RaspiBlitz - Setup"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nChoose how you want to setup your RaspiBlitz: \n "
OPTIONS+=(BITCOIN "Setup BITCOIN and Lightning (DEFAULT)" \
LITECOIN "Setup LITECOIN and Lightning (EXPERIMENTAL)" \
MIGRATION "Upload a Migration File from old RaspiBlitz" )
HEIGHT=12
elif [ ${setupStep} -lt 100 ]; then
# continue setup
BACKTITLE="${hostname} / ${network} / ${chain}"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nThe setup process is not finished yet: \n "
OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz")
HEIGHT=10
# continue setup
BACKTITLE="${hostname} / ${network} / ${chain}"
TITLE="⚡ Welcome to your RaspiBlitz ⚡"
MENU="\nThe setup process is not finished yet: \n "
OPTIONS+=(CONTINUE "Continue Setup of your RaspiBlitz")
HEIGHT=10
else

View File

@ -1,176 +0,0 @@
#!/bin/bash
# A solid hardware setup is important to garantuee stability of data
# This script checks the hardware and gives user feedback.
# Start with parameter "no-new-stresstest" to just use the already
# made stresstest report during boostrap script.
# INFOFILE - state data from bootstrap
source /home/admin/raspiblitz.info
source /home/admin/_version.info
clear
echo "*** Hardware Test Report ***"
echo ""
# check for parameter
parameter="$1"
if [ "${parameter}" != "no-new-stresstest" ]; then
sudo /home/admin/config.scripts/blitz.stresstest.sh /home/admin/stresstest.report
echo ""
fi
# load the stresstest values
source /home/admin/stresstest.report
#########################
# Explain Report to User
#########################
# check for power issues
showPowerImproveInfo=0
if [ ${powerWARN} -gt 0 ]; then
showPowerImproveInfo=1
if [ ${powerFAIL} -gt 0 ]; then
whiptail --backtitle "RaspiBlitz v${codeVersion} - ${powerMIN}" --title " POWER SUPPLY CRITICAL " --msgbox "
Your power supply was FAILING the stress test (${powerMIN}).
Most reports of data loss are caused by weak power supplies.
Also a lot of RaspiBlitz setups fail because of weak power supplies.
To SHUTDOWN and upgrade the Power Supply is HIGHLY RECOMMENDED.
See upcomming screen on detailed info how to improve on power supply.
" 14 78
else
whiptail --backtitle "RaspiBlitz v${codeVersion} - ${powerMIN}" --title " Power Supply Warning " --msgbox "
Your power supply seems OK - but could be better for stable operations.
A replacement/upgrade of the Power Supply is recommended if possible.
Because most reports of data loss are caused by weak power supplies.
See upcomming screen on detailed info how to improve on power supply.
" 12 78
fi
fi
if [ ${#undervoltageReports} -gt 0 ]; then
if [ ${undervoltageReports} -gt 0 ]; then
showPowerImproveInfo=1
whiptail --backtitle "RaspiBlitz v${codeVersion}" --title " Runtime Undervoltages Detected " --msgbox "
Already during runtime of RaspiBlitz Undervoltage Reports were detected.
A upgrade of the Power Supply is strongly recommended (see next screen).
You should see the number of outages on your LCD as an ongoing counting.
Note that after replacement of power supply this number is not set to 0.
As long that counting is not going further up you are good.
" 13 78
fi
fi
if [ ${showPowerImproveInfo} -gt 0 ]; then
whiptail --backtitle "RaspiBlitz v${codeVersion}" --title " What todo on Power Issues " --msgbox "
To improve on power issues an upgrade of the power supply is recommended.
Check if you have the latest power supply listed in your shopping list.
If you have that one, please report on GitHub that alternative is needed.
In general a good power supply needs to fullfill this three points:
- needs to deliver at least 3 Ampere
- needs to deliver a stable >=5V output (big & clunky is good)
- needs a thick cable (low AWG score) & best is no switch
If you think all is good with your power supply please also re-run test
up to 3 times. Sometimes a good power supply has 1 or 2 bad measurements.
" 18 78
choice=$(whiptail --backtitle "RaspiBlitz v${codeVersion}" --title " Hardware Check " --menu "What todo about Power Issues?" 12 60 6 \
TESTAGAIN "Run Test again to be sure." \
CONTINUE "I take the risk - continue." \
SHUTDOWN "Shutdown to change hardware." 3>&1 1>&2 2>&3)
if [ ${#choice} -eq 0 ]; then
choice="CONTINUE"
fi
if [ "${choice}" == "TESTAGAIN" ]; then
echo "Shutting down ..."
sudo /home/admin/05hardwareTest.sh
exit 0
elif [ "${choice}" == "SHUTDOWN" ]; then
echo "Shutting down ..."
sudo shutdown now
exit 1
else
echo "OK continue .."
fi
fi
# check for heat issues
showHeatImproveInfo=0
if [ ${tempWARN} -gt 0 ]; then
showHeatImproveInfo=1
if [ ${tempFAIL} -gt 0 ]; then
whiptail --backtitle "RaspiBlitz v${codeVersion} - ${tempMAX}" --title " HEAT MANAGEMENT CRITICAL " --msgbox "
Your RaspiBlitz is getting MUCH TOO HOT (${tempMAX}).
The system is getting very slow when hot - thats not a NO GO but bad.
An upgrade of the Heat Management is HIGHLY RECOMMENDED.
See upcomming screen on detailed info how to improve heat management.
" 12 78
else
whiptail --backtitle "RaspiBlitz v${codeVersion} - ${tempMAX}" --title " Heat Management Warning " --msgbox "
Your RaspiBlitz is getting a bit too hot (${tempMAX}).
The system is getting slow when hot - thats not a NO GO but bad.
An upgrade of the Heat Management is recommended if possible.
See upcomming screen on detailed info how to improve heat management.
" 12 78
fi
fi
if [ ${showHeatImproveInfo} -gt 0 ]; then
whiptail --backtitle "RaspiBlitz v${codeVersion}" --title " What todo on Heat Issues " --msgbox "
To improve on heat issues an upgrade of the casing is recommended.
Check if you have the latest casing options in your shopping list.
Use a big passive heat sink or fan to prevent overheating.
If you have already one, check if its applied correctly to CPU.
In extreme cases consider some external fan helping out.
Again a RaspiBlitz getting hot can be tolerated. But it is
slowing down your CPU and may reduce the lifetime of hardware.
" 16 72
choice=$(whiptail --backtitle "RaspiBlitz v${codeVersion}" --title " Hardware Check " --menu "What todo about Heat Issues?" 12 60 6 \
TESTAGAIN "Run Test again to be sure." \
CONTINUE "I take the risk - continue." \
SHUTDOWN "Shutdown to change hardware." 3>&1 1>&2 2>&3)
if [ ${#choice} -eq 0 ]; then
choice="CONTINUE"
fi
if [ "${choice}" == "TESTAGAIN" ]; then
echo "Shutting down ..."
sudo /home/admin/05hardwareTest.sh
exit 0
elif [ "${choice}" == "SHUTDOWN" ]; then
echo "Shutting down ..."
sudo shutdown now
exit 1
else
echo "OK continue .."
fi
fi
if [ ${showPowerImproveInfo} -eq 0 ] && [ ${showHeatImproveInfo} -eq 0 ]; then
dialog --backtitle "RaspiBlitz v${codeVersion}" --title " Hardware Check " --msgbox "
RaspiBlitz hardware setup looks good :)
You are ready to continue - have fun.
" 8 43
fi

View File

@ -5,8 +5,64 @@ source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
# show password info dialog
resetAlsoPasswordB=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep -c "rpcpassword=passwordB")
if [ ${resetAlsoPasswordB} -eq 0 ]; then
resetAlsoPasswordB=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf 2>/dev/null | grep -c "rpcpassword=passwordB")
resetAlsoPasswordC=$(sudo ls /mnt/hdd/passwordc.flag 2>/dev/null | grep -c ".flag")
if [ ${resetAlsoPasswordC} -gt 0 ]; then
# password A + B + C
dialog --backtitle "RaspiBlitz - Migration Setup" --msgbox "Your migration to RaspiBlitz is almost done.
You need to set a new Password A, B & C:
A) Main User Password (SSH, WebUI, ..)
B) RPC & APP Password (Additional Apps, ..)
C) Lightning Wallet Unlock Password
Follow Password Rules: Minimal of 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 17 52
# call set password a script
sudo /home/admin/config.scripts/blitz.setpassword.sh a
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh b
dialog --backtitle "RaspiBlitz" --msgbox "OK - password B was set\nit will be used by additional apps you install." 6 52
oldPasswordC=$(sudo cat /mnt/hdd/passwordc.flag)
sudo /home/admin/config.scripts/blitz.setpassword.sh c $oldPasswordC
if [ "$?" != "0" ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "Please write down your Password C:\n${oldPasswordC}" 10 52
else
dialog --backtitle "RaspiBlitz" --msgbox "OK - password C was set\nuse it to unlock your Lightning Wallet after restarts." 6 52
fi
elif [ ${resetAlsoPasswordB} -gt 0 ]; then
# password A + B
dialog --backtitle "RaspiBlitz - Migration Setup" --msgbox "Your migration to RaspiBlitz is almost done.
You need to set a new Password A & B:
A) Main User Password (SSH, WebUI, ..)
B) RPC & APP Password (Additional Apps, ..)
Passwords C (for your Lightning wallet) stays to the password you set before.
Follow Password Rules: Minimal of 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 17 52
# call set password a script
sudo /home/admin/config.scripts/blitz.setpassword.sh a
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh b
dialog --backtitle "RaspiBlitz" --msgbox "OK - password B was set\nit will be used by additional apps you install." 6 52
else
# just password A
dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
@ -23,30 +79,11 @@ Write them down & store them in a safe place.
# call set password a script
sudo /home/admin/config.scripts/blitz.setpassword.sh a
else
# password A + B
dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
You need to set a new Password A & B:
A) Main User Password (SSH, WebUI, ..)
B) RPC & APP Password (Additional Apps, ..)
Passwords C (for your Lightning wallet) stays to the password you set before.
Follow Password Rules: Minimal of 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 17 52
# call set password a script
sudo /home/admin/config.scripts/blitz.setpassword.sh a
sudo /home/admin/config.scripts/blitz.setpassword.sh b
fi
# sucess info dialog
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
fi
# activate lnd & bitcoin service
echo "Enabling Services"
sudo systemctl daemon-reload

View File

@ -164,8 +164,8 @@ if [ "$1" == "sourcemode" ]; then
fi
# Basic Options
OPTIONS=(HARDWARE "Run Hardwaretest" \
SOFTWARE "Run Softwaretest (DebugReport)" \
#OPTIONS=(HARDWARE "Run Hardwaretest" \
OPTIONS=(SOFTWARE "Run Softwaretest (DebugReport)" \
BACKUP-LND "Backup your LND data (Rescue-File)" \
MIGRATION "Migrate Blitz Data to new Hardware" \
COPY-SOURCE "Copy Blockchain Source Modus" \
@ -181,15 +181,12 @@ CHOICE=$(whiptail --clear --title "Repair Options" --menu "" 18 62 11 "${OPTIONS
clear
case $CHOICE in
HARDWARE)
sudo /home/admin/05hardwareTest.sh
/home/admin/00mainMenu.sh
;;
# HARDWARE)
# ;;
SOFTWARE)
sudo /home/admin/XXdebugLogs.sh
echo "Press ENTER to return to main menu."
read key
/home/admin/00mainMenu.sh
;;
BACKUP-LND)
sudo /home/admin/config.scripts/lnd.rescue.sh backup
@ -202,7 +199,6 @@ case $CHOICE in
sudo /home/admin/config.scripts/blitz.migration.sh "export-gui"
echo "Press ENTER to return to main menu."
read key
/home/admin/00mainMenu.sh
;;
RESET-CHAIN)
/home/admin/XXcleanHDD.sh -blockchain

View File

@ -291,6 +291,3 @@ HiddenServicePort 8333 127.0.0.1:8333" | sudo tee -a /etc/tor/torrc
esac
;;
esac
# go into loop - start script from beginning to load config/start fresh
/home/admin/00mainMenu.sh

View File

@ -114,6 +114,3 @@ case $CHOICE in
read key
;;
esac
# go into loop - start script from beginning to load config/sate fresh
/home/admin/00mainMenu.sh

View File

@ -193,21 +193,6 @@ if [ ${#undervoltageReports} -gt 0 ]; then
showImproveInfo=1
fi
fi
if [ -f /home/admin/stresstest.report ]; then
sudo cat /home/admin/stresstest.report
source /home/admin/stresstest.report
if [ ${powerWARN} -gt 0 ]; then
showImproveInfo=1
fi
if [ ${tempWARN} -gt 0 ]; then
showImproveInfo=1
fi
fi
if [ ${showImproveInfo} -gt 0 ]; then
echo "IMPORTANT: There are some hardware issues with your setup."
echo "'Run Hardwaretest' in main menu or: sudo /home/admin/05hardwareTest.sh"
fi
echo ""
echo "*** SYSTEM STATUS (can take some seconds to gather) ***"
sudo /home/admin/config.scripts/blitz.statusscan.sh

View File

@ -493,10 +493,9 @@ sudo chown bitcoin:bitcoin -R /mnt/hdd/bitcoin 2>/dev/null
# FIX BLOCKING FILES (just in case)
# https://github.com/rootzoll/raspiblitz/issues/1901#issue-774279088
# https://github.com/rootzoll/raspiblitz/issues/1836#issue-755342375
sudo rm -f /home/bitcoin/.bitcoin/bitcoind.pid 2>/dev/null
sudo rm -f /mnt/hdd/bitcoin/bitcoind.pid 2>/dev/null
sudo rm -f /mnt/hdd/bitcoin/.lock 2>/dev/null
#################################
# MAKE SURE USERS HAVE LATEST LND CREDENTIALS
#################################
@ -600,22 +599,6 @@ else
sudo chown admin:admin /mnt/hdd/app-data/subscriptions
fi
################################
# STRESSTEST RASPBERRY PI
################################
if [ "${baseimage}" = "raspbian" ] || [ "${baseimage}" = "raspios_arm64" ]; then
# generate stresstest report on every startup (in case hardware has changed)
sed -i "s/^state=.*/state=stresstest/g" ${infoFile}
sed -i "s/^message=.*/message='Testing Hardware 60s'/g" ${infoFile}
sudo /home/admin/config.scripts/blitz.stresstest.sh /home/admin/stresstest.report
source /home/admin/stresstest.report
if [ "${powerWARN}" = "0" ]; then
# https://github.com/rootzoll/raspiblitz/issues/576
echo "" > /var/log/syslog
fi
fi
# mark that node is ready now
sed -i "s/^state=.*/state=ready/g" ${infoFile}
sed -i "s/^message=.*/message='Node Running'/g" ${infoFile}

View File

@ -12,9 +12,9 @@ After=bootstrap.service
User=bitcoin
Group=bitcoin
Type=forking
PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid
PIDFile=/mnt/hdd/bitcoin/bitcoind.pid
ExecStartPre=-/home/admin/config.scripts/blitz.systemd.sh log blockchain STARTED
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid
ExecStart=/usr/local/bin/bitcoind -daemon -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/mnt/hdd/bitcoin/bitcoind.pid
KillMode=process
Restart=always
TimeoutSec=120

View File

@ -259,7 +259,7 @@ if [ "$1" = "status" ]; then
if [ ${isUmbrelHDD} -gt 0 ]; then
hddGotMigrationData="umbrel"
fi
isMyNodeHDD=$(sudo ls /mnt/storage/bitcoin/bitcoin.conf 2>/dev/null | grep -c '.conf')
isMyNodeHDD=$(sudo ls /mnt/storage/mynode/bitcoin/bitcoin.conf 2>/dev/null | grep -c '.conf')
if [ ${isMyNodeHDD} -gt 0 ]; then
hddGotMigrationData="mynode"
fi

View File

@ -89,7 +89,7 @@ migrate_raspiblitz_conf () {
echo "network=bitcoin" >> /home/admin/raspiblitz.conf
echo "chain=main" >> /home/admin/raspiblitz.conf
echo "hostname=${nodename}" >> /home/admin/raspiblitz.conf
echo "displayClass=hdmi" >> /home/admin/raspiblitz.conf
echo "displayClass=lcd" >> /home/admin/raspiblitz.conf
echo "lcdrotate=1" >> /home/admin/raspiblitz.conf
echo "runBehindTor=on" >> /home/admin/raspiblitz.conf
sudo mv /home/admin/raspiblitz.conf /mnt/hdd/raspiblitz.conf
@ -176,9 +176,6 @@ if [ "$1" = "migration-mynode" ]; then
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
echo "IMPORTANT TODO -> take care about lnd wallet password - see: https://btc21.de/bitcoin/raspiblitz-migration/"
exit 1
# can olny migrate unmonted data disks
if [ "${isMounted}" == "1" ]; then
echo "err='cannot migrate mounted drive'"
@ -224,9 +221,11 @@ if [ "$1" = "migration-mynode" ]; then
sudo chown bitcoin:bitcoin -R /mnt/hdd/lnd
migrate_lnd_conf
# copy lnd wallet password - so that user can set own on final setup
sudo cp /mnt/hdd/mynode/settings/.lndpw /mnt/hdd/passwordc.flag
# backup & rename the rest of the data
sudo mv /mnt/hdd/mynode /mnt/hdd/backup_migration
sudo rm
# call function for final migration
migrate_raspiblitz_conf

View File

@ -3,7 +3,9 @@
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small config script to set a passwords A,B,C & D"
echo "blitz.setpassword.sh [?a|b|c|d] [?newpassword] "
echo "blitz.setpassword.sh a [?newpassword] "
echo "blitz.setpassword.sh b [?newpassword] "
echo "blitz.setpassword.sh c [?oldpassword] [?newpassword] "
echo "or just as a password enter dialog (result as file)"
echo "blitz.setpassword.sh [x] [text] [result-file] [?empty-allowed]"
echo "exits on 0 = needs reboot"
@ -29,18 +31,9 @@ if [ ${#chain} -eq 0 ]; then
chain="main"
fi
# 1. parameter [?a|b|c|d]
# 1. parameter [?a|b|c]
abcd=$1
# 2. parameter [?newpassword]
newPassword=$2
# 4. parameter [?newpassword]
emptyAllowed=0
if [ "$4" == "empty-allowed" ]; then
emptyAllowed=1
fi
# run interactive if no further parameters
OPTIONS=()
if [ ${#abcd} -eq 0 ]; then
@ -48,7 +41,6 @@ if [ ${#abcd} -eq 0 ]; then
OPTIONS+=(A "Master User Password / SSH")
OPTIONS+=(B "RPC Password (blockchain/lnd)")
OPTIONS+=(C "LND Wallet Password")
OPTIONS+=(D "LND Seed Password")
CHOICE=$(dialog --clear \
--backtitle "RaspiBlitz" \
--title "Set Password" \
@ -83,6 +75,8 @@ echo ""
# PASSWORD A
if [ "${abcd}" = "a" ]; then
newPassword=$2
# if no password given by parameter - ask by dialog
if [ ${#newPassword} -eq 0 ]; then
clear
@ -158,6 +152,8 @@ if [ "${abcd}" = "a" ]; then
# PASSWORD B
elif [ "${abcd}" = "b" ]; then
newPassword=$2
# if no password given by parameter - ask by dialog
if [ ${#newPassword} -eq 0 ]; then
clear
@ -298,50 +294,104 @@ EOF
# PASSWORD C
elif [ "${abcd}" = "c" ]; then
if [ ${#newPassword} -gt 0 ]; then
echo "New password C cannot be set thru paramter .. will start interactive password setting."
echo "PRESS ENTER to continue"
read key
oldPassword=$2
newPassword=$3
if [ "${oldPassword}" == "" ]; then
# ask user for old password c
clear
oldPassword=$(whiptail --passwordbox "\nEnter old Password C:\n" 10 52 "" --title "Old Password C" --backtitle "RaspiBlitz - Passwords" 3>&1 1>&2 2>&3)
if [ $? -eq 1 ] || [ "${oldPassword}" == "" ]; then
sudo /home/admin/config.scripts/blitz.setpassword.sh c
fi
echo "OK ... processing"
fi
clear
echo ""
echo "****************************************************************************"
echo "Change LND Wallet Password --> lncli --chain=${network} --network=${chain}net changepassword"
echo "****************************************************************************"
echo "This is your Password C on the RaspiBlitz to unlock your LND wallet."
echo "If you had Auto-Unlock active - you need to re-activate after this."
echo "****************************************************************************"
if [ "${newPassword}" == "" ]; then
clear
# ask user for new password c
newPassword=$(whiptail --passwordbox "\nEnter new Password C:\n" 10 52 "" --title "New Password C" --backtitle "RaspiBlitz - Passwords" 3>&1 1>&2 2>&3)
if [ $? -eq 1 ] || [ "${newPassword}" == "" ]; then
sudo /home/admin/config.scripts/blitz.setpassword.sh c ${oldPassword}
exit 0
fi
# check new password does not contain bad characters
clearedResult=$(echo "${newPassword}" | tr -dc '[:alnum:]-.' | tr -d ' ')
if [ ${#clearedResult} != ${#newPassword} ] || [ ${#clearedResult} -eq 0 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Contains bad characters (spaces, special chars)" 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh c ${oldPassword}
exit 0
fi
# check new password longer than 8
if [ ${#newPassword} -lt 8 ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Password length under 8" 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh c ${oldPassword}
exit 1
fi
# ask user to retype new password c
newPassword2=$(whiptail --passwordbox "\nEnter again new Password C:\n" 10 52 "" --title "New Password C (repeat)" --backtitle "RaspiBlitz - Passwords" 3>&1 1>&2 2>&3)
if [ $? -eq 1 ] || [ "${newPassword}" == "" ]; then
sudo /home/admin/config.scripts/blitz.setpassword.sh c ${oldPassword}
exit 0
fi
echo "OK ... processing"
# check if passwords match
if [ "${newPassword}" != "${newPassword2}" ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Passwords dont Match" 6 52
sudo /home/admin/config.scripts/blitz.setpassword.sh c ${oldPassword}
exit 0
fi
echo "OK ... processing"
fi
#echo "oldPassword: ${oldPassword}"
#echo "newPassword: ${newPassword}"
echo "# Make sure Auto-Unlocks off"
sudo /home/admin/config.scripts/lnd.autounlock.sh off
echo "LND needs to be restarted to lock wallet first .. (please wait)"
sudo systemctl restart lnd
sleep 6
sleep 2
err=""
source <(sudo /home/admin/config.scripts/lnd.initwallet.py change-password $oldPassword $newPassword)
if [ "${err}" != "" ]; then
dialog --backtitle "RaspiBlitz - Setup" --msgbox "FAIL -> Was not able to change password\n\n${err}\n${errMore}" 10 52
clear
echo "# FAIL: Was not able to change password"
exit 1
fi
# old manual way
# clear
# echo ""
# echo "****************************************************************************"
# echo "Change LND Wallet Password --> lncli --chain=${network} --network=${chain}net changepassword"
# echo "****************************************************************************"
# echo "This is your Password C on the RaspiBlitz to unlock your LND wallet."
# echo "If you had Auto-Unlock active - you need to re-activate after this."
# echo "****************************************************************************"
# sleep 6
# let LND-CLI handle the password change
sudo -u bitcoin lncli --chain=${network} --network=${chain}net changepassword
# deactivate AUTO-UNLOCK if activated
echo ""
echo "# Make sure Auto-Unlocks off"
sudo /home/admin/config.scripts/lnd.autounlock.sh off
# sudo -u bitcoin lncli --chain=${network} --network=${chain}net changepassword
# final user output
echo ""
echo "OK"
exit 0
############################
# PASSWORD D
elif [ "${abcd}" = "d" ]; then
echo "#### NOTICE ####"
echo "Sorry - the password D cannot be changed. Its the password you set on creating your wallet to protect your seed (the list of words)."
exit 1
############################
# PASSWORD X
elif [ "${abcd}" = "x" ]; then
emptyAllowed=0
if [ "$4" == "empty-allowed" ]; then
emptyAllowed=1
fi
# second parameter is the flexible text
text=$2
resultFile=$3

View File

@ -1,134 +0,0 @@
#!/bin/bash
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "run stress test to measure heat and voltage"
echo "blitz.stresstest.sh [?filenameForReport]"
exit 1
fi
isRaspbian=$(cat /etc/os-release 2>/dev/null | grep -c 'Raspbian')
if [ ${isRaspbian} -eq 0 ]; then
echo "the OS is not Raspbian - the stresstest is only for the Raspberry Pi"
exit 0
fi
# Based on https://github.com/bamarni/pi64/issues/4#issuecomment-292707581
# sysbench manual: http://imysql.com/wp-content/uploads/2014/10/sysbench-manual.pdf
# get parameter
filenameForReport=$1
# check if bechmarking tool is installed
sysbenchInstalled=$(sysbench --version 2>/dev/null | grep -c 'sysbench 0.')
if [ ${sysbenchInstalled} -eq 0 ];then
sudo apt install -y sysbench
fi
# do debug outputs to the STDERR - so that the STDOUT is just the results in the end
echo "RaspiBlitz Hardwaretest v0.2" >&2
# detect hardware version of RaspberryPi
# https://www.unixtutorial.org/command-to-confirm-raspberry-pi-model
raspberryPi=$(cat /proc/device-tree/model | cut -d " " -f 3 | sed 's/[^0-9]*//g')
if [ ${#raspberryPi} -eq 0 ]; then
raspberryPi=0
fi
echo "RaspberryPi Model Version: ${raspberryPi}"
if [ ${raspberryPi} -lt 4 ]; then
# raspberryPi 3 and lower (microUSB power connector)
voltWARN=1230000
voltFAIL=1200100
tempWARNING=6500
tempCRTICAL=6999
else
# raspberryPi 4 and up (USB-C power connector)
voltWARN=833200
voltFAIL=823200
tempWARNING=6900
tempCRTICAL=7799
fi
echo "Starting sysbench to run for 60 seconds (--max-time=60 --cpu-max-prime=100000)" >&2
# result values
powerWARN=0
powerFAIL=0
powerMIN=9999999
tempWARN=0
tempFAIL=0
tempMAX=0
# starting bench mark
sysbench --max-time=60 --test=cpu --cpu-max-prime=100000 --num-threads=4 run 1>/dev/null 2>&1 &
# keep monitoring in the background
Maxfreq=$(( $(awk '{printf ("%0.0f",$1/1000); }' </sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq) -15 ))
for (( n=0; n<15; ++n )); do
# make measurements
Temp=$(sudo vcgencmd measure_temp | cut -f2 -d=)
RealClockspeed=$(sudo vcgencmd measure_clock arm | awk -F"=" '{printf ("%0.0f",$2/1000000); }' )
SysFSClockspeed=$(awk '{printf ("%0.0f",$1/1000); }' </sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
CoreVoltage=$(sudo vcgencmd measure_volts | cut -f2 -d= | sed 's/000//')
# debug output
if [ ${RealClockspeed} -ge ${Maxfreq} ]; then
echo "${Temp}$(printf "%5s" ${SysFSClockspeed}) MHz ${CoreVoltage}" >&2
else
echo "${Temp}$(printf "%5s" ${RealClockspeed})/$(printf "%4s" ${SysFSClockspeed}) MHz ${CoreVoltage}" >&2
fi
# analyse Voltage
voltFloat=$(echo "${CoreVoltage/V/}*1000000" | bc)
voltInt=${voltFloat/.*}
#echo "V -> ${voltFloat}/${voltInt}"
if [ ${voltInt} -lt ${voltFAIL} ] && [ ${powerWARN} -gt 1 ]; then
((powerFAIL=powerFAIL+1))
echo "--> Power CRITICAL detected" >&2
fi
if [ ${voltInt} -lt ${voltWARN} ]; then
((powerWARN=powerWARN+1))
echo "--> Power WARN detected" >&2
fi
if [ ${voltInt} -lt ${powerMIN} ]; then
powerMIN=${voltInt}
fi
# analyse Temp
tempFloat=$(echo "${Temp/\'C/}*100" | bc)
tempInt=${tempFloat/.*}
#echo "T -> ${tempFloat}/${tempInt}"
if [ ${tempInt} -gt ${tempCRTICAL} ]; then
((tempFAIL=tempFAIL+1))
echo "--> Temp CRITICAL detected" >&2
fi
if [ ${tempInt} -gt ${tempWARNING} ]; then
((tempWARN=tempWARN+1))
echo "--> Temp WARN detected" >&2
fi
if [ ${tempInt} -gt ${tempMAX} ]; then
tempMAX=${tempInt}
fi
sleep 5
done
if [ ${#filenameForReport} -eq 0 ]; then
echo "raspberryPi=${raspberryPi}"
echo "powerFAIL=${powerFAIL}"
echo "powerWARN=${powerWARN}"
echo "powerMIN='${powerMIN} microVolt'"
echo "tempFAIL=${tempFAIL}"
echo "tempWARN=${tempWARN}"
echo "tempMAX='${tempMAX} centiGrad'"
else
echo "raspberryPi=${raspberryPi}" >${filenameForReport}
echo "powerFAIL=${powerFAIL}" >>${filenameForReport}
echo "powerWARN=${powerWARN}" >>${filenameForReport}
echo "powerMIN='${powerMIN} microVolt'" >>${filenameForReport}
echo "tempFAIL=${tempFAIL}" >>${filenameForReport}
echo "tempWARN=${tempWARN}" >>${filenameForReport}
echo "tempMAX='${tempMAX} centiGrad'" >>${filenameForReport}
sudo chmod 744 ${filenameForReport}
fi

View File

@ -18,6 +18,7 @@ if len(sys.argv) <= 1 or sys.argv[1] in ["-h", "--help", "help"]:
print("# lnd.initwallet.py new [walletpassword] [?seedpassword]")
print("# lnd.initwallet.py seed [walletpassword] [\"seeds-words-seperated-spaces\"] [?seedpassword]")
print("# lnd.initwallet.py scb [walletpassword] [\"seeds-words-seperated-spaces\"] [filepathSCB] [?seedpassword]")
print("# lnd.initwallet.py change-password [walletpassword-old] [walletpassword-new]")
print("err='missing parameters'")
sys.exit(1)
@ -138,9 +139,35 @@ def scb(stub, wallet_password="", seed_words="", seed_password="", file_path_scb
print("err='TODO: implement creating from seed/scb'")
sys.exit(1)
def change_password(stub, wallet_password="", wallet_password_new=""):
request = lnrpc.ChangePasswordRequest(
current_password=wallet_password.encode(),
new_password=wallet_password_new.encode()
)
try:
response = stub.ChangePassword(request)
print("# ok - password changed")
#print(response.admin_macaroon)
except grpc.RpcError as rpc_error_call:
code = rpc_error_call.code()
print(code, file=sys.stderr)
details = rpc_error_call.details()
print("err='RPCError ChangePassword'")
print("errMore=\"" + details + "\"")
print("# make sure wallet is locked when trying to change password'", file=sys.stderr)
sys.exit(1)
except:
e = sys.exc_info()[0]
print(e, file=sys.stderr)
print("err='ChangePassword'")
sys.exit(1)
def parse_args():
wallet_password = ""
wallet_password_new = ""
seed_words = ""
seed_password = ""
filepath_scb = ""
@ -152,12 +179,27 @@ def parse_args():
print("err='wallet password is too short'")
sys.exit(1)
else:
print("err='wallet password is too short'")
print("err='missing parameters'")
sys.exit(1)
if len(sys.argv) > 3:
seed_password = sys.argv[3]
elif mode == "change-password":
if len(sys.argv) > 3:
wallet_password = sys.argv[2]
if len(wallet_password) < 8:
print("err='wallet password is too short'")
sys.exit(1)
wallet_password_new = sys.argv[3]
if len(wallet_password_new ) < 8:
print("err='wallet password new is too short'")
sys.exit(1)
else:
print("err='missing parameters'")
sys.exit(1)
elif mode == "seed" or mode == "scb":
if len(sys.argv) > 2:
@ -206,7 +248,7 @@ def parse_args():
print("err='unknown mode parameter - run without any parameters to see options'")
sys.exit(1)
return wallet_password, seed_words, seed_password, filepath_scb
return wallet_password, seed_words, seed_password, filepath_scb, wallet_password_new
def main():
@ -216,7 +258,7 @@ def main():
channel = grpc.secure_channel('localhost:10009', ssl_creds)
stub = rpcstub.WalletUnlockerStub(channel)
wallet_password, seed_words, seed_password, file_path_scb = parse_args()
wallet_password, seed_words, seed_password, file_path_scb, wallet_password_new = parse_args()
if mode == "new":
print("# *** CREATING NEW LND WALLET ***")
@ -230,6 +272,10 @@ def main():
print("# *** RECOVERING LND WALLET FROM SEED + SCB ***")
scb(stub, wallet_password, seed_words, seed_password, file_path_scb)
elif mode == "change-password":
print("# *** SETTING NEW PASSWORD FOR WALLET ***")
change_password(stub, wallet_password, wallet_password_new)
if __name__ == '__main__':
main()