From 70eae57b033f726369fa9c2c26ec7dc720c3285f Mon Sep 17 00:00:00 2001 From: openoms <43343391+openoms@users.noreply.github.com> Date: Fri, 25 Aug 2023 22:11:06 +0200 Subject: [PATCH] cln clboss update to latest commit, add simple update (#4121) * clboss: buildfrom github clone, add update option * cln clboss update to latest commit --- home.admin/config.scripts/cl-plugin.clboss.sh | 98 ++++++++++++------- 1 file changed, 65 insertions(+), 33 deletions(-) diff --git a/home.admin/config.scripts/cl-plugin.clboss.sh b/home.admin/config.scripts/cl-plugin.clboss.sh index b64b35e42..64b7b5a49 100644 --- a/home.admin/config.scripts/cl-plugin.clboss.sh +++ b/home.admin/config.scripts/cl-plugin.clboss.sh @@ -2,28 +2,34 @@ # https://github.com/ZmnSCPxj/clboss#operating # https://github.com/ZmnSCPxj/clboss/releases -CLBOSSVERSION="0.13A" +# https://github.com/ZmnSCPxj/clboss/commits/master +CLBOSSVERSION="ef5c41612da0d544b0ed1f3e986b4b07126723a1" # command info -if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ];then +if [ $# -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then echo echo "Install or remove the CLBOSS Core Lightning plugin" echo "version: v${CLBOSSVERSION}" echo "Usage:" - echo "cl-plugin.clboss.sh [on|off] [testnet|mainnet|signet]" - echo "cl-plugin.clboss.sh [info]" + echo "cl-plugin.clboss.sh [on|off] [mainnet|testnet] " + echo "cl-plugin.clboss.sh info" + echo "cl-plugin.clboss.sh update" echo exit 1 fi +if [ $# -gt 2 ] && [ $3 = latest ]; then + CLBOSSVERSION="" +fi + # source <(/home/admin/config.scripts/network.aliases.sh getvars cl ) source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2) if [ "$1" = info ]; then - whiptail --title " CLBOSS WARNING " \ + whiptail --title " CLBOSS WARNING " \ --yes-button "Install" \ - --no-button "Cancel" \ - --yesno " + --no-button "Cancel" \ + --yesno " 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. @@ -40,35 +46,39 @@ 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 -if [ "$1" = on ];then - - if [ ! -f /home/bitcoin/cl-plugins-available/clboss-${CLBOSSVERSION}.tar.gz ];then - - # download tarball - sudo -u bitcoin wget \ - https://github.com/ZmnSCPxj/clboss/releases/download/${CLBOSSVERSION}/clboss-${CLBOSSVERSION}.tar.gz \ - -O /home/bitcoin/cl-plugins-available/clboss-${CLBOSSVERSION}.tar.gz || exit 1 + # 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 - if [ ! -f /home/bitcoin/cl-plugins-available/clboss-${CLBOSSVERSION}/clboss ];then - # dependencies - sudo apt install -y build-essential pkg-config libev-dev \ - libcurl4-gnutls-dev libsqlite3-dev dnsutils + # build + sudo -u bitcoin autoreconf -i + sudo -u bitcoin ./configure && sudo -u bitcoin make + # sudo make install # optional - installs to /usr/local/bin/clboss +} + +if [ "$1" = on ]; then + + if [ ! -f /home/bitcoin/cl-plugins-available/clboss/clboss ]; then + + buildFromSource ${CLBOSSVERSION} - # install - cd /home/bitcoin/cl-plugins-available/ || exit 1 - sudo -u bitcoin tar -xvf clboss-${CLBOSSVERSION}.tar.gz - cd clboss-${CLBOSSVERSION} || exit 1 - sudo -u bitcoin ./configure && sudo -u bitcoin make - # sudo make install # installs to /usr/local/bin/clboss fi - # symlink to enable - if [ ! -L /home/bitcoin/${netprefix}cl-plugins-enabled/clboss ];then - sudo ln -s /home/bitcoin/cl-plugins-available/clboss-${CLBOSSVERSION}/clboss \ - /home/bitcoin/${netprefix}cl-plugins-enabled - 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/ # setting value in raspiblitz.conf /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clboss "on" @@ -85,17 +95,18 @@ if [ "$1" = on ];then echo "${netprefix}cl clboss-status" echo "https://github.com/ZmnSCPxj/clboss#operating" + exit 0 fi -if [ "$1" = off ];then +if [ "$1" = off ]; then # delete symlink sudo rm -rf /home/bitcoin/${netprefix}cl-plugins-enabled/clboss - echo "# Restart the ${netprefix}lightningd.service to deactivate clboss" + echo "# Restarting the ${netprefix}lightningd.service to deactivate clboss" sudo systemctl restart ${netprefix}lightningd # purge - if [ "$(echo "$@" | grep -c purge)" -gt 0 ];then + if [ "$(echo "$@" | grep -c purge)" -gt 0 ]; then echo "# Delete plugin" sudo rm -rf /home/bitcoin/cl-plugins-available/clboss* sudo rm -f /usr/local/bin/clboss @@ -105,4 +116,25 @@ if [ "$1" = off ];then /home/admin/config.scripts/blitz.conf.sh set ${netprefix}clboss "off" 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 +fi + +echo "# FAIL - Unknown Parameter $1" +exit 1