raspiblitz/home.admin/config.scripts/network.aliases.sh

96 lines
2.5 KiB
Bash
Raw Normal View History

#!/bin/bash
# Usage:
# source <(/home/admin/config.scripts/network.aliases.sh getvars <lnd|cln> <mainnet|testnet|signet>)
2021-06-28 11:47:51 +01:00
# if no values given uses the default values from the raspiblitz.conf
2021-06-23 11:20:59 +01:00
# chain is: main | test ; from raspiblitz.conf or raspiblitz.info or defaults to main
# LNTYPE is: lnd | cln ; default: lnd
# typeprefix is: "" | c
# CHAIN is: mainnet | testnet | signet
# netprefix is: "" | t | s
# portprefix is: "" | 1 | 3
# CLNETWORK is: bitcoin / signet / testnet
2021-06-23 11:20:59 +01:00
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
if [ $1 = getvars ];then
2021-06-23 11:20:59 +01:00
# LNTYPE is: lnd | cln
if [ $# -gt 1 ];then
LNTYPE=$2
else
2021-05-25 14:24:17 +01:00
if [ ${#LNdefault} -gt 0 ];then
LNTYPE=${LNdefault}
else
LNTYPE=lnd
fi
fi
2021-05-25 14:24:17 +01:00
echo "LNTYPE=${LNTYPE}"
2021-06-23 11:20:59 +01:00
# typeprefix is: "" | c
2021-05-25 14:24:17 +01:00
if [ $LNTYPE = cln ];then
2021-06-23 11:20:59 +01:00
typeprefix=c
2021-05-25 14:24:17 +01:00
elif [ $LNTYPE = lnd ];then
2021-06-23 11:20:59 +01:00
typeprefix=''
2021-05-25 14:24:17 +01:00
fi
2021-06-23 11:20:59 +01:00
echo "typeprefix=${typeprefix}"
2021-05-25 14:24:17 +01:00
# from raspiblitz.conf or raspiblitz.info or defaults to main
if [ ${#chain} -eq 0 ] || [ $3 = net ]; then
chain=main
fi
2021-06-23 11:20:59 +01:00
# CHAIN is: signet | testnet | mainnet
if [ $# -gt 2 ]&&[ $3 != net ];then
CHAIN=$3
chain=${CHAIN::-3}
else
CHAIN=${chain}net
fi
2021-05-25 14:24:17 +01:00
echo "CHAIN=${chain}net"
echo "chain=${chain}"
2021-06-23 11:20:59 +01:00
# netprefix is: "" | t | s
# portprefix is: "" | 1 | 3
2021-05-25 14:24:17 +01:00
if [ ${chain} = "test" ];then
netprefix="t"
L1rpcportmod=1
L2rpcportmod=1
2021-06-23 11:20:59 +01:00
portprefix=1
2021-05-25 14:24:17 +01:00
elif [ ${chain} = "sig" ];then
netprefix="s"
L1rpcportmod=3
L2rpcportmod=3
2021-06-23 11:20:59 +01:00
portprefix=3
2021-05-25 14:24:17 +01:00
elif [ ${chain} = "main" ];then
netprefix=""
L1rpcportmod=""
L2rpcportmod=0
2021-06-23 11:20:59 +01:00
portprefix=""
fi
2021-06-23 11:20:59 +01:00
echo "netprefix=${netprefix}"
echo "portprefix=${portprefix}"
# CLNETWORK is: bitcoin / signet / testnet
if [ $chain = main ];then
CLNETWORK=${network}
else
CLNETWORK=${chain}net
fi
echo CLNETWORK=${CLNETWORK}
# instead of all
# sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net
echo "lncli_alias=\"sudo -u bitcoin /usr/local/bin/lncli -n=${chain}net --rpcserver localhost:1${L2rpcportmod}009\""
# sudo -u bitcoin ${network}-cli -datadir=/home/bitcoin/.${network}
echo "bitcoincli_alias=\"/usr/local/bin/${network}-cli -datadir=/home/bitcoin/.${network} -rpcport=${L1rpcportmod}8332\""
echo "lightningcli_alias=\"sudo -u bitcoin /usr/local/bin/lightning-cli --conf=/home/bitcoin/.lightning/${netprefix}config\""
2021-06-23 11:20:59 +01:00
fi
2021-05-25 14:24:17 +01:00
#TODO
2021-06-28 11:47:51 +01:00
# where /lnd.conf is not changed to /${netprefix}lnd.conf
# the service remains mainnet only