raspiblitz/home.admin/config.scripts/blitz.setpassword.sh

117 lines
2.8 KiB
Bash
Raw Normal View History

2019-01-14 14:39:01 +01:00
#!/bin/bash
# command info
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small config script to set a passwords A,B,C & D"
2019-01-14 15:47:47 +01:00
echo "blitz.setpassword.sh [?a|b|c|d] [?newpassword] "
2019-01-14 14:39:01 +01:00
exit 1
fi
2019-01-14 16:05:39 +01:00
# check if sudo
if [ "$EUID" -ne 0 ]
then echo "Please run as root (with sudo)"
exit
fi
# load raspiblitz config (if available)
source /mnt/hdd/raspiblitz.conf 2>/dev/null
2019-01-14 16:25:43 +01:00
if [ ${#network} -eq 0 ]; then
network="bitcoin"
fi
if [ ${#chain} -eq 0 ]; then
chain="main"
fi
2019-01-14 16:05:39 +01:00
2019-01-14 14:39:01 +01:00
# 1. parameter [?a|b|c|d]
abcd=$1
# 2. parameter [?newpassword]
newPassword=$2
# run interactive if no further parameters
2019-01-14 15:30:01 +01:00
OPTIONS=()
2019-01-14 14:39:01 +01:00
if [ ${#abcd} -eq 0 ]; then
2019-01-14 15:30:01 +01:00
OPTIONS+=(A "Master User Password / SSH")
2019-01-14 14:51:34 +01:00
OPTIONS+=(B "RPC Password (blockchain/lnd)")
OPTIONS+=(C "LND Wallet Password")
OPTIONS+=(D "LND Seed Password")
2019-01-14 14:39:01 +01:00
CHOICE=$(dialog --clear \
2019-01-14 15:39:50 +01:00
--backtitle "RaspiBlitz" \
--title "Set Password" \
--menu "Which password to change?" \
11 50 7 \
2019-01-14 14:39:01 +01:00
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
A)
abcd='a';
;;
B)
abcd='b';
;;
C)
abcd='c';
;;
D)
abcd='d';
;;
esac
fi
2019-01-14 15:47:47 +01:00
echo "Changing Password ${abcd} ..."
echo ""
# PASSWORD A
if [ "${abcd}" = "a" ]; then
echo "TODO: Password A"
# PASSWORD B
elif [ "${abcd}" = "b" ]; then
echo "TODO: Password B"
# PASSWORD C
elif [ "${abcd}" = "c" ]; then
2019-01-14 16:32:21 +01:00
if [ ${#newPassword} -gt 0 ]; then
2019-01-14 16:30:46 +01:00
echo "New password C cannot be set thru paramter .. will start interactive password setting."
echo "PRESS ENTER to continue"
read key
fi
2019-01-14 16:05:39 +01:00
clear
echo ""
echo "****************************************************************************"
2019-01-14 16:25:43 +01:00
echo "Change LND Wallet Password --> lncli --chain=${network} --network=${chain}net changepassword"
2019-01-14 16:05:39 +01:00
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 "To CANCEL use CTRL+C"
echo "****************************************************************************"
# let LND-CLI handle the password change
2019-01-14 16:32:21 +01:00
sudo -u bitcoin lncli --chain=${network} --network=${chain}net changepassword
2019-01-14 16:05:39 +01:00
# deactivate AUTO-UNLOCK if activated
2019-01-14 16:36:36 +01:00
echo ""
echo "# Make sure Auto-Unlocks off"
2019-01-14 16:05:39 +01:00
sudo /home/admin/config.scripts/lnd.autounlock.sh off
2019-01-14 15:47:47 +01:00
2019-01-14 16:36:36 +01:00
# final user output
echo ""
echo "OK"
2019-01-14 15:47:47 +01:00
# 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)."
# everything else
else
echo "FAIL: there is no password '${abcd}' (reminder: use lower case)"
fi
echo ""