2019-06-15 23:02:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
|
|
|
|
2019-11-10 02:21:25 +00:00
|
|
|
# Wait for LND + BTC to start
|
2020-05-13 04:02:11 +00:00
|
|
|
sleep 1m
|
2019-11-10 02:21:25 +00:00
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
while true; do
|
|
|
|
|
|
|
|
while [ ! -f "$LND_WALLET_FILE" ]; do
|
|
|
|
echo "Waiting for LND wallet file to exist..."
|
|
|
|
sleep 30s
|
|
|
|
done
|
|
|
|
|
2019-11-05 02:22:46 +00:00
|
|
|
while [ ! -f "$LND_ADMIN_MACAROON_FILE" ]; do
|
|
|
|
echo "Waiting for LND admin macaroon file to exist..."
|
|
|
|
sleep 30s
|
|
|
|
done
|
|
|
|
|
|
|
|
# Sleep 15 seconds to let LND startup and avoid LN race condition
|
|
|
|
# See https://github.com/lightningnetwork/lnd/issues/3631
|
2020-05-13 04:02:11 +00:00
|
|
|
#/bin/sleep 60s
|
|
|
|
|
|
|
|
# Wait for lnd to accept logins
|
|
|
|
until journalctl -r -u lnd --no-pager | head -n 20 | grep "Waiting for wallet encryption password"
|
|
|
|
do
|
|
|
|
sleep 15s
|
|
|
|
done
|
|
|
|
sleep 15s
|
2019-11-05 02:22:46 +00:00
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
echo "Unlocking wallet..."
|
|
|
|
/usr/bin/expect /usr/bin/unlock_lnd.tcl
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
# Unlocked! Verify unlocked every time LND files change
|
2020-01-24 03:43:50 +00:00
|
|
|
inotifywait -t 600 -r -e modify -e create -e delete /mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/ /mnt/hdd/mynode/lnd/tls.cert
|
2019-06-15 23:02:44 +00:00
|
|
|
else
|
|
|
|
# Failed, try again in 15 seconds
|
|
|
|
/bin/sleep 15s
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|