|
|
@ -6,29 +6,140 @@ if [ $# -eq 0 ]; then |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
# load raspiblitz conf |
|
|
|
source /mnt/hdd/raspiblitz.conf |
|
|
|
|
|
|
|
# check basic LND setup |
|
|
|
if [ "$1" == "basic-setup" ]; then |
|
|
|
|
|
|
|
# check TLS exits |
|
|
|
tlsExists=$(sudo ls /mnt/hdd/lnd/tls.cert | grep -c 'tls.cert') |
|
|
|
tlsExists=$(sudo ls /mnt/hdd/lnd/tls.cert 2>/dev/null | grep -c 'tls.cert') |
|
|
|
if [ ${tlsExists} -gt 0 ]; then |
|
|
|
echo "tls=1" |
|
|
|
else |
|
|
|
echo "tls=0" |
|
|
|
echo "err='tls.cert is missing in /mnt/hdd/lnd'" |
|
|
|
fi |
|
|
|
# check TLS exits (on SD card for admin) |
|
|
|
tlsExists=$(sudo ls /home/admin/.lnd/tls.cert 2>/dev/null | grep -c 'tls.cert') |
|
|
|
if [ ${tlsExists} -gt 0 ]; then |
|
|
|
echo "tlsCopy=1" |
|
|
|
# check if the same |
|
|
|
orgChecksum=$(sudo shasum -a 256 /mnt/hdd/lnd/tls.cert 2>/dev/null | cut -d " " -f1) |
|
|
|
cpyChecksum=$(sudo shasum -a 256 /home/admin/.lnd/tls.cert 2>/dev/null | cut -d " " -f1) |
|
|
|
if [ "${orgChecksum}" == "${cpyChecksum}" ]; then |
|
|
|
echo "tlsMismatch=0" |
|
|
|
else |
|
|
|
echo "tlsMismatch=1" |
|
|
|
echo "err='tls.cert for user admin is old'" |
|
|
|
fi |
|
|
|
else |
|
|
|
echo "tlsCopy=0" |
|
|
|
echo "tlsMismatch=0" |
|
|
|
echo "err='tls.cert is missing for user admin'" |
|
|
|
fi |
|
|
|
|
|
|
|
# check lnd.conf exits |
|
|
|
lndConfExists=$(sudo ls /mnt/hdd/lnd/lnd.conf | grep -c 'lnd.conf') |
|
|
|
lndConfExists=$(sudo ls /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep -c 'lnd.conf') |
|
|
|
if [ ${lndConfExists} -gt 0 ]; then |
|
|
|
echo "config=1" |
|
|
|
else |
|
|
|
echo "config=0" |
|
|
|
echo "err='lnd.conf is missing in /mnt/hdd/lnd'" |
|
|
|
fi |
|
|
|
# check lnd.conf exits (on SD card for admin) |
|
|
|
lndConfExists=$(sudo ls /home/admin/.lnd/lnd.conf 2>/dev/null | grep -c 'lnd.conf') |
|
|
|
if [ ${lndConfExists} -gt 0 ]; then |
|
|
|
echo "configCopy=1" |
|
|
|
# check if the same |
|
|
|
orgChecksum=$(sudo shasum -a 256 /mnt/hdd/lnd/lnd.conf 2>/dev/null | cut -d " " -f1) |
|
|
|
cpyChecksum=$(sudo shasum -a 256 /home/admin/.lnd/lnd.conf 2>/dev/null | cut -d " " -f1) |
|
|
|
if [ "${orgChecksum}" == "${cpyChecksum}" ]; then |
|
|
|
echo "configMismatch=0" |
|
|
|
else |
|
|
|
echo "configMismatch=1" |
|
|
|
echo "err='lnd.conf for user admin is old'" |
|
|
|
fi |
|
|
|
else |
|
|
|
echo "configCopy=0" |
|
|
|
echo "configMismatch=0" |
|
|
|
echo "err='lnd.conf is missing for user admin'" |
|
|
|
fi |
|
|
|
|
|
|
|
# get network from config (BLOCKCHAIN) |
|
|
|
lndNetwork="" |
|
|
|
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep 'bitcoin.active' | sed 's/^[a-z]*\./bitcoin_/g') |
|
|
|
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep 'litecoin.active' | sed 's/^[a-z]*\./litecoin_/g') |
|
|
|
if [ "${bitcoin_active}" == "1" ] && [ "${litecoin_active}" == "1" ]; then |
|
|
|
echo "err='lnd.conf: bitcoin and litecoin are set active at the same time'" |
|
|
|
elif [ "${bitcoin_active}" == "1" ]; then |
|
|
|
lndNetwork="bitcoin" |
|
|
|
elif [ "${litecoin_active}" == "1" ]; then |
|
|
|
lndNetwork="litecoin" |
|
|
|
else |
|
|
|
echo "err='lnd.conf: no blockchain network is set'" |
|
|
|
fi |
|
|
|
echo "network='${lndNetwork}'" |
|
|
|
|
|
|
|
# load config values |
|
|
|
source <(sudo sed -e 's/\[/#/g' /mnt/hdd/lnd/lnd.conf) |
|
|
|
echo "debuglevel=${debuglevel}" |
|
|
|
echo "bitcoin.mainnet=${bitcoin.mainnet}" |
|
|
|
echo "bitcoin.testnet=${bitcoin.testnet}" |
|
|
|
# check if network is same the raspiblitz config |
|
|
|
if [ "${network}" != "${lndNetwork}" ]; then |
|
|
|
echo "err='lnd.conf: blockchain network in lnd.conf (${lndNetwork}) is different from raspiblitz.conf (${network})'" |
|
|
|
fi |
|
|
|
|
|
|
|
# get chain from config (TESTNET / MAINNET) |
|
|
|
lndChain="" |
|
|
|
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.mainnet" | sed 's/^[a-z]*\.//g') |
|
|
|
source <(sudo cat /mnt/hdd/lnd/lnd.conf 2>/dev/null | grep "${lndNetwork}.testnet" | sed 's/^[a-z]*\.//g') |
|
|
|
if [ "${mainnet}" == "1" ] && [ "${testnet}" == "1" ]; then |
|
|
|
echo "err='lnd.conf: mainnet and testnet are set active at the same time'" |
|
|
|
elif [ "${mainnet}" == "1" ]; then |
|
|
|
lndChain="bitcoin" |
|
|
|
elif [ "${testnet}" == "1" ]; then |
|
|
|
lndChain="litecoin" |
|
|
|
else |
|
|
|
echo "err='lnd.conf: neither testnet or mainnet is set active (raspiblitz needs one of them active in lnd.conf)'" |
|
|
|
fi |
|
|
|
echo "chain='${lndChain}'" |
|
|
|
|
|
|
|
# check if chain is same the raspiblitz config |
|
|
|
if [ "${chain}" != "${lndChain}" ]; then |
|
|
|
echo "err='lnd.conf: testnet/mainnet in lnd.conf (${lndChain}) is different from raspiblitz.conf (${chain})'" |
|
|
|
fi |
|
|
|
|
|
|
|
# check for admin macaroon exist (on HDD) |
|
|
|
adminMacaroonExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c 'admin.macaroon') |
|
|
|
if [ ${adminMacaroonExists} -gt 0 ]; then |
|
|
|
echo "macaroon=1" |
|
|
|
else |
|
|
|
echo "macaroon=0" |
|
|
|
echo "err='admin.macaroon is missing in /mnt/hdd/lnd/data/chain/${network}/${chain}net'" |
|
|
|
fi |
|
|
|
# check for admin macaroon exist (on SD card for admin) |
|
|
|
adminMacaroonExists=$(sudo ls /home/admin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | grep -c 'admin.macaroon') |
|
|
|
if [ ${adminMacaroonExists} -gt 0 ]; then |
|
|
|
echo "macaroonCopy=1" |
|
|
|
# check if the same |
|
|
|
orgChecksum=$(sudo shasum -a 256 /mnt/hdd/lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | cut -d " " -f1) |
|
|
|
cpyChecksum=$(sudo shasum -a 256 /home/admin/.lnd/data/chain/${network}/${chain}net/admin.macaroon 2>/dev/null | cut -d " " -f1) |
|
|
|
if [ "${orgChecksum}" == "${cpyChecksum}" ]; then |
|
|
|
echo "macaroonMismatch=0" |
|
|
|
else |
|
|
|
echo "macaroonMismatch=1" |
|
|
|
echo "err='admin.macaroon for user admin is old'" |
|
|
|
fi |
|
|
|
else |
|
|
|
echo "macaroonCopy=0" |
|
|
|
echo "macaroonMismatch=0" |
|
|
|
echo "err='admin.macaroon is missing for user admin" |
|
|
|
fi |
|
|
|
|
|
|
|
# check for walletDB exist |
|
|
|
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep -c 'wallet.db') |
|
|
|
if [ ${walletExists} -gt 0 ]; then |
|
|
|
echo "wallet=1" |
|
|
|
else |
|
|
|
echo "wallet=0" |
|
|
|
fi |
|
|
|
|
|
|
|
else |
|
|
|
echo "# FAIL: parameter not known" |
|
|
|