From eae7160422e4d797ca7659c7f75734bcdc391831 Mon Sep 17 00:00:00 2001 From: openoms Date: Sun, 19 Dec 2021 23:56:40 +0000 Subject: [PATCH] cl, lnd.update: check version in reckless install #2798 --- home.admin/config.scripts/cl.update.sh | 14 ++-- home.admin/config.scripts/lnd.update.sh | 89 +++++++++++++++---------- 2 files changed, 62 insertions(+), 41 deletions(-) diff --git a/home.admin/config.scripts/cl.update.sh b/home.admin/config.scripts/cl.update.sh index f84afdeda..81449c7b6 100644 --- a/home.admin/config.scripts/cl.update.sh +++ b/home.admin/config.scripts/cl.update.sh @@ -99,10 +99,16 @@ if [ "${mode}" = "reckless" ]; then echo "# cl.update.sh reckless" - /home/admin/config.scripts/cl.install.sh update ${clLatestVersion} - - # prepare install - clInterimsUpdateNew="reckless" + # only update if the latest release is different from the installed + if [ "v${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) diff --git a/home.admin/config.scripts/lnd.update.sh b/home.admin/config.scripts/lnd.update.sh index 3ca0ec014..e77585d7d 100755 --- a/home.admin/config.scripts/lnd.update.sh +++ b/home.admin/config.scripts/lnd.update.sh @@ -59,6 +59,7 @@ fi # installed LND version lndInstalledVersion=$(sudo -u bitcoin lncli --version | cut -d " " -f3) +# example: '0.14.1-beta' lndInstalledVersionMajor=$(echo "${lndInstalledVersion}" | cut -d "-" -f1 | cut -d "." -f1) lndInstalledVersionMain=$(echo "${lndInstalledVersion}" | cut -d "-" -f1 | cut -d "." -f2) lndInstalledVersionMinor=$(echo "${lndInstalledVersion}" | cut -d "-" -f1 | cut -d "." -f3) @@ -96,6 +97,24 @@ if [ "${mode}" = "info" ]; then exit 1 fi +function installLND() { + # install + echo "# stopping LND" + sudo systemctl stop lnd + echo "# unzip LND binary" + sudo -u admin tar -xzf ${binaryName} + # removing the tar.gz ending from the binary + directoryName="${binaryName%.*.*}" + echo "# install binary directory '${directoryName}'" + sudo install -m 0755 -o root -g root -t /usr/local/bin ${directoryName}/* + sleep 3 + installed=$(sudo -u admin lnd --version) + if [ ${#installed} -eq 0 ]; then + echo "error='install failed'" + exit 1 + fi +} + # verified if [ "${mode}" = "verified" ]; then @@ -183,6 +202,8 @@ if [ "${mode}" = "verified" ]; then # note: install will be done the same as reckless further down lndInterimsUpdateNew="${lndUpdateVersion}" + installLND + fi # RECKLESS @@ -192,50 +213,44 @@ fi if [ "${mode}" = "reckless" ]; then echo "# lnd.update.sh reckless" + # only update if the latest release is different from the installed + if [ "v${lndInstalledVersion}" = "${lndLatestVersion}" ]; then + # attention to leading 'v' + echo "# lndInstalledVersion = lndLatestVersion (${lndLatestVersion:1})" + echo "# There is no need to update again." + lndInterimsUpdateNew="${lndLatestVersion:1}" + else + # check that download link has a value + if [ ${#lndLatestDownload} -eq 0 ]; then + echo "error='no download link'" + exit 1 + fi + + # clean & change into download directory + sudo rm -r ${downloadDir}/* + cd "${downloadDir}" || exit 1 + + # download binary + echo "# downloading binary" + binaryName=$(basename "${lndLatestDownload}") + sudo -u admin wget -N ${lndLatestDownload} + checkDownload=$(ls ${binaryName} 2>/dev/null | grep -c ${binaryName}) + if [ ${checkDownload} -eq 0 ]; then + echo "error='download binary failed'" + exit 1 + fi + + # prepare install + lndInterimsUpdateNew="reckless" + + installLND - # check that download link has a value - if [ ${#lndLatestDownload} -eq 0 ]; then - echo "error='no download link'" - exit 1 fi - - # clean & change into download directory - sudo rm -r ${downloadDir}/* - cd "${downloadDir}" || exit 1 - - # download binary - echo "# downloading binary" - binaryName=$(basename "${lndLatestDownload}") - sudo -u admin wget -N ${lndLatestDownload} - checkDownload=$(ls ${binaryName} 2>/dev/null | grep -c ${binaryName}) - if [ ${checkDownload} -eq 0 ]; then - echo "error='download binary failed'" - exit 1 - fi - - # prepare install - lndInterimsUpdateNew="reckless" fi # JOINED INSTALL (verified & RECKLESS) if [ "${mode}" = "verified" ] || [ "${mode}" = "reckless" ]; then - # install - echo "# stopping LND" - sudo systemctl stop lnd - echo "# unzip LND binary" - sudo -u admin tar -xzf ${binaryName} - # removing the tar.gz ending from the binary - directoryName="${binaryName%.*.*}" - echo "# install binary directory '${directoryName}'" - sudo install -m 0755 -o root -g root -t /usr/local/bin ${directoryName}/* - sleep 3 - installed=$(sudo -u admin lnd --version) - if [ ${#installed} -eq 0 ]; then - echo "error='install failed'" - exit 1 - fi - echo "# mark update in raspiblitz config" /home/admin/config.scripts/blitz.conf.sh set lndInterimsUpdate "${lndInterimsUpdateNew}"