From dbbdaf91fcca9f9c4226f9fc470cb6271a35a4bb Mon Sep 17 00:00:00 2001 From: openoms <43343391+openoms@users.noreply.github.com> Date: Tue, 16 May 2023 12:12:36 +0100 Subject: [PATCH] CLN: less reckless update, consistent leading v (#3835) * CLN: less reckless update, consistent leading v * check in app-data as root and add output * check if clUpdateVersion is already installed --- home.admin/_provision_.sh | 24 +++++++++++++++++++----- home.admin/config.scripts/cl.update.sh | 21 +++++++++++++-------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/home.admin/_provision_.sh b/home.admin/_provision_.sh index 905ebca48..0686fcf6d 100755 --- a/home.admin/_provision_.sh +++ b/home.admin/_provision_.sh @@ -243,13 +243,27 @@ fi if [ ${#clInterimsUpdate} -gt 0 ]; then /home/admin/_cache.sh set message "Provisioning CL update" if [ "${clInterimsUpdate}" == "reckless" ]; then - # recklessly update CL to latest release on GitHub (just for test & dev nodes) - echo "Provisioning CL reckless interims update" >> ${logFile} - /home/admin/config.scripts/cl.update.sh reckless >> ${logFile} + # determine the database version # Examples: 216 is CLN v23.02.2 # 219 is CLN v23.05 + clDbVersion=$(sqlite3 /mnt/hdd/app-data/.lightning/bitcoin/lightningd.sqlite3 "SELECT version FROM version;") + if [ ${#clDbVersion} -eq 0 ]; then + echo "Could not determine the CLN database version - using 0" >> ${logFile} + clDbVersion=0 + else + echo "The CLN database version is ${clDbVersion}" >> ${logFile} + fi + if [ ${clDbVersion} -lt 217 ]; then + # even if reckless is set - update to the recommended release + echo "Provisioning CL verified interims update" >> ${logFile} + /home/admin/config.scripts/cl.update.sh verified >> ${logFile} + else # 217 or higher + # recklessly update CL to latest release on GitHub (just for test & dev nodes) + echo "Provisioning CL reckless interims update" >> ${logFile} + /home/admin/config.scripts/cl.update.sh reckless >> ${logFile} + fi else # when installing the same sd image - this will re-trigger the secure interims update - # if this a update with a newer RaspiBlitz version .. interims update will be ignored - # because standard CL version is most more up to date + # if this is an update with a newer RaspiBlitz version .. interims update will be ignored + # because the standard CL version is up to date echo "Provisioning CL verified interims update" >> ${logFile} /home/admin/config.scripts/cl.update.sh verified ${clInterimsUpdate} >> ${logFile} fi diff --git a/home.admin/config.scripts/cl.update.sh b/home.admin/config.scripts/cl.update.sh index 91903700c..02d8fc4e1 100644 --- a/home.admin/config.scripts/cl.update.sh +++ b/home.admin/config.scripts/cl.update.sh @@ -9,7 +9,7 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then 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 " published on Core Lightning GitHub releases without any" echo " testing or security checks." echo exit 1 @@ -20,13 +20,13 @@ 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 +clUpdateVersion="v23.02.2" # example: v23.02.2 # 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) +clInstalledVersion=$(sudo -u bitcoin lightningd --version) # example output: v23.02.2 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) @@ -36,7 +36,7 @@ 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 +# example output: v23.05 # INFO if [ "${mode}" = "info" ]; then @@ -80,7 +80,13 @@ if [ "${mode}" = "verified" ]; then fi if [ ${#clUpdateVersion} -gt 0 ]; then - /home/admin/config.scripts/cl.install.sh update v${clUpdateVersion} + # only update if the clUpdateVersion is different from the installed + if [ "${clInstalledVersion}" = "${clUpdateVersion}" ]; then + echo "# clInstalledVersion = clUpdateVersion (${clUpdateVersion})" + echo "# There is no need to update again." + else + /home/admin/config.scripts/cl.install.sh update ${clUpdateVersion} + fi else /home/admin/config.scripts/cl.install.sh on fi @@ -100,10 +106,9 @@ if [ "${mode}" = "reckless" ]; then # 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 "# clInstalledVersion = clLatestVersion (${clLatestVersion})" echo "# There is no need to update again." - clInterimsUpdateNew="${clLatestVersion:1}" + clInterimsUpdateNew="${clLatestVersion}" else /home/admin/config.scripts/cl.install.sh update ${clLatestVersion} clInterimsUpdateNew="reckless"