replace password entry in setup

This commit is contained in:
rootzoll 2019-01-14 18:34:21 +01:00
parent 52910319ba
commit 099e4f3f62
3 changed files with 46 additions and 121 deletions

View file

@ -385,6 +385,8 @@ case $CHOICE in
read key
sudo shutdown -r now
else
echo "Press ENTER to return to main menu .."
read key
./00mainMenu.sh
fi
;;

View file

@ -1,13 +1,8 @@
#!/bin/bash
_temp="./download/dialog.$$"
## get basic info
source /mnt/hdd/raspiblitz.conf
passwordValid=0
result=""
while [ ${passwordValid} -eq 0 ]
do
# show password info dialog
dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
@ -21,30 +16,11 @@ no spaces and only special characters - or .
Write them down & store them in a safe place.
" 14 52
# ask user for new password A
dialog --backtitle "RaspiBlitz - Setup"\
--inputbox "Please enter your Master/Admin Password A:\n!!! This is new password to login per SSH !!!" 10 52 2>$_temp
# call set password a script
sudo /home/admin/config.scripts/blitz.setpassword.sh a
# get user input
result=$( cat $_temp )
shred $_temp
passwordValid=1
clearedResult=$(echo "${result}" | tr -dc '[:alnum:]-.' | tr -d ' ')
if [ ${#clearedResult} != ${#result} ] || [ ${#clearedResult} -eq 0 ]; then
clear
echo "FAIL - Password contained not allowed chars (see next screen)"
echo "Press ENTER to continue .."
read key
passwordValid=0
else
# change user passwords and then change hostname
echo "pi:$result" | sudo chpasswd
echo "root:$result" | sudo chpasswd
echo "bitcoin:$result" | sudo chpasswd
echo "admin:$result" | sudo chpasswd
sleep 1
# sucess info dialog
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
# activate lnd & bitcoin service
echo "Enabling Services"
@ -73,15 +49,7 @@ to deactivate the Auto-Unlock feature.
dialog --backtitle "RaspiBlitz" --msgbox "FINAL REBOOT IS NEEDED." 6 52
else
dialog --backtitle "RaspiBlitz" --msgbox "New SSH password A is '$result'\nFINAL REBOOT IS NEEDED." 6 52
dialog --backtitle "RaspiBlitz" --msgbox "OK - SSH password A set.\nFINAL REBOOT IS NEEDED." 6 52
fi
sudo shutdown -r now
fi
done

View file

@ -4,6 +4,10 @@ _temp="./download/dialog.$$"
## get basic info
source /home/admin/raspiblitz.info 2>/dev/null
###################
# ENTER NAME
###################
# welcome and ask for name of RaspiBlitz
result=""
while [ ${#result} -eq 0 ]
@ -29,11 +33,10 @@ else
sed -i "s/^hostname=.*/hostname=${result}/g" /home/admin/raspiblitz.info
fi
###################
# ENTER PASSWORDS
###################
passwordValid=0
result=""
while [ ${passwordValid} -eq 0 ]
do
# show password info dialog
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --msgbox "RaspiBlitz uses 4 different passwords.
Referenced as password A, B, C and D.
@ -48,63 +51,15 @@ no spaces and only special characters - or .
Write them down & store them in a safe place.
" 15 52
# ask user for new password A
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})"\
--inputbox "Please enter your Master/Admin Password A:\n!!! This is new password to login per SSH !!!" 10 52 2>$_temp
# get user input
result=$( cat $_temp )
shred $_temp
passwordValid=1
clearedResult=$(echo "${result}" | tr -dc '[:alnum:]-.' | tr -d ' ')
if [ ${#clearedResult} != ${#result} ] || [ ${#clearedResult} -eq 0 ]; then
clear
echo "FAIL - Password contained not allowed chars (see next screen)"
echo "Press ENTER to continue .."
read key
passwordValid=0
else
# change user passwords and then change hostname
echo "pi:$result" | sudo chpasswd
echo "root:$result" | sudo chpasswd
echo "bitcoin:$result" | sudo chpasswd
echo "admin:$result" | sudo chpasswd
sleep 1
# call set password a script
sudo /home/admin/config.scripts/blitz.setpassword.sh a
# sucess info dialog
dialog --backtitle "RaspiBlitz" --msgbox "OK - password changed to '$result'\nfor all users pi, admin, root & bitcoin" 6 52
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
# repeat until user input is nit length 0
result=""
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})"\
--inputbox "Enter your RPC Password B:" 9 52 2>$_temp
result=$( cat $_temp )
shred $_temp
clearedResult=$(echo "${result}" | tr -dc '[:alnum:]-.' | tr -d ' ')
if [ ${#clearedResult} != ${#result} ] || [ ${#clearedResult} -eq 0 ]; then
clear
echo "FAIL - Password contained not allowed chars (see next screen)"
echo "Press ENTER to continue to start again"
read key
passwordValid=0
else
# set Blockchain RPC Password (for admin cli & template for user bitcoin)
sed -i "s/^rpcpassword=.*/rpcpassword=${result}/g" /home/admin/assets/${network}.conf
sed -i "s/^${network}d.rpcpass=.*/${network}d.rpcpass=${result}/g" /home/admin/assets/lnd.${network}.conf
# call set password b script
sudo /home/admin/config.scripts/blitz.setpassword.sh b
# success info dialog
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --msgbox "OK - RPC password changed to '$result'\n\nNow starting the Setup of your RaspiBlitz." 7 52
dialog --backtitle "RaspiBlitz" --msgbox "OK - RPC password changed \n\nNow starting the Setup of your RaspiBlitz." 7 52
clear
fi
fi
done