From 5771035584fc5b6706fd4622e115872e8ce0ef92 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 24 Jun 2021 21:08:00 +0200 Subject: [PATCH 1/3] add more debug info --- home.admin/_bootstrap.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/home.admin/_bootstrap.sh b/home.admin/_bootstrap.sh index ff2d52f2a..76ed9d3c8 100755 --- a/home.admin/_bootstrap.sh +++ b/home.admin/_bootstrap.sh @@ -465,7 +465,7 @@ if [ ${isMounted} -eq 0 ]; then # refresh data from info file source ${infoFile} - echo "# PROVISION PROCESS with setupPhase(${setupPhase})" + echo "# PROVISION PROCESS with setupPhase(${setupPhase})" >> $logFile # mark system on sd card as in setup process 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 [ "${setupPhase}" == "setup" ]; then 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 if [ "$?" != "0" ]; then echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile @@ -503,6 +504,7 @@ if [ ${isMounted} -eq 0 ]; then # if migration - run the migration provision first if [ "${setupPhase}" == "migration" ]; then echo "Calling _provision.migration.sh for possible migrations .." >> $logFile + sed -i "s/^message=.*/message='Provision migration'/g" ${infoFile} sudo /home/admin/_provision.migration.sh if [ "$?" != "0" ]; then echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile @@ -514,6 +516,7 @@ if [ ${isMounted} -eq 0 ]; then # if update/recovery/migration if [ "${setupPhase}" == "update" ] || [ "${setupPhase}" == "recovery" ] || [ "${setupPhase}" == "migration" ]; then echo "Calling _provision.update.sh .." >> $logFile + sed -i "s/^message=.*/message='Provision Update/Recovery/Migration'/g" ${infoFile} sudo /home/admin/_provision.update.sh if [ "$?" != "0" ]; then echo "EXIT BECAUSE OF ERROR STATE ($?)" >> $logFile @@ -522,13 +525,18 @@ if [ ${isMounted} -eq 0 ]; then fi fi + # finalize provisioning 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 if [ "$?" != "0" ]; then echo "EXIT BECAUSE OF ERROR STATE" >> $logFile exit 1 fi + # mark provision process done + sed -i "s/^message=.*/message='Provision Done'/g" ${infoFile} + ################################################### # WAIT LOOP: AFTER FRESH SETUP, MIGRATION # successfull update & recover can skip this From a971485c24e772b671c13f0467d2f31a281c2851 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 24 Jun 2021 21:20:48 +0200 Subject: [PATCH 2/3] moving github script --- FAQ.md | 12 ++++++------ .../amd64/packer/scripts/init_vagrant.sh | 4 ++-- home.admin/99updateMenu.sh | 12 ++++++------ home.admin/_commands.sh | 2 +- .../blitz.github.sh} | 0 5 files changed, 15 insertions(+), 15 deletions(-) rename home.admin/{XXsyncScripts.sh => config.scripts/blitz.github.sh} (100%) diff --git a/FAQ.md b/FAQ.md index 29803c837..f7fa39dc2 100644 --- a/FAQ.md +++ b/FAQ.md @@ -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: -* 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: `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? @@ -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: ``` -/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. @@ -473,14 +473,14 @@ cd /home/admin/raspiblitz git fetch origin pull/[PRNUMBER]/head:pr[PRNUMBER] git checkout pr[PRNUMBER] 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. 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? @@ -839,7 +839,7 @@ https://seravo.fi/2015/using-raid-btrfs-recovering-broken-disks ## How do I fix a displayed Error in my Config? 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' - 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' diff --git a/alternative.platforms/amd64/packer/scripts/init_vagrant.sh b/alternative.platforms/amd64/packer/scripts/init_vagrant.sh index 2ead12ece..ed01e8e74 100644 --- a/alternative.platforms/amd64/packer/scripts/init_vagrant.sh +++ b/alternative.platforms/amd64/packer/scripts/init_vagrant.sh @@ -5,10 +5,10 @@ echo "************* Vagrant Provisioning ********************" echo 'Syncing local code with RaspiBlitzVM' # 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 -/home/admin/XXsyncScripts.sh -run +/home/admin/config.scripts/blitz.github.sh -run source <(/home/admin/config.scripts/internet.sh status) diff --git a/home.admin/99updateMenu.sh b/home.admin/99updateMenu.sh index 3c96d092a..0d251c497 100755 --- a/home.admin/99updateMenu.sh +++ b/home.admin/99updateMenu.sh @@ -101,7 +101,7 @@ patch() { # get sync info - source <(sudo /home/admin/XXsyncScripts.sh info) + source <(sudo /home/admin/config.scripts/blitz.github.sh info) # Patch Options OPTIONS=(PATCH "Patch/Sync RaspiBlitz with GitHub Repo" \ @@ -115,7 +115,7 @@ patch() clear case $CHOICE in PATCH) - sudo -u admin /home/admin/XXsyncScripts.sh -run + sudo -u admin /home/admin/config.scripts/blitz.github.sh -run sleep 4 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) echo "--> " ${newGitHubUser} 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 whiptail --title "ERROR" --msgbox "${error}" 8 30 fi @@ -159,7 +159,7 @@ patch() newGitHubBranch=$(echo "${newGitHubBranch}" | cut -d " " -f1) echo "--> " $newGitHubBranch 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 whiptail --title "ERROR" --msgbox "${error}" 8 30 fi @@ -178,12 +178,12 @@ patch() cd /home/admin/raspiblitz git fetch origin pull/${pullRequestID}/head:pr${pullRequestID} 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 whiptail --title "ERROR" --msgbox "${error}" 8 30 else echo "# update installs .." - /home/admin/XXsyncScripts.sh -justinstall + /home/admin/config.scripts/blitz.github.sh -justinstall fi fi exit 1 diff --git a/home.admin/_commands.sh b/home.admin/_commands.sh index 9ad496234..5e1ce3f25 100755 --- a/home.admin/_commands.sh +++ b/home.admin/_commands.sh @@ -60,7 +60,7 @@ function debug() { # syncs script with latest set github and branch function patch() { cd /home/admin - ./XXsyncScripts.sh -run + /home/admin/config.scripts/blitz.github.sh } # command: off diff --git a/home.admin/XXsyncScripts.sh b/home.admin/config.scripts/blitz.github.sh similarity index 100% rename from home.admin/XXsyncScripts.sh rename to home.admin/config.scripts/blitz.github.sh From e85e118e5b8a6fbc605e390f3a78d8bf7b96d214 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 24 Jun 2021 21:25:38 +0200 Subject: [PATCH 3/3] remove chain in sync --- home.admin/BBcreateInvoice.sh | 27 ++++++++++++++++++++++--- home.admin/BBpayInvoice.sh | 29 +++++++++++++++++++++++---- home.admin/XXchainInSync.sh | 37 ----------------------------------- 3 files changed, 49 insertions(+), 44 deletions(-) delete mode 100755 home.admin/XXchainInSync.sh diff --git a/home.admin/BBcreateInvoice.sh b/home.admin/BBcreateInvoice.sh index a291bf1a7..f6c63427a 100755 --- a/home.admin/BBcreateInvoice.sh +++ b/home.admin/BBcreateInvoice.sh @@ -14,9 +14,30 @@ if [ ${#chain} -eq 0 ]; then chain=$(${network}-cli getblockchaininfo | jq -r '.chain') fi -# Check if ready (chain in sync and channels open) -./XXchainInSync.sh $network $chain -if [ $? != 0 ]; then +# check if chain is in sync +cmdChainInSync="lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c" +chainInSync=${cmdChainInSync} +while [ "${chainInSync}" == "0" ]; do + dialog --title "Fail: not in sync" \ + --ok-label "Try now" \ + --cancel-label "Give up" \ + --pause "\n\n'lncli 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" +openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | grep chan_id -c) +if [ ${openChannels} -eq 0 ]; then + echo "" + echo "!!!!!!!!!!!!!!!!!!!" + echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first." + echo "!!!!!!!!!!!!!!!!!!!" + echo "" exit 1 fi diff --git a/home.admin/BBpayInvoice.sh b/home.admin/BBpayInvoice.sh index aafcc8418..59fb8c3b0 100755 --- a/home.admin/BBpayInvoice.sh +++ b/home.admin/BBpayInvoice.sh @@ -14,10 +14,31 @@ if [ ${#chain} -eq 0 ]; then chain=$(${network}-cli getblockchaininfo | jq -r '.chain') fi -# Check if ready (chain in sync and channels open) -./XXchainInSync.sh $network $chain -if [ $? != 0 ]; then - exit 1 +# check if chain is in sync +cmdChainInSync="lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c" +chainInSync=${cmdChainInSync} +while [ "${chainInSync}" == "0" ]; do + dialog --title "Fail: not in sync" \ + --ok-label "Try now" \ + --cancel-label "Give up" \ + --pause "\n\n'lncli 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" +openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | grep chan_id -c) +if [ ${openChannels} -eq 0 ]; then + echo "" + echo "!!!!!!!!!!!!!!!!!!!" + echo "FAIL - You have NO ESTABLISHED CHANNELS .. open a channel first." + echo "!!!!!!!!!!!!!!!!!!!" + echo "" + exit 1 fi paymentRequestStart="???" diff --git a/home.admin/XXchainInSync.sh b/home.admin/XXchainInSync.sh deleted file mode 100755 index 9e102072e..000000000 --- a/home.admin/XXchainInSync.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# Check if lnd is synced to chain and channels are open -# If it isn't, wait until it is -# exits with 1 if it isn't. - -network=$1 -chain=$2 - -# check if chain is in sync -cmdChainInSync="lncli --chain=${network} --network=${chain}net getinfo | grep '"synced_to_chain": true' -c" -chainInSync=${cmdChainInSync} -while [ "${chainInSync}" == "0" ]; do - dialog --title "Fail: not in sync" \ - --ok-label "Try now" \ - --cancel-label "Give up" \ - --pause "\n\n'lncli 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" -openChannels=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net listchannels 2>/dev/null | grep chan_id -c) -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