Merge branch '1126-provision' into pre-1.7.1

This commit is contained in:
rootzoll 2021-06-24 21:28:19 +02:00
commit 34bdd3256b
9 changed files with 117 additions and 70 deletions

12
FAQ.md
View file

@ -415,13 +415,13 @@ For example if you want to make a build from the 'dev' branch you execute the fo
If you fork the RaspiBlitz repo (much welcome) and you want to run that code on your RaspiBlitz, there are two ways to do that: If you fork the RaspiBlitz repo (much welcome) and you want to run that code on your RaspiBlitz, there are two ways to do that:
* The quick way: For small changes in scripts, go to `/home/admin` on your running RaspiBlitz, delete the old git with `sudo rm -r raspiblitz` then replace it with your code `git clone [YOURREPO]` and `/home/admin/XXsyncScripts.sh` * The quick way: For small changes in scripts, go to `/home/admin` on your running RaspiBlitz, delete the old git with `sudo rm -r raspiblitz` then replace it with your code `git clone [YOURREPO]` and `patch`
* The long way: If you like to install/remove/change services and system configurations you need to build a SD card from your own code. Prepare like in [Build the SD Card Image](README.md#build-the-sd-card-image) from the README but in the end run the command: * The long way: If you like to install/remove/change services and system configurations you need to build a SD card from your own code. Prepare like in [Build the SD Card Image](README.md#build-the-sd-card-image) from the README but in the end run the command:
`wget --no-cache https://raw.githubusercontent.com/[GITHUB-USERNAME]/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh false false [GITHUB-USERNAME] [BRANCH] lcd true true` `wget --no-cache https://raw.githubusercontent.com/[GITHUB-USERNAME]/raspiblitz/[BRANCH]/build_sdcard.sh && sudo bash build_sdcard.sh false false [GITHUB-USERNAME] [BRANCH] lcd true true`
If you are then working in your forked repo and want to update the scripts on your RaspiBlitz with your latest repo changes, run `/home/admin/XXsyncScripts.sh` - That's OK as long as you don't make changes to the SD card build script - for that you would need to build a fresh SD card again from your repo. If you are then working in your forked repo and want to update the scripts on your RaspiBlitz with your latest repo changes, run `patch` - That's OK as long as you don't make changes to the SD card build script - for that you would need to build a fresh SD card again from your repo.
## How can I checkout a new branch from the RaspiBlitz repo to my forked repo? ## How can I checkout a new branch from the RaspiBlitz repo to my forked repo?
@ -452,7 +452,7 @@ git remote set-url origin [THE-URL-OF-YOUR-FORKED-REPO]
Now to sync your branch namend BRANCH on your forked repo with your RaspiBlitz, you always just run: Now to sync your branch namend BRANCH on your forked repo with your RaspiBlitz, you always just run:
``` ```
/home/admin/XXsyncScripts.sh BRANCH /home/admin/config.scripts/blitz.github.sh BRANCH
``` ```
So your workflow can go like this: You write code on your local computer. Commit to your local repo, push it to your forked repo and use the sync-script above to get the code to your RaspiBlitz. So your workflow can go like this: You write code on your local computer. Commit to your local repo, push it to your forked repo and use the sync-script above to get the code to your RaspiBlitz.
@ -473,14 +473,14 @@ cd /home/admin/raspiblitz
git fetch origin pull/[PRNUMBER]/head:pr[PRNUMBER] git fetch origin pull/[PRNUMBER]/head:pr[PRNUMBER]
git checkout pr[PRNUMBER] git checkout pr[PRNUMBER]
cd /home/admin cd /home/admin
./XXsyncScripts.sh -justinstall /home/admin/config.scripts/blitz.github.sh -justinstall
``` ```
Now you have the code of the PR active - depending on what scripts are changed you might need to reboot. Now you have the code of the PR active - depending on what scripts are changed you might need to reboot.
To change back to the code: To change back to the code:
``` ```
./XXsyncScripts.sh master /home/admin/config.scripts/blitz.github.sh master
``` ```
## How to attach the RaspberryPi to the HDD? ## How to attach the RaspberryPi to the HDD?
@ -839,7 +839,7 @@ https://seravo.fi/2015/using-raid-btrfs-recovering-broken-disks
## How do I fix a displayed Error in my Config? ## How do I fix a displayed Error in my Config?
When the LCD display is telling you to do a config check: When the LCD display is telling you to do a config check:
- go to the RaspiBlitz terminal (X on main menu) and run './XXsyncScripts.sh' - go to the RaspiBlitz terminal (X on main menu) and run 'patch'
- start reboot with command: 'restart' - start reboot with command: 'restart'
- go to the RaspiBlitz terminal run the command: 'check' - go to the RaspiBlitz terminal run the command: 'check'
- now edit the RaspiBlitz config and get rid of the errors: 'nano /mnt/hdd/raspiblitz.conf' - now edit the RaspiBlitz config and get rid of the errors: 'nano /mnt/hdd/raspiblitz.conf'

View file

@ -5,10 +5,10 @@ echo "************* Vagrant Provisioning ********************"
echo 'Syncing local code with RaspiBlitzVM' echo 'Syncing local code with RaspiBlitzVM'
# make sure the lastest sync script is in place # make sure the lastest sync script is in place
cp /vagrant/home.admin/XXsyncScripts.sh /home/admin/XXsyncScripts.sh cp /vagrant/home.admin/config.scripts/blitz.github.sh /home/admin/config.scripts/blitz.github.sh
# execute 'patch' command to sync laptop with VM # execute 'patch' command to sync laptop with VM
/home/admin/XXsyncScripts.sh -run /home/admin/config.scripts/blitz.github.sh -run
source <(/home/admin/config.scripts/internet.sh status) source <(/home/admin/config.scripts/internet.sh status)

View file

@ -101,7 +101,7 @@ patch()
{ {
# get sync info # get sync info
source <(sudo /home/admin/XXsyncScripts.sh info) source <(sudo /home/admin/config.scripts/blitz.github.sh info)
# Patch Options # Patch Options
OPTIONS=(PATCH "Patch/Sync RaspiBlitz with GitHub Repo" \ OPTIONS=(PATCH "Patch/Sync RaspiBlitz with GitHub Repo" \
@ -115,7 +115,7 @@ patch()
clear clear
case $CHOICE in case $CHOICE in
PATCH) PATCH)
sudo -u admin /home/admin/XXsyncScripts.sh -run sudo -u admin /home/admin/config.scripts/blitz.github.sh -run
sleep 4 sleep 4
whiptail --title " Patching/Syncing " --yes-button "Reboot" --no-button "Skip Reboot" --yesno " OK patching/syncing done. whiptail --title " Patching/Syncing " --yes-button "Reboot" --no-button "Skip Reboot" --yesno " OK patching/syncing done.
@ -142,7 +142,7 @@ patch()
newGitHubUser=$(echo "${newGitHubUser}" | cut -d " " -f1) newGitHubUser=$(echo "${newGitHubUser}" | cut -d " " -f1)
echo "--> " ${newGitHubUser} echo "--> " ${newGitHubUser}
error="" error=""
source <(sudo -u admin /home/admin/XXsyncScripts.sh -clean ${activeBranch} ${newGitHubUser}) source <(sudo -u admin /home/admin/config.scripts/blitz.github.sh -clean ${activeBranch} ${newGitHubUser})
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
whiptail --title "ERROR" --msgbox "${error}" 8 30 whiptail --title "ERROR" --msgbox "${error}" 8 30
fi fi
@ -159,7 +159,7 @@ patch()
newGitHubBranch=$(echo "${newGitHubBranch}" | cut -d " " -f1) newGitHubBranch=$(echo "${newGitHubBranch}" | cut -d " " -f1)
echo "--> " $newGitHubBranch echo "--> " $newGitHubBranch
error="" error=""
source <(sudo -u admin /home/admin/XXsyncScripts.sh ${newGitHubBranch}) source <(sudo -u admin /home/admin/config.scripts/blitz.github.sh ${newGitHubBranch})
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
whiptail --title "ERROR" --msgbox "${error}" 8 30 whiptail --title "ERROR" --msgbox "${error}" 8 30
fi fi
@ -178,12 +178,12 @@ patch()
cd /home/admin/raspiblitz cd /home/admin/raspiblitz
git fetch origin pull/${pullRequestID}/head:pr${pullRequestID} git fetch origin pull/${pullRequestID}/head:pr${pullRequestID}
error="" error=""
source <(sudo -u admin /home/admin/XXsyncScripts.sh pr${pullRequestID}) source <(sudo -u admin /home/admin/config.scripts/blitz.github.sh pr${pullRequestID})
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
whiptail --title "ERROR" --msgbox "${error}" 8 30 whiptail --title "ERROR" --msgbox "${error}" 8 30
else else
echo "# update installs .." echo "# update installs .."
/home/admin/XXsyncScripts.sh -justinstall /home/admin/config.scripts/blitz.github.sh -justinstall
fi fi
fi fi
exit 1 exit 1

View file

@ -20,9 +20,52 @@ alias bitcoincli_alias="$bitcoincli_alias"
alias lncli_alias="$lncli_alias" alias lncli_alias="$lncli_alias"
alias lightningcli_alias="$lightningcli_alias" alias lightningcli_alias="$lightningcli_alias"
# Check if ready (chain in sync and channels open) source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net)
./XXchainInSync.sh $network $chain $LNTYPE shopt -s expand_aliases
if [ $? != 0 ]; then alias bitcoincli_alias="$bitcoincli_alias"
alias lncli_alias="$lncli_alias"
alias lightningcli_alias="$lightningcli_alias"
# check if chain is in sync
if [ $LNTYPE = cln ];then
lncommand="lightning-cli"
BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
cmdChainInSync=1
else
cmdChainInSync=0
fi
elif [ $LNTYPE = lnd ];then
lncommand="lncli"
cmdChainInSync="lncli_alias getinfo | grep '"synced_to_chain": true' -c"
fi
chainInSync=${cmdChainInSync}
while [ "${chainInSync}" == "0" ]; do
dialog --title "Fail: not in sync" \
--ok-label "Try now" \
--cancel-label "Give up" \
--pause "\n\n'$lncommand getinfo' shows 'synced_to_chain': false\n\nTry again in a few seconds." 15 60 5
if [ $? -gt 0 ]; then
exit 1
fi
chainInSync=${cmdChainInSync}
done
# check number of connected peers
echo "check for open channels"
if [ $LNTYPE = cln ];then
openChannels=$($lightningcli_alias listpeers | grep -c "CHANNELD_NORMAL")
elif [ $LNTYPE = lnd ];then
openChannels=$($lncli_alias listchannels 2>/dev/null | grep chan_id -c)
fi
if [ ${openChannels} -eq 0 ]; then
echo
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first."
echo "!!!!!!!!!!!!!!!!!!!"
echo
exit 1 exit 1
fi fi

View file

@ -20,10 +20,53 @@ alias bitcoincli_alias="$bitcoincli_alias"
alias lncli_alias="$lncli_alias" alias lncli_alias="$lncli_alias"
alias lightningcli_alias="$lightningcli_alias" alias lightningcli_alias="$lightningcli_alias"
# Check if ready (chain in sync and channels open) source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net)
./XXchainInSync.sh $network $chain $LNTYPE shopt -s expand_aliases
if [ $? != 0 ]; then alias bitcoincli_alias="$bitcoincli_alias"
exit 1 alias lncli_alias="$lncli_alias"
alias lightningcli_alias="$lightningcli_alias"
# check if chain is in sync
if [ $LNTYPE = cln ];then
lncommand="lightning-cli"
BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
cmdChainInSync=1
else
cmdChainInSync=0
fi
elif [ $LNTYPE = lnd ];then
lncommand="lncli"
cmdChainInSync="lncli_alias getinfo | grep '"synced_to_chain": true' -c"
fi
chainInSync=${cmdChainInSync}
while [ "${chainInSync}" == "0" ]; do
dialog --title "Fail: not in sync" \
--ok-label "Try now" \
--cancel-label "Give up" \
--pause "\n\n'$lncommand getinfo' shows 'synced_to_chain': false\n\nTry again in a few seconds." 15 60 5
if [ $? -gt 0 ]; then
exit 1
fi
chainInSync=${cmdChainInSync}
done
# check number of connected peers
echo "check for open channels"
if [ $LNTYPE = cln ];then
openChannels=$($lightningcli_alias listpeers | grep -c "CHANNELD_NORMAL")
elif [ $LNTYPE = lnd ];then
openChannels=$($lncli_alias listchannels 2>/dev/null | grep chan_id -c)
fi
if [ ${openChannels} -eq 0 ]; then
echo
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first."
echo "!!!!!!!!!!!!!!!!!!!"
echo
exit 1
fi fi
paymentRequestStart="???" paymentRequestStart="???"

47
home.admin/XXchainInSync.sh Executable file → Normal file
View file

@ -14,53 +14,6 @@ else
LNTYPE=lnd LNTYPE=lnd
fi fi
source <(/home/admin/config.scripts/network.aliases.sh getvars $LNTYPE ${chain}net)
shopt -s expand_aliases
alias bitcoincli_alias="$bitcoincli_alias"
alias lncli_alias="$lncli_alias"
alias lightningcli_alias="$lightningcli_alias"
# check if chain is in sync
if [ $LNTYPE = cln ];then
lncommand="lightning-cli"
BLOCKHEIGHT=$($bitcoincli_alias getblockchaininfo|grep blocks|awk '{print $2}'|cut -d, -f1)
CLHEIGHT=$($lightningcli_alias getinfo | jq .blockheight)
if [ $BLOCKHEIGHT -eq $CLHEIGHT ];then
cmdChainInSync=1
else
cmdChainInSync=0
fi
elif [ $LNTYPE = lnd ];then
lncommand="lncli"
cmdChainInSync="lncli_alias getinfo | grep '"synced_to_chain": true' -c"
fi
chainInSync=${cmdChainInSync}
while [ "${chainInSync}" == "0" ]; do
dialog --title "Fail: not in sync" \
--ok-label "Try now" \
--cancel-label "Give up" \
--pause "\n\n'$lncommand getinfo' shows 'synced_to_chain': false\n\nTry again in a few seconds." 15 60 5
if [ $? -gt 0 ]; then
exit 1
fi
chainInSync=${cmdChainInSync}
done
# check number of connected peers
echo "check for open channels"
if [ $LNTYPE = cln ];then
openChannels=$($lightningcli_alias listpeers | grep -c "CHANNELD_NORMAL")
elif [ $LNTYPE = lnd ];then
openChannels=$($lncli_alias listchannels 2>/dev/null | grep chan_id -c)
fi
if [ ${openChannels} -eq 0 ]; then
echo
echo "!!!!!!!!!!!!!!!!!!!"
echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first."
echo "!!!!!!!!!!!!!!!!!!!"
echo
exit 1
fi
exit 0 exit 0

View file

@ -465,7 +465,7 @@ if [ ${isMounted} -eq 0 ]; then
# refresh data from info file # refresh data from info file
source ${infoFile} source ${infoFile}
echo "# PROVISION PROCESS with setupPhase(${setupPhase})" echo "# PROVISION PROCESS with setupPhase(${setupPhase})" >> $logFile
# mark system on sd card as in setup process # mark system on sd card as in setup process
echo "the provision process was started but did not finish yet" > /home/admin/provision.flag echo "the provision process was started but did not finish yet" > /home/admin/provision.flag
@ -492,6 +492,7 @@ if [ ${isMounted} -eq 0 ]; then
# if setup - run provision setup first # if setup - run provision setup first
if [ "${setupPhase}" == "setup" ]; then if [ "${setupPhase}" == "setup" ]; then
echo "Calling _provision.setup.sh for basic setup tasks .." >> $logFile echo "Calling _provision.setup.sh for basic setup tasks .." >> $logFile
sed -i "s/^message=.*/message='Provision Setup'/g" ${infoFile}
sudo /home/admin/_provision.setup.sh sudo /home/admin/_provision.setup.sh
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile
@ -503,6 +504,7 @@ if [ ${isMounted} -eq 0 ]; then
# if migration - run the migration provision first # if migration - run the migration provision first
if [ "${setupPhase}" == "migration" ]; then if [ "${setupPhase}" == "migration" ]; then
echo "Calling _provision.migration.sh for possible migrations .." >> $logFile echo "Calling _provision.migration.sh for possible migrations .." >> $logFile
sed -i "s/^message=.*/message='Provision migration'/g" ${infoFile}
sudo /home/admin/_provision.migration.sh sudo /home/admin/_provision.migration.sh
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile
@ -514,6 +516,7 @@ if [ ${isMounted} -eq 0 ]; then
# if update/recovery/migration # if update/recovery/migration
if [ "${setupPhase}" == "update" ] || [ "${setupPhase}" == "recovery" ] || [ "${setupPhase}" == "migration" ]; then if [ "${setupPhase}" == "update" ] || [ "${setupPhase}" == "recovery" ] || [ "${setupPhase}" == "migration" ]; then
echo "Calling _provision.update.sh .." >> $logFile echo "Calling _provision.update.sh .." >> $logFile
sed -i "s/^message=.*/message='Provision Update/Recovery/Migration'/g" ${infoFile}
sudo /home/admin/_provision.update.sh sudo /home/admin/_provision.update.sh
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile
@ -522,13 +525,18 @@ if [ ${isMounted} -eq 0 ]; then
fi fi
fi fi
# finalize provisioning
echo "Calling _bootstrap.provision.sh for general system provisioning (${setupPhase}) .." >> $logFile echo "Calling _bootstrap.provision.sh for general system provisioning (${setupPhase}) .." >> $logFile
sed -i "s/^message=.*/message='Provision Basics'/g" ${infoFile}
sudo /home/admin/_provision_.sh sudo /home/admin/_provision_.sh
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo "EXIT BECAUSE OF ERROR STATE" >> $logFile echo "EXIT BECAUSE OF ERROR STATE" >> $logFile
exit 1 exit 1
fi fi
# mark provision process done
sed -i "s/^message=.*/message='Provision Done'/g" ${infoFile}
################################################### ###################################################
# WAIT LOOP: AFTER FRESH SETUP, MIGRATION # WAIT LOOP: AFTER FRESH SETUP, MIGRATION
# successfull update & recover can skip this # successfull update & recover can skip this

View file

@ -63,7 +63,7 @@ function debug() {
# syncs script with latest set github and branch # syncs script with latest set github and branch
function patch() { function patch() {
cd /home/admin cd /home/admin
./XXsyncScripts.sh -run /home/admin/config.scripts/blitz.github.sh
} }
# command: off # command: off