raspiblitz/home.admin/20recoverDialog.sh

88 lines
2.5 KiB
Bash
Raw Normal View History

2018-12-05 00:07:58 +01:00
#!/bin/bash
2018-07-17 13:12:03 +02:00
_temp="./download/dialog.$$"
2018-12-06 14:36:02 +01:00
## get basic info
2018-12-12 18:21:01 +01:00
source /mnt/hdd/raspiblitz.conf
2018-07-29 01:33:54 +02:00
2018-11-28 12:42:52 +01:00
passwordValid=0
result=""
2018-11-28 12:47:15 +01:00
while [ ${passwordValid} -eq 0 ]
2018-11-28 12:42:52 +01:00
do
# show password info dialog
2018-12-12 18:21:01 +01:00
dialog --backtitle "RaspiBlitz - Recover Setup" --msgbox "Your previous RaspiBlitz config was recovered.
2018-07-17 13:12:03 +02:00
2018-12-12 18:21:01 +01:00
You need to set a new Password A:
2018-07-17 13:12:03 +02:00
A) Master User Password
2018-12-12 18:21:01 +01:00
Passwords B, C & D stay as before.
Follow Password Rules: Minimal of 8 chars,
2018-11-27 21:11:53 +01:00
no spaces and only special characters - or .
2018-07-17 13:12:03 +02:00
Write them down & store them in a safe place.
2018-12-12 18:21:01 +01:00
" 14 52
2018-07-17 13:12:03 +02:00
2018-11-28 12:42:52 +01:00
# ask user for new password A
dialog --backtitle "RaspiBlitz - Setup"\
2018-07-17 13:12:03 +02:00
--inputbox "Please enter your Master/Admin Password A:\n!!! This is new password to login per SSH !!!" 10 52 2>$_temp
2018-11-28 12:42:52 +01:00
# get user input
result=$( cat $_temp )
shred $_temp
passwordValid=1
2018-11-28 14:07:33 +01:00
clearedResult=$(echo "${result}" | tr -dc '[:alnum:]-.' | tr -d ' ')
2018-11-28 14:17:21 +01:00
if [ ${#clearedResult} != ${#result} ] || [ ${#clearedResult} -eq 0 ]; then
2018-11-28 12:42:52 +01:00
clear
2018-11-28 14:07:33 +01:00
echo "FAIL - Password contained not allowed chars (see next screen)"
2018-11-28 12:42:52 +01:00
echo "Press ENTER to continue .."
2018-11-28 12:51:16 +01:00
read key
2018-11-28 12:42:52 +01:00
passwordValid=0
2018-11-28 14:13:17 +01:00
else
2018-11-28 14:17:21 +01:00
# 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
2018-12-12 18:21:01 +01:00
# activate lnd & bitcoin service
echo "Enabling Services"
sudo systemctl daemon-reload
sudo systemctl enable lnd.service
sudo systemctl enable ${network}d.service
2018-12-12 18:29:49 +01:00
if [ "${rtlWebinterface}" = "on" ]; then
sudo systemctl enable RTL
fi
2018-12-12 18:21:01 +01:00
2018-12-12 18:23:03 +01:00
# remove flag that freshly recovered
sudo rm /home/admin/raspiblitz.recover.info
2018-12-22 16:44:15 +01:00
# when auto-unlock is activated then Password C is needed to be restored on SD card
if [ "${autoUnlock}" = "on" ]; then
2018-12-24 02:51:11 +01:00
# reset auto-unlock feature
dialog --backtitle "RaspiBlitz - Setup" --msgbox "You had the Auto-Unlock feature enabled.
In the next dialog you need to re-enter your
ACTUAL/OLD Password C to re-activate the
Auto-Unlock feature. Enter a empty password
to deactivate the Auto-Unlock feature.
" 10 52
sudo /home/admin/config.scripts/lnd.autounlock.sh on
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
2018-12-22 16:44:15 +01:00
fi
sudo shutdown -r now
2018-11-28 14:13:17 +01:00
fi
2018-07-17 13:12:03 +02:00
done
2018-12-12 18:21:01 +01:00
2018-07-29 01:33:54 +02:00
2018-11-28 14:13:17 +01:00