mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-24 14:51:03 +01:00
Merge branch 'dev' of https://github.com/rootzoll/raspiblitz into dev
This commit is contained in:
commit
cdf8a77bf4
2 changed files with 31 additions and 27 deletions
|
@ -280,22 +280,17 @@ fi
|
||||||
clnRunning=$(systemctl status ${netprefix}lightningd.service 2>/dev/null | grep -c running)
|
clnRunning=$(systemctl status ${netprefix}lightningd.service 2>/dev/null | grep -c running)
|
||||||
echo "clnActive=${clnRunning}"
|
echo "clnActive=${clnRunning}"
|
||||||
echo "CLNwalletLocked=0"
|
echo "CLNwalletLocked=0"
|
||||||
|
|
||||||
if [ "${clnRunning}" != "1" ] && [ "${LNTYPE}" == "cln" ]; then
|
if [ "${clnRunning}" != "1" ] && [ "${LNTYPE}" == "cln" ]; then
|
||||||
clnInfo=$($lightningcli_alias getinfo 2>&1)
|
|
||||||
# check if locked
|
# check if locked
|
||||||
if [ $(echo "${clnInfo}" | grep -c "Connecting to 'lightning-rpc': Connection refused") -gt 0 ];then
|
if [ "$(sudo journalctl -n5 -u ${netprefix}lightningd | \
|
||||||
echo "# CLN wallet not running yet"
|
grep -cE 'Could not read pass from stdin|pass the --encrypted-hsm|Wrong password')" -gt 0 ];then
|
||||||
clnError=$(sudo journalctl -n5 -u lightningd)
|
|
||||||
if [ $(echo "${clnError}" | grep -c 'encrypted-hsm: Could not read pass from stdin.') -gt 0 ]\
|
|
||||||
|| [ $(echo "${clnError}" | grep -c 'hsm_secret is encrypted, you need to pass the --encrypted-hsm startup option.') -gt 0 ]\
|
|
||||||
|| [ $(echo "${clnError}" | grep -c 'Wrong password for encrypted hsm_secret.') -gt 0 ]; then
|
|
||||||
echo "CLNwalletLocked=1"
|
echo "CLNwalletLocked=1"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${clnRunning}" == "1" ] && [ "${LNTYPE}" == "cln" ]; then
|
if [ "${clnRunning}" == "1" ] && [ "${LNTYPE}" == "cln" ]; then
|
||||||
clnInfo=$($lightningcli_alias getinfo)
|
clnInfo=$($lightningcli_alias getinfo 2>&1)
|
||||||
clnBlockHeight=$(echo "${clnInfo}" | jq -r '.blockheight' | tr -cd '[[:digit:]]')
|
clnBlockHeight=$(echo "${clnInfo}" | jq -r '.blockheight' | tr -cd '[[:digit:]]')
|
||||||
scanProgress=$(echo "scale=2; $clnBlockHeight*100/$total" | bc)
|
scanProgress=$(echo "scale=2; $clnBlockHeight*100/$total" | bc)
|
||||||
echo "scanProgress=${scanProgress}"
|
echo "scanProgress=${scanProgress}"
|
||||||
|
|
|
@ -241,32 +241,41 @@ seedwords6x4='${seedwords6x4}'
|
||||||
elif [ "$1" = "unlock" ]; then
|
elif [ "$1" = "unlock" ]; then
|
||||||
# check if unlocked
|
# check if unlocked
|
||||||
attempt=0
|
attempt=0
|
||||||
while [ $($lightningcli_alias getinfo | grep -c '"id":') -eq 0 ];do
|
justUnlocked=0
|
||||||
|
while [ $($lightningcli_alias getinfo 2>&1 | grep -c '"id":') -eq 0 ];do
|
||||||
|
clnError=$(sudo journalctl -n5 -u ${netprefix}lightningd)
|
||||||
|
|
||||||
# getpassword
|
# getpassword
|
||||||
if [ $(sudo journalctl -n5 -u ${netprefix}lightningd | \
|
if [ $(echo "${clnError}" | \
|
||||||
grep -c 'encrypted-hsm: Could not read pass from stdin.') -gt 0 ];then
|
grep -c 'encrypted-hsm: Could not read pass from stdin.') -gt 0 ];then
|
||||||
if [ -f $passwordFile ];then
|
if [ ${justUnlocked} -eq 0 ];then
|
||||||
echo "# Wrong passwordFile is present"
|
if [ -f $passwordFile ];then
|
||||||
|
echo "# Wrong passwordFile is present"
|
||||||
|
else
|
||||||
|
echo "# No passwordFile is present"
|
||||||
|
fi
|
||||||
|
passwordToFile
|
||||||
|
sudo systemctl restart ${netprefix}lightningd
|
||||||
|
justUnlocked=1
|
||||||
else
|
else
|
||||||
echo "# No passwordFile is present"
|
echo "# Waiting to unlock wallet (2) ... "
|
||||||
|
sleep 5
|
||||||
fi
|
fi
|
||||||
passwordToFile
|
|
||||||
sudo systemctl restart ${netprefix}lightningd
|
|
||||||
|
|
||||||
# configure --encrypted-hsm
|
# configure --encrypted-hsm
|
||||||
elif [ $(sudo journalctl -n5 -u ${netprefix}lightningd | \
|
elif [ $(echo "${clnError}" | \
|
||||||
grep -c 'hsm_secret is encrypted, you need to pass the --encrypted-hsm startup option.') -gt 0 ];then
|
grep -c 'hsm_secret is encrypted, you need to pass the --encrypted-hsm startup option.') -gt 0 ];then
|
||||||
echo "# The hsm_secret is encrypted, but unlock is not configured"
|
|
||||||
passwordToFile
|
echo "# The hsm_secret is encrypted, but unlock is not configured"
|
||||||
# setting value in raspiblitz config
|
passwordToFile
|
||||||
sudo sed -i \
|
# setting value in raspiblitz config
|
||||||
"s/^${netprefix}clnEncryptedHSM=.*/${netprefix}clnEncryptedHSM=on/g" \
|
sudo sed -i \
|
||||||
/mnt/hdd/raspiblitz.conf
|
"s/^${netprefix}clnEncryptedHSM=.*/${netprefix}clnEncryptedHSM=on/g" \
|
||||||
/home/admin/config.scripts/cln.install-service.sh $CHAIN
|
/mnt/hdd/raspiblitz.conf
|
||||||
|
/home/admin/config.scripts/cln.install-service.sh $CHAIN
|
||||||
|
|
||||||
# get new password
|
# get new password
|
||||||
elif [ $(sudo journalctl -n5 -u ${netprefix}lightningd | \
|
elif [ $(echo "${clnError}" | \
|
||||||
grep -c 'Wrong password for encrypted hsm_secret.') -gt 0 ];then
|
grep -c 'Wrong password for encrypted hsm_secret.') -gt 0 ];then
|
||||||
echo "# Wrong password"
|
echo "# Wrong password"
|
||||||
sudo rm -f $passwordFile
|
sudo rm -f $passwordFile
|
||||||
|
@ -280,7 +289,7 @@ elif [ "$1" = "unlock" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "# Waiting to unlock wallet ... "
|
echo "# Waiting to unlock wallet ... "
|
||||||
sleep 15
|
sleep 5
|
||||||
attempt=$((attempt+1))
|
attempt=$((attempt+1))
|
||||||
done
|
done
|
||||||
echo "# Ok the ${netprefix}lightningd wallet is unlocked"
|
echo "# Ok the ${netprefix}lightningd wallet is unlocked"
|
||||||
|
|
Loading…
Add table
Reference in a new issue