raspiblitz/home.admin/config.scripts/cl-plugin.clboss.sh

141 lines
4.2 KiB
Bash
Raw Normal View History

2021-08-10 19:43:00 +01:00
#!/bin/bash
# https://github.com/ZmnSCPxj/clboss#operating
# https://github.com/ZmnSCPxj/clboss/releases
# https://github.com/ZmnSCPxj/clboss/commits/master
CLBOSSVERSION="ef5c41612da0d544b0ed1f3e986b4b07126723a1"
2021-08-10 19:43:00 +01:00
# command info
if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
2021-08-10 19:43:00 +01:00
echo
2022-07-07 09:52:33 +01:00
echo "Install or remove the CLBOSS Core Lightning plugin"
2021-08-10 19:43:00 +01:00
echo "version: v${CLBOSSVERSION}"
echo "Usage:"
echo "cl-plugin.clboss.sh [on|off] [mainnet|testnet] <latest>"
echo "cl-plugin.clboss.sh info"
echo "cl-plugin.clboss.sh update"
2021-08-10 19:43:00 +01:00
echo
exit 1
fi
if [ $# -gt 2 ] && [ $3 = latest ]; then
CLBOSSVERSION=""
fi
# source <(/home/admin/config.scripts/network.aliases.sh getvars cl <mainnet|testnet|signet>)
source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2)
2021-08-10 19:43:00 +01:00
2022-07-07 09:52:33 +01:00
if [ "$1" = info ]; then
whiptail --title " CLBOSS WARNING " \
2022-07-07 09:52:33 +01:00
--yes-button "Install" \
--no-button "Cancel" \
--yesno "
2022-07-07 09:52:33 +01:00
The goal of CLBOSS is to make the node able to pay and receive payments
on the lightning network reliably without needing active management.
It is not a tool to run a profitable lightning node and it can lose some sats on fees.
CLBOSS does the following automatically:
- Open channels to other, useful nodes when fees are low and there are onchain funds
- Acquire incoming capacity via boltz.exchange swaps (these funds return onchain)
- Rebalance open channels by self-payment (including JIT rebalancer)
- Set forwarding fees so that they're competitive to other nodes
Links with more info:
https://github.com/rootzoll/raspiblitz/blob/dev/FAQ.cl.md#clboss
https://github.com/ZmnSCPxj/clboss#operating
" 0 0
fi
function buildFromSource() {
version=$1
# dependencies
sudo apt install -y build-essential pkg-config libev-dev \
libcurl4-gnutls-dev libsqlite3-dev dnsutils
sudo apt install -y git automake autoconf-archive libtool
# download
cd /home/bitcoin/cl-plugins-available/ || exit 1
sudo -u bitcoin git clone https://github.com/ZmnSCPxj/clboss
cd clboss || exit 1
if [[ -v version && -n "$version" ]]; then
sudo -u bitcoin git reset --hard ${version}
fi
2022-07-07 09:52:33 +01:00
# build
sudo -u bitcoin autoreconf -i
sudo -u bitcoin ./configure && sudo -u bitcoin make
# sudo make install # optional - installs to /usr/local/bin/clboss
}
2021-08-10 19:43:00 +01:00
if [ "$1" = on ]; then
2022-05-13 13:25:30 +01:00
if [ ! -f /home/bitcoin/cl-plugins-available/clboss/clboss ]; then
2021-08-10 19:43:00 +01:00
buildFromSource ${CLBOSSVERSION}
2021-08-10 19:43:00 +01:00
fi
# refresh symlink to enable
sudo rm /home/bitcoin/${netprefix}cl-plugins-enabled/clboss 2>/dev/null
sudo ln -s /home/bitcoin/cl-plugins-available/clboss/clboss \
/home/bitcoin/${netprefix}cl-plugins-enabled/
2021-08-10 19:43:00 +01:00
# setting value in raspiblitz.conf
/home/admin/config.scripts/blitz.conf.sh set ${netprefix}clboss "on"
2021-08-10 19:43:00 +01:00
source <(/home/admin/_cache.sh get state)
2021-08-10 19:43:00 +01:00
if [ "${state}" == "ready" ]; then
echo "# Restart the ${netprefix}lightningd.service to activate clboss"
sudo systemctl restart ${netprefix}lightningd
fi
echo "# clboss was installed for $CHAIN"
echo "# Monitor with:"
echo "sudo tail -n 100 -f /home/bitcoin/.lightning/${CLNETWORK}/cl.log | grep clboss"
echo "${netprefix}cl clboss-status"
2021-08-10 19:43:00 +01:00
echo "https://github.com/ZmnSCPxj/clboss#operating"
2022-05-13 13:25:30 +01:00
exit 0
2021-08-10 19:43:00 +01:00
fi
if [ "$1" = off ]; then
2021-08-10 19:43:00 +01:00
# delete symlink
sudo rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/clboss
2022-05-13 13:25:30 +01:00
echo "# Restarting the ${netprefix}lightningd.service to deactivate clboss"
2021-08-10 19:43:00 +01:00
sudo systemctl restart ${netprefix}lightningd
# purge
if [ "$(echo "$@" | grep -c purge)" -gt 0 ]; then
2021-08-10 19:43:00 +01:00
echo "# Delete plugin"
sudo rm -rf /home/bitcoin/cl-plugins-available/clboss*
2021-08-10 19:43:00 +01:00
sudo rm -f /usr/local/bin/clboss
fi
# setting value in raspi blitz config
/home/admin/config.scripts/blitz.conf.sh set ${netprefix}clboss "off"
2021-08-10 19:43:00 +01:00
echo "# clboss was uninstalled for $CHAIN"
exit 0
fi
if [ "$1" = update ]; then
if [ ! -f /home/bitcoin/cl-plugins-available/clboss/clboss ]; then
/home/admin/config.scrips/cl-plugin/clboss.sh on "${CHAIN}"
exit 0
else
sudo rm -rf /home/bitcoin/cl-plugins-available/clboss
buildFromSource
echo "# clboss was updated to the latest master commit"
echo "# Restarting ${netprefix}lightningd to activate"
sudo systemctl restart ${netprefix}lightningd
exit 0
fi
2021-08-10 19:43:00 +01:00
fi
echo "# FAIL - Unknown Parameter $1"
exit 1