2020-04-26 15:39:10 +02:00
#!/bin/bash
# load raspiblitz config data
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
source /home/admin/_version.info
2020-09-16 13:33:14 +02:00
## PROCEDURES
2020-04-26 15:39:10 +02:00
release( )
{
whiptail --title "Update Instructions" --yes-button "Not Now" --no-button "Start Update" --yesno " To update your RaspiBlitz to a new version:
- Download the new SD card image to your laptop:
https://github.com/rootzoll/raspiblitz
2020-10-30 12:23:32 +01:00
- Flash that SD card image to a new SD card ( best)
or override old SD card after shutdown ( fallback)
2020-04-26 15:39:10 +02:00
- Choose 'Start Update' below.
No need to close channels or download blockchain again.
Do you want to start the Update now?
" 16 62
if [ $? -eq 0 ] ; then
exit 1
fi
whiptail --title "LND Data Backup" --yes-button "Download Backup" --no-button "Skip" --yesno "
Before we start the RaspiBlitz Update process,
its recommended to make a backup of all your LND Data
and download that file to your laptop.
Do you want to download LND Data Backup now?
" 12 58
if [ $? -eq 0 ] ; then
clear
echo "*************************************"
echo "* PREPARING LND BACKUP DOWNLOAD"
echo "*************************************"
echo "please wait .."
sleep 2
/home/admin/config.scripts/lnd.rescue.sh backup
echo
2020-08-23 12:15:49 +02:00
echo "PRESS ENTER to continue once you're done downloading."
2020-04-26 15:39:10 +02:00
read key
else
clear
echo "*************************************"
echo "* JUST MAKING BACKUP TO OLD SD CARD"
echo "*************************************"
echo "please wait .."
sleep 2
/home/admin/config.scripts/lnd.rescue.sh backup no-download
fi
whiptail --title "READY TO UPDATE?" --yes-button "START UPDATE" --no-button "Cancel" --yesno " If you start the update: The RaspiBlitz will power down.
Once the LCD is white and no LEDs are blicking anymore:
- Remove the Power from RaspiBlitz
- Exchange the old with the new SD card
- Connect Power back to the RaspiBlitz
- Follow the instructions on the LCD
Do you have the SD card with the new version image ready
and do you WANT TO START UPDATE NOW?
" 16 62
if [ $? -eq 1 ] ; then
dialog --title " Update Canceled " --msgbox "
OK. RaspiBlitz will NOT update now.
" 7 39
sudo systemctl start lnd
exit 1
fi
clear
sudo shutdown now
}
2020-04-26 17:56:32 +02:00
patchNotice( )
2020-04-26 15:39:10 +02:00
{
2020-04-26 23:22:33 +02:00
whiptail --title "Patching Notice" --yes-button "Dont Patch" --no-button "Patch Menu" --yesno " This is the possibility to patch your RaspiBlitz:
2020-04-26 15:39:10 +02:00
It means it will sync the program code with the
2020-09-21 16:53:11 +02:00
GitHub repo for your version branch v${ codeVersion } .
2020-04-26 15:39:10 +02:00
2020-12-10 19:18:54 +01:00
This can be useful if there are important updates
in between releases to fix severe bugs. It can also
2020-04-26 15:39:10 +02:00
be used to sync your own code with your RaspiBlitz
if you are developing on your own GitHub Repo.
BUT BEWARE: This means RaspiBlitz will contact GitHub,
hotfix the code and might compromise your security.
Do you want to Patch your RaspiBlitz now?
2020-04-26 15:44:42 +02:00
" 18 58
2020-04-26 15:39:10 +02:00
if [ $? -eq 0 ] ; then
exit 1
fi
2020-04-26 17:56:32 +02:00
}
patch( )
{
2020-04-26 15:39:10 +02:00
# get sync info
source <( sudo /home/admin/XXsyncScripts.sh info)
# Patch Options
2020-04-26 15:43:06 +02:00
OPTIONS = ( PATCH "Patch/Sync RaspiBlitz with GitHub Repo" \
2020-04-26 15:39:10 +02:00
REPO "Change GitHub Repo to sync with" \
2020-09-10 16:15:00 +02:00
BRANCH "Change GitHub Branch to sync with" \
PR "Checkout a PullRequest to test"
2020-04-26 15:39:10 +02:00
)
2020-09-10 16:15:00 +02:00
CHOICE = $( whiptail --clear --title " GitHub-User: ${ activeGitHubUser } Branch: ${ activeBranch } " --menu "" 11 55 4 " ${ OPTIONS [@] } " 2>& 1 >/dev/tty)
2020-04-26 15:39:10 +02:00
clear
case $CHOICE in
PATCH)
2020-06-01 22:56:51 +02:00
sudo -u admin /home/admin/XXsyncScripts.sh -run
2020-04-26 18:17:06 +02:00
sleep 4
2020-04-26 22:06:44 +02:00
whiptail --title " Patching/Syncing " --yes-button "Reboot" --no-button "Skip Reboot" --yesno " OK patching/syncing done.
2020-04-26 18:17:06 +02:00
By default a reboot is advised.
Only skip reboot if you know
it will work without restart.
" 11 40
if [ $? -eq 0 ] ; then
2020-04-26 18:38:42 +02:00
clear
2020-04-26 18:27:02 +02:00
echo "REBOOT .."
/home/admin/XXshutdown.sh reboot
sleep 8
2020-04-26 18:17:06 +02:00
else
2020-04-26 18:27:02 +02:00
echo "SKIP REBOOT .."
2020-04-26 18:17:06 +02:00
fi
exit 1
2020-04-26 15:39:10 +02:00
; ;
REPO)
2020-04-26 20:07:02 +02:00
clear
2020-04-26 22:01:56 +02:00
echo "..."
2020-04-26 20:07:02 +02:00
newGitHubUser = $( whiptail --inputbox "\nPlease enter the GitHub USERNAME of the forked RaspiBlitz Repo?" 10 38 ${ activeGitHubUser } --title "Change Sync Repo" 3>& 1 1>& 2 2>& 3)
exitstatus = $?
if [ $exitstatus = 0 ] ; then
newGitHubUser = $( echo " ${ newGitHubUser } " | cut -d " " -f1)
2020-04-26 21:54:24 +02:00
echo "--> " ${ newGitHubUser }
2020-04-26 22:01:56 +02:00
error = ""
source <( sudo -u admin /home/admin/XXsyncScripts.sh -clean ${ activeBranch } ${ newGitHubUser } )
2020-04-26 21:54:24 +02:00
if [ ${# error } -gt 0 ] ; then
whiptail --title "ERROR" --msgbox " ${ error } " 8 30
fi
2020-04-26 20:07:02 +02:00
fi
2020-04-26 15:39:10 +02:00
patch
exit 1
; ;
BRANCH)
2020-04-26 20:07:02 +02:00
clear
2020-04-26 22:01:56 +02:00
echo "..."
2020-04-26 20:07:02 +02:00
newGitHubBranch = $( whiptail --inputbox " \nPlease enter the GitHub BRANCH of the RaspiBlitz Repo ' ${ activeGitHubUser } '? " 10 38 ${ activeBranch } --title "Change Sync Branch" 3>& 1 1>& 2 2>& 3)
exitstatus = $?
if [ $exitstatus = 0 ] ; then
newGitHubBranch = $( echo " ${ newGitHubBranch } " | cut -d " " -f1)
echo "--> " $newGitHubBranch
2020-04-26 22:01:56 +02:00
error = ""
2020-09-14 12:49:10 +02:00
source <( sudo -u admin /home/admin/XXsyncScripts.sh ${ newGitHubBranch } )
2020-04-26 21:54:24 +02:00
if [ ${# error } -gt 0 ] ; then
whiptail --title "ERROR" --msgbox " ${ error } " 8 30
fi
2020-04-26 20:07:02 +02:00
fi
2020-04-26 15:39:10 +02:00
patch
exit 1
; ;
2020-09-10 16:15:00 +02:00
PR)
clear
echo "..."
pullRequestID = $( whiptail --inputbox " \nPlease enter the NUMBER of the PullRequest on RaspiBlitz Repo ' ${ activeGitHubUser } '? " 10 46 --title "Checkout PullRequest ID" 3>& 1 1>& 2 2>& 3)
exitstatus = $?
if [ $exitstatus = 0 ] ; then
pullRequestID = $( echo " ${ pullRequestID } " | cut -d " " -f1)
2020-10-06 21:06:14 +02:00
echo "# --> " $pullRequestID
2020-09-10 16:15:00 +02:00
cd /home/admin/raspiblitz
2020-09-10 21:11:57 +02:00
git fetch origin pull/${ pullRequestID } /head:pr${ pullRequestID }
2020-09-10 16:15:00 +02:00
error = ""
2020-09-14 12:49:10 +02:00
source <( sudo -u admin /home/admin/XXsyncScripts.sh pr${ pullRequestID } )
2020-09-10 16:15:00 +02:00
if [ ${# error } -gt 0 ] ; then
whiptail --title "ERROR" --msgbox " ${ error } " 8 30
2020-10-06 21:06:14 +02:00
else
echo "# update installs .."
/home/admin/XXsyncScripts.sh -justinstall
2020-09-10 16:15:00 +02:00
fi
fi
exit 1
; ;
2020-04-26 15:39:10 +02:00
esac
}
lnd( )
{
2020-04-27 00:13:47 +02:00
# get lnd info
source <( sudo -u admin /home/admin/config.scripts/lnd.update.sh info)
# LND Update Options
2020-07-11 20:40:30 +02:00
OPTIONS = ( )
2020-09-15 16:32:58 +02:00
if [ ${ lndUpdateInstalled } -eq 0 ] ; then
OPTIONS += ( VERIFIED " Optional LND update to ${ lndUpdateVersion } " )
fi
2020-07-11 20:40:30 +02:00
OPTIONS += ( RECKLESS " Experimental LND update to ${ lndLatestVersion } " )
2020-04-27 00:13:47 +02:00
2020-04-27 00:21:36 +02:00
CHOICE = $( whiptail --clear --title "Update LND Options" --menu "" 9 60 2 " ${ OPTIONS [@] } " 2>& 1 >/dev/tty)
2020-04-27 00:13:47 +02:00
clear
case $CHOICE in
2020-04-28 20:55:09 +02:00
VERIFIED)
2020-04-27 00:13:47 +02:00
if [ ${ lndUpdateInstalled } -eq 1 ] ; then
whiptail --title "ALREADY INSTALLED" --msgbox " The LND version ${ lndUpdateVersion } is already installed. " 8 30
exit 1
fi
whiptail --title "OPTIONAL LND UPDATE" --yes-button "Cancel" --no-button "Update" --yesno " BEWARE on updating to LND v ${ lndUpdateVersion } :
${ lndUpdateComment }
Do you really want to update LND now?
" 16 58
if [ $? -eq 0 ] ; then
echo "# cancel update"
exit 1
fi
2020-05-01 18:20:47 +02:00
# if loop is installed remove
if [ " ${ loop } " = = "on" ] ; then
2020-05-14 22:55:27 +02:00
sudo -u admin /home/admin/config.scripts/bonus.loop.sh off
2020-05-01 18:20:47 +02:00
fi
2020-04-27 00:28:09 +02:00
error = ""
2020-05-01 18:20:47 +02:00
warn = ""
2020-04-28 20:55:09 +02:00
source <( sudo -u admin /home/admin/config.scripts/lnd.update.sh verified)
2020-04-27 00:28:09 +02:00
if [ ${# error } -gt 0 ] ; then
whiptail --title "ERROR" --msgbox " ${ error } " 8 30
else
2020-05-01 18:20:47 +02:00
# if loop was installed before reinstall
if [ " ${ loop } " = = "on" ] ; then
sudo -u admin /home/admin/config.scripts/bonus.loop.sh on
fi
2020-04-27 00:28:09 +02:00
/home/admin/XXshutdown.sh reboot
sleep 8
fi
2020-04-27 00:13:47 +02:00
; ;
RECKLESS)
2020-04-27 00:28:09 +02:00
whiptail --title " RECKLESS LND UPDATE to ${ lndLatestVersion } " --yes-button "Cancel" --no-button "Update" --yesno " Using the 'RECKLESS' LND update will simply
2020-04-27 00:13:47 +02:00
grab the latest LND release published on the LND 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 LND now?
" 16 58
if [ $? -eq 0 ] ; then
echo "# cancel update"
exit 1
fi
2020-04-27 00:28:09 +02:00
error = ""
source <( sudo -u admin /home/admin/config.scripts/lnd.update.sh reckless)
if [ ${# error } -gt 0 ] ; then
whiptail --title "ERROR" --msgbox " ${ error } " 8 30
else
/home/admin/XXshutdown.sh reboot
sleep 8
fi
2020-04-27 00:13:47 +02:00
; ;
esac
2020-04-26 15:39:10 +02:00
}
2020-09-16 13:33:14 +02:00
# quick call by parameter
if [ " $1 " = = "github" ] ; then
patch
exit 0
fi
# Basic Options Menu
OPTIONS = (
RELEASE "RaspiBlitz Release Update/Recovery" \
LND "Interim LND Update Options" \
PATCH " Patch RaspiBlitz v ${ codeVersion } "
)
if [ " ${ bos } " = = "on" ] ; then
OPTIONS += ( BOS "Update Balance of Satoshis" )
fi
if [ " ${ thunderhub } " = = "on" ] ; then
OPTIONS += ( THUB "Update ThunderHub" )
fi
if [ " ${ specter } " = = "on" ] ; then
OPTIONS += ( SPECTER "Update Cryptoadvance Specter" )
fi
2020-10-13 09:45:17 +02:00
if [ " ${ rtlWebinterface } " = = "on" ] ; then
OPTIONS += ( RTL "Update RTL" )
fi
2020-10-20 12:45:47 +02:00
if [ " ${ pyblock } " = = "on" ] ; then
OPTIONS += ( PYBLOCK "Update PyBLOCK" )
fi
2020-11-18 01:36:12 +01:00
if [ " ${ pool } " = = "on" ] ; then
OPTIONS += ( POOL "Update Lightning Pool" )
fi
2020-11-17 02:21:57 +01:00
if [ " ${ loop } " = = "on" ] ; then
OPTIONS += ( LOOP "Update Lightning Loop" )
fi
2020-11-15 23:16:13 +01:00
if [ " ${ runBehindTor } " = = "on" ] ; then
OPTIONS += ( TOR "Update Tor from the source code" )
fi
2020-11-27 00:53:54 +01:00
if [ " ${ sphinxrelay } " = = "on" ] ; then
OPTIONS += ( SPHINX "Update Sphinx Server Relay" )
fi
2020-09-16 13:33:14 +02:00
CHOICE = $( whiptail --clear --title "Update Options" --menu "" 13 55 6 " ${ OPTIONS [@] } " 2>& 1 >/dev/tty)
2020-04-26 15:39:10 +02:00
clear
case $CHOICE in
RELEASE)
release
; ;
PATCH)
2020-04-26 17:56:32 +02:00
patchNotice
2020-04-26 15:39:10 +02:00
patch
; ;
LND)
lnd
; ;
2020-06-01 12:32:28 +02:00
BOS)
/home/admin/config.scripts/bonus.bos.sh update
; ;
THUB)
/home/admin/config.scripts/bonus.thunderhub.sh update
; ;
2020-09-02 11:11:50 +02:00
SPECTER)
/home/admin/config.scripts/bonus.cryptoadvance-specter.sh update
; ;
2020-10-13 09:45:17 +02:00
RTL)
/home/admin/config.scripts/bonus.rtl.sh update
; ;
2020-11-27 00:53:54 +01:00
SPHINX)
/home/admin/config.scripts/bonus.sphinxrelay.sh update
; ;
2020-10-20 12:45:47 +02:00
PYBLOCK)
/home/admin/config.scripts/bonus.pyblock.sh update
; ;
2020-11-15 23:16:13 +01:00
POOL)
/home/admin/config.scripts/bonus.pool.sh update
; ;
2020-11-17 02:21:57 +01:00
LOOP)
/home/admin/config.scripts/bonus.loop.sh update
; ;
2020-11-15 23:16:13 +01:00
TOR)
sudo /home/admin/config.scripts/internet.tor.sh update
; ;
2020-08-23 12:15:49 +02:00
esac