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

110 lines
3 KiB
Bash
Raw Normal View History

#!/bin/bash
2021-07-12 15:37:43 +01:00
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then
echo "# Usage:"
echo "# source <(/home/admin/config.scripts/network.aliases.sh getvars <lnd|cln> <mainnet|testnet|signet>)"
echo "# if no values given uses the default values from the raspiblitz.conf"
echo
echo "# chain is: main | test ; from raspiblitz.conf or raspiblitz.info or defaults to main"
echo
echo "# LNTYPE is: lnd | cln ; default: lnd"
echo "# typeprefix is: "" | c"
echo
echo "# CHAIN is: mainnet | testnet | signet"
echo "# netprefix is: "" | t | s"
echo "# portprefix is: "" | 1 | 3"
echo "# CLNETWORK is: bitcoin / signet / testnet"
exit 1
fi
2021-08-19 23:34:04 +02:00
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf 2>/dev/null
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
# from raspiblitz.conf or raspiblitz.info or defaults to main
2021-07-12 15:37:43 +01:00
if [ ${#chain} -eq 0 ]; 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
# L2rpcportmod is: 0 | 1 | 3
if [ ${chain} = "main" ];then
netprefix=""
L1rpcportmod=""
L2rpcportmod=0
portprefix=""
elif [ ${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
fi
2021-06-23 11:20:59 +01:00
echo "netprefix=${netprefix}"
echo "portprefix=${portprefix}"
echo "L2rpcportmod=${L2rpcportmod}"
if [ $LNTYPE = cln ];then
# CLNETWORK is: bitcoin / signet / testnet
if [ $chain = main ];then
CLNETWORK=${network}
else
CLNETWORK=${chain}net
fi
echo "CLNETWORK=${CLNETWORK}"
2021-06-23 11:20:59 +01:00
# CLNCONF is the path to the config
if [ ${CLNETWORK} = "bitcoin" ]; then
CLNCONF="/home/bitcoin/.lightning/config"
else
CLNCONF="/home/bitcoin/.lightning/${CLNETWORK}/config"
fi
echo "CLNCONF=${CLNCONF}"
typeprefix=c
2021-06-23 11:20:59 +01:00
fi
# typeprefix is: "" | c
if [ $LNTYPE = lnd ];then
typeprefix=''
fi
echo "typeprefix=${typeprefix}"
# 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\""
2021-08-13 09:11:56 +01:00
echo "lightningcli_alias=\"sudo -u bitcoin /usr/local/bin/lightning-cli --conf=${CLNCONF}\""
2021-06-23 11:20:59 +01:00
fi
2021-05-25 14:24:17 +01:00
#TODO
# where /lnd.conf is not changed to /${netprefix}lnd.conf the service remains for mainnet only