2019-06-15 23:02:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
source /usr/share/mynode/mynode_config.sh
|
|
|
|
|
|
|
|
mkdir -p /tmp/mynode_lndconnect/
|
|
|
|
cd /tmp/mynode_lndconnect/
|
|
|
|
|
|
|
|
echo "Starting lndconnect script..."
|
|
|
|
|
|
|
|
echo "Waiting on lnd wallet file..."
|
|
|
|
while [ ! -f $LND_WALLET_FILE ]; do
|
|
|
|
sleep 1m
|
|
|
|
done
|
|
|
|
echo "LND Wallet found!"
|
2019-07-27 17:00:41 +00:00
|
|
|
echo "Waiting on admin macaroon..."
|
|
|
|
while [ ! -f $LND_ADMIN_MACAROON_FILE ]; do
|
2019-11-04 04:50:47 +00:00
|
|
|
sleep 15s
|
2019-07-27 17:00:41 +00:00
|
|
|
done
|
|
|
|
echo "Admin macroon found!"
|
2019-11-11 02:15:43 +00:00
|
|
|
sleep 30s
|
2019-06-15 23:02:44 +00:00
|
|
|
|
|
|
|
while true; do
|
|
|
|
echo "Generating lndconnect QR codes..."
|
|
|
|
rm -rf /tmp/mynode_lndconnect/*
|
|
|
|
|
2019-11-04 04:50:47 +00:00
|
|
|
while [ ! -f $LND_ADMIN_MACAROON_FILE ] || [ ! -f $LND_WALLET_FILE ] || [ ! -f $LND_TLS_CERT_FILE ]; do
|
|
|
|
sleep 15s
|
|
|
|
done
|
|
|
|
|
2019-09-02 02:08:55 +00:00
|
|
|
# Find URLs
|
2019-09-16 01:50:38 +00:00
|
|
|
LND_TOR_ADDR=$(cat /var/lib/tor/mynode/hostname | awk '{print $1}')
|
2019-11-09 15:32:48 +00:00
|
|
|
LOCAL_IP_ADDR=$(hostname -I | head -n 1)
|
2019-09-02 02:08:55 +00:00
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Generate QR Codes
|
2019-11-09 15:32:48 +00:00
|
|
|
lndconnect --lnddir=/mnt/hdd/mynode/lnd -o --bitcoin.mainnet --host=$LOCAL_IP_ADDR
|
2019-06-15 23:02:44 +00:00
|
|
|
cp -f lndconnect-qr.png lndconnect_local_grpc.png
|
2019-11-09 15:32:48 +00:00
|
|
|
lndconnect --lnddir=/mnt/hdd/mynode/lnd -o --bitcoin.mainnet --host=$LOCAL_IP_ADDR -p 10080
|
2019-06-15 23:02:44 +00:00
|
|
|
cp -f lndconnect-qr.png lndconnect_local_rest.png
|
2019-09-02 02:08:55 +00:00
|
|
|
lndconnect --lnddir=/mnt/hdd/mynode/lnd -o --bitcoin.mainnet --host=$LND_TOR_ADDR
|
|
|
|
cp -f lndconnect-qr.png lndconnect_tor_grpc.png
|
|
|
|
lndconnect --lnddir=/mnt/hdd/mynode/lnd -o --bitcoin.mainnet --host=$LND_TOR_ADDR -p 10080
|
|
|
|
cp -f lndconnect-qr.png lndconnect_tor_rest.png
|
2019-06-15 23:02:44 +00:00
|
|
|
|
|
|
|
# Generate Text Files
|
2019-11-09 15:32:48 +00:00
|
|
|
lndconnect --lnddir=/mnt/hdd/mynode/lnd -j --bitcoin.mainnet --host=$LOCAL_IP_ADDR > lndconnect_local_grpc.txt
|
|
|
|
lndconnect --lnddir=/mnt/hdd/mynode/lnd -j --bitcoin.mainnet --host=$LOCAL_IP_ADDR -p 10080 > lndconnect_local_rest.txt
|
2019-09-02 02:08:55 +00:00
|
|
|
lndconnect --lnddir=/mnt/hdd/mynode/lnd -j --bitcoin.mainnet --host=$LND_TOR_ADDR > lndconnect_tor_grpc.txt
|
|
|
|
lndconnect --lnddir=/mnt/hdd/mynode/lnd -j --bitcoin.mainnet --host=$LND_TOR_ADDR -p 10080 > lndconnect_tor_rest.txt
|
2019-06-15 23:02:44 +00:00
|
|
|
|
2019-11-09 15:32:48 +00:00
|
|
|
echo "Done! Waiting until LND changes, then regen lndconnect codes! (or 24 hours)"
|
|
|
|
inotifywait -t 86400 -e modify -e create -e delete $LND_TLS_CERT_FILE $LND_ADMIN_MACAROON_FILE
|
2019-06-15 23:02:44 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Should never exit
|
|
|
|
exit 99
|