raspiblitz/home.admin/20initDialog.sh

92 lines
3.0 KiB
Bash
Raw Normal View History

2018-07-17 13:12:03 +02:00
#!/bin/sh
_temp="./download/dialog.$$"
2018-07-29 01:33:54 +02:00
# load network
network=`cat .network`
2018-07-17 13:12:03 +02:00
# welcome and ask for name of RaspiBlitz
result=""
while [ ${#result} -eq 0 ]
do
l1="Please enter the name of your new RaspiBlitz:\n"
l2="one word, keep characters basic & not too long"
2018-07-25 17:40:50 +02:00
dialog --backtitle "RaspiBlitz - Setup" --inputbox "$l1$l2" 11 52 2>$_temp
2018-09-21 15:12:37 +02:00
result=$( cat $_temp | tr -d [:space:] )
2018-07-17 13:12:03 +02:00
shred $_temp
done
# set lightning alias
sed -i "s/^alias=.*/alias=${result}/g" /home/admin/assets/lnd.${network}.conf
2018-07-17 13:12:03 +02:00
# store hostname for later - to be set right before the next reboot
# work around - because without a reboot the hostname seems not updates in the whole system
2018-07-31 20:13:08 +02:00
echo $result > /home/admin/.hostname
2018-07-17 13:12:03 +02:00
# show password info dialog
2018-07-25 17:40:50 +02:00
dialog --backtitle "RaspiBlitz - Setup" --msgbox "RaspiBlitz uses 4 different passwords.
2018-07-17 13:12:03 +02:00
Referenced as password A, B, C and D.
A) Master User Password
2018-07-29 01:33:54 +02:00
B) Blockchain RPC Password
2018-07-17 13:12:03 +02:00
C) LND Wallet Password
D) LND Seed Password
Choose now 4 new passwords - all min 8 chars
Write them down & store them in a safe place.
" 14 52
# ask user for new password A
2018-07-25 17:40:50 +02:00
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
# get user input
2018-09-21 15:12:37 +02:00
result=$( cat $_temp )
2018-07-17 13:12:03 +02:00
shred $_temp
# check input (check for more later)
if [ ${#result} -eq 0 ]; then
clear
echo "FAIL - Password cannot be empty"
echo "Please restart with ./00mainMenu.sh"
exit 1
fi
# 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=""
while [ ${#result} -lt 8 ]
do
2018-07-25 17:40:50 +02:00
dialog --backtitle "RaspiBlitz - Setup"\
2018-07-17 13:12:03 +02:00
--inputbox "Enter your RPC Password B (min 8 chars):" 9 52 2>$_temp
2018-09-21 15:12:37 +02:00
result=$( cat $_temp )
2018-07-17 13:12:03 +02:00
shred $_temp
done
2018-07-29 01:33:54 +02:00
# set Blockchain RPC Password (for admin cli & template for user bitcoin)
sed -i "s/^rpcpassword=.*/rpcpassword=${result}/g" /home/admin/assets/${network}.conf
2018-08-14 12:56:00 +02:00
sed -i "s/^${network}d.rpcpass=.*/${network}d.rpcpass=${result}/g" /home/admin/assets/lnd.${network}.conf
2018-07-29 01:33:54 +02:00
2018-07-17 13:12:03 +02:00
# success info dialog
dialog --backtitle "RaspiBlitz - SetUP" --msgbox "OK - RPC password changed to '$result'\n\nNow starting the Setup of your RaspiBlitz." 7 52
2018-08-21 18:44:17 +02:00
clear
# init get publicip service
getpublicipExists=$(sudo ls /usr/local/bin/getpublicip.sh 2>/dev/null | grep "getpublicip.sh" -c)
if [ ${getpublicipExists} -eq 0 ]; then
echo "*** Installing getPublic ip script and service *** "
sudo cp ./assets/getpublicip.sh /usr/local/bin/getpublicip.sh
sudo chmod +x /usr/local/bin/getpublicip.sh
sudo cp ./assets/getpublicip.service /etc/systemd/system/getpublicip.service
sudo systemctl enable getpublicip
sudo systemctl start getpublicip
echo ""
fi