mynode/rootfs/standard/usr/bin/mynode_lnd_admin_files.sh

43 lines
1.2 KiB
Bash
Raw Normal View History

2019-06-15 23:02:44 +00:00
#!/bin/bash
source /usr/share/mynode/mynode_config.sh
2021-03-09 03:55:39 +00:00
NETWORK=mainnet
if [ -f $IS_TESTNET_ENABLED_FILE ]; then
NETWORK=testnet
fi
2019-06-15 23:02:44 +00:00
mkdir -p /home/admin/.lnd/
2021-03-09 03:55:39 +00:00
mkdir -p /home/admin/.lnd/data/chain/bitcoin/$NETWORK/
2019-06-15 23:02:44 +00:00
chown -R admin:admin /home/admin/.lnd/
echo "Waiting on lnd files..."
while [ ! -f $LND_TLS_CERT_FILE ]; do
sleep 1m
done
2019-11-05 03:52:54 +00:00
# Copy cert so we can interact with LND even if wallet has not been created
cp -f $LND_TLS_CERT_FILE /home/admin/.lnd/
chown -R admin:admin /home/admin/.lnd/
2019-06-15 23:02:44 +00:00
while [ ! -f $LND_ADMIN_MACAROON_FILE ]; do
sleep 1m
done
echo "LND files found!"
while true; do
2019-11-10 02:52:04 +00:00
# Make sure lnd path exists for admin user
2019-06-15 23:02:44 +00:00
mkdir -p /home/admin/.lnd/
2021-03-09 03:55:39 +00:00
mkdir -p /home/admin/.lnd/data/chain/bitcoin/$NETWORK/
2019-06-15 23:02:44 +00:00
chown -R admin:admin /home/admin/.lnd/
# Copy LND files to admin folder
cp -f $LND_TLS_CERT_FILE /home/admin/.lnd/
2021-03-09 03:55:39 +00:00
cp -f /mnt/hdd/mynode/lnd/data/chain/bitcoin/$NETWORK/*.macaroon /home/admin/.lnd/data/chain/bitcoin/$NETWORK/
2019-06-15 23:02:44 +00:00
chown -R admin:admin /home/admin/.lnd/
echo "Updated admin copy of LND files!"
# Wait for changes
2021-03-09 03:55:39 +00:00
inotifywait -e modify -e create -e delete $LND_TLS_CERT_FILE /mnt/hdd/mynode/lnd/data/chain/bitcoin/$NETWORK/*.macaroon
2019-06-15 23:02:44 +00:00
done
# Should never exit
exit 99