mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-03-30 12:36:07 +02:00
CL: add update options for C-lightning
This commit is contained in:
parent
55390c9a53
commit
6b34ce9e3a
@ -287,6 +287,75 @@ Do you really want to update LND now?
|
||||
esac
|
||||
}
|
||||
|
||||
cl()
|
||||
{
|
||||
|
||||
# get cl info
|
||||
source <(sudo -u admin /home/admin/config.scripts/cl.update.sh info)
|
||||
|
||||
# C-lightning Update Options
|
||||
OPTIONS=()
|
||||
if [ ${clUpdateInstalled} -eq 0 ]; then
|
||||
OPTIONS+=(VERIFIED "Optional C-lightning update to ${clUpdateVersion}")
|
||||
fi
|
||||
OPTIONS+=(RECKLESS "Experimental C-lightning update to ${clLatestVersion}")
|
||||
|
||||
CHOICE=$(whiptail --clear --title "Update C-lightning Options" --menu "" 9 60 2 "${OPTIONS[@]}" 2>&1 >/dev/tty)
|
||||
|
||||
clear
|
||||
case $CHOICE in
|
||||
VERIFIED)
|
||||
if [ ${clUpdateInstalled} -eq 1 ]; then
|
||||
whiptail --title "ALREADY INSTALLED" --msgbox "The C-lightning version ${clUpdateVersion} is already installed." 8 30
|
||||
exit 0
|
||||
fi
|
||||
whiptail --title "OPTIONAL C-lightning UPDATE" --yes-button "Cancel" --no-button "Update" --yesno "BEWARE on updating to C-lightning v${clUpdateVersion}:
|
||||
|
||||
${clUpdateComment}
|
||||
|
||||
Do you really want to update C-lightning now?
|
||||
" 16 58
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "# cancel update"
|
||||
exit 0
|
||||
fi
|
||||
error=""
|
||||
warn=""
|
||||
source <(sudo -u admin /home/admin/config.scripts/cl.update.sh verified)
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
whiptail --title "ERROR" --msgbox "${error}" 8 30
|
||||
else
|
||||
echo "# C-lightning was updated successfully"
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
RECKLESS)
|
||||
whiptail --title "RECKLESS C-lightning UPDATE to ${clLatestVersion}" --yes-button "Cancel" --no-button "Update" --yesno "Using the 'RECKLESS' C-lightning update will simply
|
||||
grab the latest C-lightning release published on the C-lightning GitHub page (also release candidates).
|
||||
|
||||
There will be no security checks on signature, etc.
|
||||
|
||||
This update mode is only recommended for testing and
|
||||
development nodes with no serious funding.
|
||||
|
||||
Do you really want to update C-lightning now?
|
||||
" 16 58
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "# cancel update"
|
||||
exit 0
|
||||
fi
|
||||
error=""
|
||||
source <(sudo -u admin /home/admin/config.scripts/cl.update.sh reckless)
|
||||
if [ ${#error} -gt 0 ]; then
|
||||
whiptail --title "ERROR" --msgbox "${error}" 8 30
|
||||
else
|
||||
echo "# C-lightning was updated successfully"
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
bitcoinUpdate() {
|
||||
# get bitcoin info
|
||||
source <(sudo -u admin /home/admin/config.scripts/bitcoin.update.sh info)
|
||||
@ -383,6 +452,10 @@ if [ "${lightning}" == "lnd" ] || [ "${lnd}" == "on" ]; then
|
||||
OPTIONS+=(LND "Interim LND Update Options")
|
||||
fi
|
||||
|
||||
if [ "${lightning}" == "cl" ] || [ "${cl}" == "on" ]; then
|
||||
OPTIONS+=(CL "Interim C-lightning Update Options")
|
||||
fi
|
||||
|
||||
if [ "${bos}" == "on" ]; then
|
||||
OPTIONS+=(BOS "Update Balance of Satoshis")
|
||||
fi
|
||||
@ -433,6 +506,9 @@ case $CHOICE in
|
||||
LND)
|
||||
lnd
|
||||
;;
|
||||
CL)
|
||||
cl
|
||||
;;
|
||||
BITCOIN)
|
||||
bitcoinUpdate
|
||||
;;
|
||||
|
@ -299,6 +299,24 @@ else
|
||||
echo "Provisioning LND interims update - keep default" >> ${logFile}
|
||||
fi
|
||||
|
||||
# CL INTERIMS UPDATE
|
||||
if [ ${#clInterimsUpdate} -gt 0 ]; then
|
||||
sudo sed -i "s/^message=.*/message='Provisioning CL update'/g" ${infoFile}
|
||||
if [ "${clInterimsUpdate}" == "reckless" ]; then
|
||||
# recklessly update CL to latest release on GitHub (just for test & dev nodes)
|
||||
echo "Provisioning CL reckless interims update" >> ${logFile}
|
||||
sudo /home/admin/config.scripts/cl.update.sh reckless >> ${logFile}
|
||||
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
|
||||
echo "Provisioning CL verified interims update" >> ${logFile}
|
||||
sudo /home/admin/config.scripts/cl.update.sh verified ${clInterimsUpdate} >> ${logFile}
|
||||
fi
|
||||
else
|
||||
echo "Provisioning CL interims update - keep default" >> ${logFile}
|
||||
fi
|
||||
|
||||
# Bitcoin Testnet
|
||||
if [ "${testnet}" == "on" ]; then
|
||||
echo "Provisioning ${network} Testnet - run config script" >> ${logFile}
|
||||
|
@ -32,7 +32,11 @@ fi
|
||||
# Tor
|
||||
TORGROUP="debian-tor"
|
||||
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2)
|
||||
if [ "$1" = update ]||[ "$1" = testPR ];then
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars cl mainnet)
|
||||
else
|
||||
source <(/home/admin/config.scripts/network.aliases.sh getvars cl $2)
|
||||
fi
|
||||
|
||||
echo "# Running: 'cl.install.sh $*'"
|
||||
echo "# Using the settings for: ${network} ${CHAIN}"
|
||||
@ -47,7 +51,7 @@ if ! grep -Eq "^${netprefix}cl=" /mnt/hdd/raspiblitz.conf; then
|
||||
fi
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = experimental ]||[ "$1" = testPR ];then
|
||||
if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = testPR ];then
|
||||
|
||||
if [ "${CHAIN}" == "testnet" ] && [ "${testnet}" != "on" ]; then
|
||||
echo "# before activating testnet on cl, first activate testnet on bitcoind"
|
||||
@ -61,12 +65,13 @@ if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = experimental ]||[ "$1" = testPR ];
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f /usr/local/bin/lightningd ]||[ "$1" = update ]||[ "$1" = testPR ];then
|
||||
if [ ! -f /usr/local/bin/lightningd ]||[ "$1" = "update" ]||[ "$1" = "testPR" ];then
|
||||
|
||||
########################
|
||||
# Install dependencies #
|
||||
########################
|
||||
|
||||
|
||||
# https://lightning.readthedocs.io/INSTALL.html#to-build-on-ubuntu
|
||||
echo "# apt update"
|
||||
echo
|
||||
sudo apt-get update
|
||||
@ -116,6 +121,10 @@ if [ "$1" = on ]||[ "$1" = update ]||[ "$1" = experimental ]||[ "$1" = testPR ];
|
||||
sudo -u bitcoin git reset --hard $CLVERSION
|
||||
fi
|
||||
|
||||
echo "Installing additional dependencies"
|
||||
sudo apt-get install -y valgrind python3-pip libpq-dev
|
||||
sudo pip3 install -r requirements.txt
|
||||
|
||||
echo "# Building with EXPERIMENTAL_FEATURES enabled"
|
||||
echo
|
||||
sudo -u bitcoin ./configure --enable-experimental-features
|
||||
|
126
home.admin/config.scripts/cl.update.sh
Normal file
126
home.admin/config.scripts/cl.update.sh
Normal file
@ -0,0 +1,126 @@
|
||||
#!/bin/bash
|
||||
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "Interim optional C-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 C-lightning GitHub releases (RC or final) without any"
|
||||
echo " testing or security checks."
|
||||
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="v0.10.1" # example: v0.10.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 C-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 C-lightning GitHub releases
|
||||
gitHubLatestReleaseJSON="$(curl -s https://api.github.com/repos/ElementsProject/lightning/releases | jq '.[0]')"
|
||||
clLatestVersion=$(echo "${gitHubLatestReleaseJSON}" | jq -r '.tag_name')
|
||||
|
||||
# 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 C-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"
|
||||
sed -i '/^clInterimsUpdate=*/d' /mnt/hdd/raspiblitz.conf
|
||||
exit 1
|
||||
else
|
||||
echo "# OK - update version is matching"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ ${#clUpdateVersion} -gt 0 ];then
|
||||
/home/admin/config.scripts/cl.install.sh update ${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"
|
||||
|
||||
/home/admin/config.scripts/cl.install.sh update ${clLatestVersion}
|
||||
|
||||
# prepare install
|
||||
clInterimsUpdateNew="reckless"
|
||||
fi
|
||||
|
||||
# JOINED INSTALL (verified & RECKLESS)
|
||||
if [ "${mode}" = "verified" ] || [ "${mode}" = "reckless" ]; then
|
||||
|
||||
echo "# flag update in raspiblitz config"
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
if [ ${#clInterimsUpdate} -eq 0 ]; then
|
||||
echo "clInterimsUpdate='${clInterimsUpdateNew}'" >> /mnt/hdd/raspiblitz.conf
|
||||
else
|
||||
sudo sed -i "s/^clInterimsUpdate=.*/clInterimsUpdate='${clInterimsUpdateNew}'/g" /mnt/hdd/raspiblitz.conf
|
||||
fi
|
||||
|
||||
echo "# OK C-lightning is installed"
|
||||
echo "# NOTE: RaspiBlitz may need to reboot now"
|
||||
exit 1
|
||||
|
||||
else
|
||||
|
||||
echo "error='parameter not known'"
|
||||
exit 1
|
||||
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user