Browse Source

replace password entry in setup

dev
rootzoll 6 years ago
parent
commit
099e4f3f62
  1. 2
      home.admin/00mainMenu.sh
  2. 74
      home.admin/20recoverDialog.sh
  3. 81
      home.admin/20setupDialog.sh

2
home.admin/00mainMenu.sh

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

74
home.admin/20recoverDialog.sh

@ -1,15 +1,10 @@
#!/bin/bash #!/bin/bash
_temp="./download/dialog.$$"
## get basic info ## get basic info
source /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf
passwordValid=0 # show password info dialog
result="" dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
while [ ${passwordValid} -eq 0 ]
do
# show password info dialog
dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
You need to set a new Password A: You need to set a new Password A:
A) Master User Password A) Master User Password
@ -21,45 +16,26 @@ no spaces and only special characters - or .
Write them down & store them in a safe place. Write them down & store them in a safe place.
" 14 52 " 14 52
# ask user for new password A # call set password a script
dialog --backtitle "RaspiBlitz - Setup"\ sudo /home/admin/config.scripts/blitz.setpassword.sh a
--inputbox "Please enter your Master/Admin Password A:\n!!! This is new password to login per SSH !!!" 10 52 2>$_temp
# get user input # sucess info dialog
result=$( cat $_temp ) dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
shred $_temp
passwordValid=1
clearedResult=$(echo "${result}" | tr -dc '[:alnum:]-.' | tr -d ' ') # activate lnd & bitcoin service
if [ ${#clearedResult} != ${#result} ] || [ ${#clearedResult} -eq 0 ]; then echo "Enabling Services"
clear sudo systemctl daemon-reload
echo "FAIL - Password contained not allowed chars (see next screen)" sudo systemctl enable lnd.service
echo "Press ENTER to continue .." sudo systemctl enable ${network}d.service
read key if [ "${rtlWebinterface}" = "on" ]; then
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
# activate lnd & bitcoin service
echo "Enabling Services"
sudo systemctl daemon-reload
sudo systemctl enable lnd.service
sudo systemctl enable ${network}d.service
if [ "${rtlWebinterface}" = "on" ]; then
sudo systemctl enable RTL sudo systemctl enable RTL
fi fi
# remove flag that freshly recovered # remove flag that freshly recovered
sudo rm /home/admin/raspiblitz.recover.info sudo rm /home/admin/raspiblitz.recover.info
# when auto-unlock is activated then Password C is needed to be restored on SD card # when auto-unlock is activated then Password C is needed to be restored on SD card
if [ "${autoUnlock}" = "on" ]; then if [ "${autoUnlock}" = "on" ]; then
# reset auto-unlock feature # reset auto-unlock feature
dialog --backtitle "RaspiBlitz - Setup" --msgbox "You had the Auto-Unlock feature enabled. dialog --backtitle "RaspiBlitz - Setup" --msgbox "You had the Auto-Unlock feature enabled.
@ -72,16 +48,8 @@ to deactivate the Auto-Unlock feature.
sudo /home/admin/config.scripts/lnd.autounlock.sh on sudo /home/admin/config.scripts/lnd.autounlock.sh on
dialog --backtitle "RaspiBlitz" --msgbox "FINAL REBOOT IS NEEDED." 6 52 dialog --backtitle "RaspiBlitz" --msgbox "FINAL REBOOT IS NEEDED." 6 52
else 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 fi
sudo shutdown -r now
fi
done
sudo shutdown -r now

81
home.admin/20setupDialog.sh

@ -4,6 +4,10 @@ _temp="./download/dialog.$$"
## get basic info ## get basic info
source /home/admin/raspiblitz.info 2>/dev/null source /home/admin/raspiblitz.info 2>/dev/null
###################
# ENTER NAME
###################
# welcome and ask for name of RaspiBlitz # welcome and ask for name of RaspiBlitz
result="" result=""
while [ ${#result} -eq 0 ] while [ ${#result} -eq 0 ]
@ -29,13 +33,12 @@ else
sed -i "s/^hostname=.*/hostname=${result}/g" /home/admin/raspiblitz.info sed -i "s/^hostname=.*/hostname=${result}/g" /home/admin/raspiblitz.info
fi fi
###################
# ENTER PASSWORDS
###################
passwordValid=0 # show password info dialog
result="" dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --msgbox "RaspiBlitz uses 4 different passwords.
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. Referenced as password A, B, C and D.
A) Master User Password A) Master User Password
@ -48,63 +51,15 @@ no spaces and only special characters - or .
Write them down & store them in a safe place. Write them down & store them in a safe place.
" 15 52 " 15 52
# ask user for new password A # call set password a script
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})"\ sudo /home/admin/config.scripts/blitz.setpassword.sh a
--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
# sucess info dialog
dialog --backtitle "RaspiBlitz" --msgbox "OK - password changed to '$result'\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
# 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
clear
fi
fi
done
# sucess info dialog
dialog --backtitle "RaspiBlitz" --msgbox "OK - password A was set\nfor all users pi, admin, root & bitcoin" 6 52
# call set password b script
sudo /home/admin/config.scripts/blitz.setpassword.sh b
# success info dialog
dialog --backtitle "RaspiBlitz" --msgbox "OK - RPC password changed \n\nNow starting the Setup of your RaspiBlitz." 7 52
clear
Loading…
Cancel
Save