raspiblitz/home.admin/config.scripts/cl.update.sh
/rootzoll 75171c09e3
merge prepare v1.9.0rc5 (#3824)
* extend sd card before fatpack (#3783)
* Fatpack sd card expand (#3784)
* extend sd card before fatpack
* fix expansion detection
* Bump lnbits to 0.10.5 and add path to poetry in systemd script (#3787)
* fix: don't reinstall same CLN version + fmt (#3796)
* fix: lnd check for rpcmiddleware (#3804)
* fix: joininbox update, hide jm api error from lcd (#3801)
* fix: hide jm api error from lcd
* joininbox update to v0.7.8
* fix: remove lnbits user when off, improve checks (#3798)
* reduce bitcoind memory usage w  MALLOC_ARENA_MAX=1 (#3780)
* Misc fixed towards v1.9.0 (#3808)
* get web api info
* #3772 increase curl timeout
* #3805 change "Please Login"
* #3807 fix cln jrpc socket access (#3815)
* Btcpay 193 (#3812)
* Update BTCPay v1.9.3
* btcpay verify with web-flow
* lnbits 0.10.6 update (#3814)
* Fatpack: LCD on & cl-plugin.cln-grpc OFF (#3817)
* make sure fatpack is LCD activated
* remove cl-plugin.cln-grpc.sh by default
* #3793 fix socket jrpc
* lndmanage 0.15.0 (#3818)

---------

Co-authored-by: Stephan Oeste <emzy@emzy.de>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
2023-05-11 17:12:28 +02:00

128 lines
4.7 KiB
Bash

#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo
echo "Interim optional Core Lightning updates between RaspiBlitz releases."
echo "cl.update.sh [info|verified|reckless]"
echo "info -> get actual state and possible actions"
echo "verified -> only do recommended updates by RaspiBlitz team"
echo " binary will be checked by signature and checksum"
echo "reckless -> if you just want to update to the latest release"
echo " published on Core Lightning GitHub releases (RC or final) without any"
echo " testing or security checks."
echo
exit 1
fi
# 1. parameter [info|verified|reckless]
mode="$1"
# RECOMMENDED UPDATE BY RASPIBLITZ TEAM
# comment will be shown as "BEWARE Info" when option is choosen (can be multiple lines)
clUpdateVersion="" # example: 0.12.1 .. keep empty if no newer version as sd card build is available
clUpdateComment="Please keep in mind that downgrading afterwards is not tested. Also not all additional apps are fully tested with the this update - but it looked good on first tests."
# GATHER DATA
# installed Core Lightning version
clInstalledVersion=$(sudo -u bitcoin lightning-cli --version)
clInstalledVersionMajor=$(echo "${clInstalledVersion}" | cut -d "-" -f1 | cut -d "." -f1)
clInstalledVersionMain=$(echo "${clInstalledVersion}" | cut -d "-" -f1 | cut -d "." -f2)
clInstalledVersionMinor=$(echo "${clInstalledVersion}" | cut -d "-" -f1 | cut -d "." -f3)
# test if the installed version already the verified/recommended update version
clUpdateInstalled=$(echo "${clInstalledVersion}" | grep -c "${clUpdateVersion}")
# get latest release from Core Lightning GitHub releases without release candidates
clLatestVersion=$(curl --header "X-GitHub-Api-Version:2022-11-28" -s https://api.github.com/repos/ElementsProject/lightning/releases | jq -r '.[].tag_name' | grep -v "rc" | head -n1)
# example: v0.12.1
# INFO
if [ "${mode}" = "info" ]; then
echo "# basic data"
echo "clInstalledVersion='${clInstalledVersion}'"
echo "clInstalledVersionMajor='${clInstalledVersionMajor}'"
echo "clInstalledVersionMain='${clInstalledVersionMain}'"
echo "clInstalledVersionMinor='${clInstalledVersionMinor}'"
echo "# the verified/recommended update option"
echo "clUpdateInstalled='${clUpdateInstalled}'"
echo "clUpdateVersion='${clUpdateVersion}'"
echo "clUpdateComment='${clUpdateComment}'"
echo "# reckless update option (latest Core Lightning release from GitHub)"
echo "clLatestVersion='${clLatestVersion}'"
exit 1
fi
# verified
if [ "${mode}" = "verified" ]; then
echo "# cl.update.sh verified"
# check for optional second parameter: forced update version
# --> only does the verified update if its the given version
# this is needed for recovery/update.
fixedUpdateVersion="$2"
if [ ${#fixedUpdateVersion} -gt 0 ]; then
echo "# checking for fixed version update: askedFor(${fixedUpdateVersion}) available(${clUpdateVersion})"
if [ "${fixedUpdateVersion}" != "${clUpdateVersion}" ]; then
echo "warn='required update version does not match'"
echo "# this is normal when the recovery script of a new RaspiBlitz version checks for an old update - just ignore"
/home/admin/config.scripts/blitz.conf.sh delete clInterimsUpdate
exit 1
else
echo "# OK - update version is matching"
fi
fi
if [ ${#clUpdateVersion} -gt 0 ]; then
/home/admin/config.scripts/cl.install.sh update v${clUpdateVersion}
else
/home/admin/config.scripts/cl.install.sh on
fi
# note: install will be done the same as reckless further down
clInterimsUpdateNew="${clUpdateVersion}"
fi
# RECKLESS
# this mode is just for people running test and development nodes - its not recommended
# for production nodes. In a update/recovery scenario it will not install a fixed version
# it will always pick the latest release from the github
if [ "${mode}" = "reckless" ]; then
echo "# cl.update.sh reckless"
# only update if the latest release is different from the installed
if [ "${clInstalledVersion}" = "${clLatestVersion}" ]; then
# attention to leading 'v'
echo "# clInstalledVersion = clLatestVersion (${clLatestVersion:1})"
echo "# There is no need to update again."
clInterimsUpdateNew="${clLatestVersion:1}"
else
/home/admin/config.scripts/cl.install.sh update ${clLatestVersion}
clInterimsUpdateNew="reckless"
fi
fi
# JOINED INSTALL (verified & RECKLESS)
if [ "${mode}" = "verified" ] || [ "${mode}" = "reckless" ]; then
echo "# flag update in raspiblitz config"
/home/admin/config.scripts/blitz.conf.sh set clInterimsUpdate "${clInterimsUpdateNew}"
echo "# OK Core Lightning is installed"
echo "# NOTE: RaspiBlitz may need to reboot now"
exit 1
else
echo "error='parameter not known'"
exit 1
fi