cleaner file seperation

This commit is contained in:
rootzoll
2021-05-03 14:00:01 +02:00
parent 12bd7fe981
commit 7d01ef1c1f
11 changed files with 551 additions and 389 deletions

View File

@@ -1,237 +0,0 @@
#!/bin/bash
# get basic info
source /home/admin/raspiblitz.info
# temp file for dialog results
_temp=$(mktemp -p /dev/shm/)
# flags of what passwords are to set by user
setPasswordA=1
setPasswordB=1
setPasswordC=1
# choose blockchain or select migration
OPTIONS=()
OPTIONS+=(BITCOIN1 "Setup BITCOIN & Lightning Network Daemon (LND)")
OPTIONS+=(BITCOIN2 "Setup BITCOIN & c-lightning by blockstream")
OPTIONS+=(LITECOIN "Setup LITECOIN & Lightning Network Daemon (LND)")
OPTIONS+=(MIGRATION "Upload a Migration File from old RaspiBlitz")
CHOICE=$(dialog --clear \
--backtitle "RaspiBlitz ${codeVersion} - Setup" \
--title "⚡ Welcome to your RaspiBlitz ⚡" \
--menu "\nChoose how you want to setup your RaspiBlitz: \n " \
13 64 7 \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
network=""
lightning=""
case $CHOICE in
BITCOIN1)
network="bitcoin"
lightning="lnd"
;;
BITCOIN2)
network="bitcoin"
lightning="cln"
;;
LITECOIN)
network="litecoin"
lightning="lnd"
;;
MIGRATION)
# send over to the migration dialogs
/home/admin/00migrationDialog.sh raspiblitz
exit 0
;;
esac
# on cancel - exit to terminal
if [ "${network}" == "" ]; then
echo "# you selected cancel - exited to terminal"
echo "# use command 'restart' to reboot & start again"
exit 1
fi
# prepare the config file (what will later become the raspiblitz.config)
source /home/admin/_version.info
CONFIGFILE="/home/admin/raspiblitz.config.tmp"
rm $CONFIGFILE 2>/dev/null
echo "# RASPIBLITZ CONFIG FILE" > $CONFIGFILE
echo "raspiBlitzVersion='${codeVersion}'" >> $CONFIGFILE
echo "lcdrotate=1" >> $CONFIGFILE
echo "lightning=${lightning}" >> $CONFIGFILE
echo "network=${network}" >> $CONFIGFILE
echo "chain=main" >> $CONFIGFILE
echo "runBehindTor=on" >> $CONFIGFILE
# prepare the setup file (that constains info just needed for the rest of setup process)
SETUPFILE="/home/admin/raspiblitz.setup.tmp"
rm $SETUPFILE 2>/dev/null
echo "# RASPIBLITZ SETUP FILE" > $SETUPFILE
###################
# ENTER NAME
###################
# welcome and ask for name of RaspiBlitz
result=""
while [ ${#result} -eq 0 ]
do
l1="Please enter the name of your new RaspiBlitz:\n"
l2="one word, keep characters basic & not too long"
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --inputbox "$l1$l2" 11 52 2>$_temp
result=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' )
shred -u $_temp
echo "processing ..."
sleep 3
done
echo "hostname=${result}" >> $CONFIGFILE
###################
# DECIDE LIGHTNING
# do this before passwords, because password C not needed if LND rescue file is uploaded
###################
# flags for sub dialogs after choice
uploadLNDRESCUE=0
enterSEED=0
uploadSCB=0
OPTIONS=()
OPTIONS+=(NEW "Setup a brand new Lightning Node (DEFAULT)")
OPTIONS+=(OLD "I had an old Node I want to recover/restore")
CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "LND Setup" --menu "LND Data & Wallet" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
if [ "${CHOICE}" == "NEW" ]; then
# mark all passwords to be set at the end
setPasswordA=1
setPasswordB=1
setPasswordC=1
elif [ "${CHOICE}" == "OLD" ]; then
CHOICE=""
while [ "${CHOICESUB}" == "" ]
do
# get more details what kind of old lightning wallet user has
OPTIONS=()
OPTIONS+=(LNDRESCUE "LND tar.gz-Backupfile (BEST)")
OPTIONS+=(SEED+SCB "Seed & channel.backup file (OK)")
OPTIONS+=(ONLYSEED "Only Seed Word List (FALLBACK)")
CHOICESUB=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
if [ "${CHOICESUB}" == "LNDRESCUE" ]; then
# just activate LND rescue upload
uploadLNDRESCUE=1
# dont set password c anymore later on
setPasswordC=0
elif [ "${CHOICESUB}" == "SEED+SCB" ]; then
# activate SEED input & SCB upload
enterSEED=1
uploadSCB=1
elif [ "${CHOICESUB}" == "ONLYSEED" ]; then
# let people know about the difference between SEED & SEED+SCB
whiptail --title "IMPORTANT INFO" --yes-button "JUST SEED" --no-button "Go Back" --yesno "
Using JUST SEED WORDS will only recover your on-chain funds.
To also try to recover the open channel funds you need the
channel.backup file (since RaspiBlitz v1.2 / LND 0.6-beta)
or having a complete LND rescue-backup from your old node.
" 11 65
if [ $? -eq 1 ]; then
# when user wants to go back
CHOICESUB=""
else
# activate SEED input & SCB upload
enterSEED=1
fi
else
echo "# you selected cancel - exited to terminal"
echo "# use command 'restart' to reboot & start again"
exit 1
fi
done
else
echo "# you selected cancel - exited to terminal"
echo "# use command 'restart' to reboot & start again"
exit 1
fi
# UPLOAD LND RESCUE FILE dialog (if activated by dialogs above)
if [ ${uploadLNDRESCUE} -eq 1 ]; then
/home/admin/config.scripts/lnd.backup.sh lnd-import-gui setup $SETUPFILE
exit 1
fi
# INPUT LIGHTNING SEED dialog (if activated by dialogs above)
if [ ${enterSEED} -eq 1 ]; then
/home/admin/config.scripts/lnd.backup.sh seed-import-gui
# load results from results file
source <(/var/cache/raspiblitz/seed-import.results)
# if user canceled the seed input
if [ "${seedWords}" == "" ]; then
echo "# you selected cancel - exited to terminal"
echo "# use command 'restart' to reboot & start again"
exit 1
fi
echo "seedWords='${seedWords}'" >> $SETUPFILE
echo "seedPassword='${seedPassword}'" >> $SETUPFILE
fi
# UPLOAD STATIC CHANNEL BACKUP FILE dialog (if activated by dialogs above)
if [ ${uploadSCB} -eq 1 ]; then
/home/admin/config.scripts/lnd.backup.sh scb-import-gui setup $SETUPFILE
fi
###################
# ENTER PASSWORDS ---> combine with migration dialog to reduce code duplication
###################
# show password info dialog
dialog --backtitle "RaspiBlitz - Setup" --msgbox "RaspiBlitz uses 3 different passwords.
Referenced as password A, B & C.
PASSWORD A) Main User Password (SSH & WebUI, sudo)
PASSWORD B) APP Password (RPC & Additional Apps)
PASSWORD C) Lightning Wallet Password for Unlock
Set now the 3 passwords - all min 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 15 54
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD A - Main User Password" $_temp
password=$(sudo cat $_temp)
echo "passwordA='${password}'" >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password A set" 7 20
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD B - APP Password" $_temp
password=$(sudo cat $_temp)
echo "passwordB='${password}'" >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password B set" 7 20
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD C - Lightning Wallet Password" $_temp
password=$(sudo cat $_temp)
echo "passwordC='${password}'" >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password C set" 7 20
clear
echo "# setup dialog done - results in:"
echo "# $CONFIGFILE"
echo "# $SETUPFILE"

View File

@@ -1,14 +0,0 @@
#!/bin/bash
_temp=$(mktemp -p /dev/shm/)
## get basic info
source /home/admin/raspiblitz.info 2>/dev/null
###################
# CHECK IF DNS NEEDS SETTING DURING SETUP
# https://github.com/rootzoll/raspiblitz/issues/787
###################
sudo /home/admin/config.scripts/internet.dns.sh test
# TODO: if DNS is not working --> ask in provision dialog
# TODO: get size of sd card & free space on sd card

View File

@@ -158,12 +158,9 @@ fi
echo "# COPYING from GIT-Directory to /home/admin/"
sudo rm -r /home/admin/config.scripts
sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/*.* /home/admin
sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/assets /home/admin
sudo -u admin chmod +x /home/admin/*.sh
sudo -u admin chmod +x /home/admin/*.py
sudo -u admin chmod +x /home/admin/config.scripts/*.sh
sudo -u admin chmod +x /home/admin/config.scripts/*.py
sudo -u admin cp -r -f /home/admin/raspiblitz/home.admin/* /home/admin
sudo -u admin chmod -R +x /home/admin/config.scripts
sudo -u admin chmod -R +x /home/admin/setup.scripts
echo "# ******************************************"
echo "# Checking if the content of BlitzPy changed .."

View File

@@ -23,6 +23,13 @@ function menu() {
./00mainMenu.sh
}
# command: setup
# calls the setup process
function setup() {
cd /home/admin
./setup.scripts/setupDialogControl.sh
}
# command: repair
# calls directly the repair menu
function repair() {

View File

@@ -8,19 +8,19 @@ if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# lnd.backup.sh lnd-export"
echo "# lnd.backup.sh lnd-export-gui"
echo "# lnd.backup.sh lnd-import [file]"
echo "# lnd.backup.sh lnd-import-gui [setup|production]"
echo "# lnd.backup.sh lnd-import-gui [setup|production] [?resultfile]"
echo "# ---------------------------------------------------"
echo "# STATIC CHANNEL BACKUP"
echo "# ---------------------------------------------------"
echo "# lnd.backup.sh scb-export"
echo "# lnd.backup.sh scb-export-gui"
echo "# lnd.backup.sh scb-import [file]"
echo "# lnd.backup.sh scb-import-gui [setup|production]"
echo "# lnd.backup.sh scb-import-gui [setup|production] [?resultfile]"
echo "# ---------------------------------------------------"
echo "# SEED WORDS"
echo "# ---------------------------------------------------"
echo "# lnd.backup.sh seed-export-gui [lndseeddata]"
echo "# lnd.backup.sh seed-import-gui"
echo "# lnd.backup.sh seed-import-gui [resultfile]"
exit 1
fi
@@ -163,10 +163,10 @@ if [ ${mode} = "lnd-import-gui" ]; then
exit 1
fi
# scenario setup needs a 3rd parameter - the SETUPFILE to store results in
# scenario setup needs a 3rd parameter - the RESULTFILE to store results in
if [ "${scenario}" == "setup" ]; then
SETUPFILE=$3
if [ "${SETUPFILE}" == "" ]; then
RESULTFILE=$3
if [ "${RESULTFILE}" == "" ]; then
echo "error='mising parameter'"
exit 1
fi
@@ -235,8 +235,8 @@ if [ ${mode} = "lnd-import-gui" ]; then
# in setup scenario the final import is happening during provison
if [ "${scenario}" == "setup" ]; then
# just add lndrescue filename to give file
echo "lndrescue='${filename}'" >> $SETUPFILE
echo ""
echo "# result in: ${RESULTFILE} (remember to make clean delete once processed)"
echo "lndrescue='${filename}'" >> $RESULTFILE
exit 0
fi
@@ -349,10 +349,10 @@ if [ ${mode} = "scb-import-gui" ]; then
exit 1
fi
# scenario setup needs a 3rd parameter - the SETUPFILE to store results in
# scenario setup needs a 3rd parameter - the RESULTFILE to store results in
if [ "${scenario}" == "setup" ]; then
SETUPFILE=$3
if [ "${SETUPFILE}" == "" ]; then
RESULTFILE=$3
if [ "${RESULTFILE}" == "" ]; then
echo "error='mising parameter'"
exit 1
fi
@@ -421,8 +421,8 @@ if [ ${mode} = "scb-import-gui" ]; then
# in setup scenario the final import is happening during provison
if [ "${scenario}" == "setup" ]; then
# just add staticchannelbackup filename to give file
echo "staticchannelbackup='${filename}'" >> $SETUPFILE
echo ""
echo "# result in: ${RESULTFILE} (remember to make clean delete once processed)"
echo "staticchannelbackup='${filename}'" >> $RESULTFILE
exit 0
fi
@@ -471,6 +471,13 @@ if [ ${mode} = "seed-import-gui" ]; then
# fake seed 24 words for testing input:
# eins zwei polizei drei vier great idea fünf sechs alte keks sieben auch gute nacht ja ja ja was ist los was ist das
# scenario setup needs a 3rd parameter - the RESULTFILE to store results in
RESULTFILE=$3
if [ "${RESULTFILE}" == "" ]; then
echo "error='mising parameter'"
exit 1
fi
# prepare seed result file
sudo rm /var/cache/raspiblitz/seed-import.results 2>/dev/null
sudo touch /var/cache/raspiblitz/seed-import.results
@@ -515,7 +522,7 @@ wordone wordtweo wordthree ...
if [ $? -eq 1 ]; then
clear
echo "# CANCEL empty results in: /var/cache/raspiblitz/seed-import.results"
echo "# CANCEL empty results in: ${RESULTFILE}"
exit 1
fi
fi
@@ -540,9 +547,9 @@ to protect the seed words. Most users did not set this.
# writing result file data
clear
echo "# result of in mem cache: /var/cache/raspiblitz/seed-import.results"
echo "seedWords='${wordstring}'" >> /var/cache/raspiblitz/seed-import.results
echo "seedPassword='${passwordD}'" >> /var/cache/raspiblitz/seed-import.results
echo "# result in: ${RESULTFILE} (remember to make clean delete once processed)"
echo "seedWords='${wordstring}'" >> $RESULTFILE
echo "seedPassword='${passwordD}'" >> $RESULTFILE
exit 0
fi

View File

@@ -0,0 +1,58 @@
#!/bin/bash
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/raspiblitz.info
# SETUPFILE
# this key/value file contains the state during the setup process
SETUPFILE="/var/cache/raspiblitz/raspiblitz.setup"
source <($SETUPFILE)
# choose blockchain or select migration
OPTIONS=()
OPTIONS+=(BITCOIN1 "Setup BITCOIN & Lightning Network Daemon (LND)")
OPTIONS+=(BITCOIN2 "Setup BITCOIN & c-lightning by blockstream")
OPTIONS+=(LITECOIN "Setup LITECOIN & Lightning Network Daemon (LND)")
OPTIONS+=(MIGRATION "Upload a Migration File from old RaspiBlitz")
CHOICE=$(dialog --clear \
--backtitle "RaspiBlitz ${codeVersion} - Setup" \
--title "⚡ Welcome to your RaspiBlitz ⚡" \
--menu "\nChoose how you want to setup your RaspiBlitz: \n " \
13 64 7 \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
network=""
lightning=""
migrationOS=""
case $CHOICE in
BITCOIN1)
network="bitcoin"
lightning="lnd"
;;
BITCOIN2)
network="bitcoin"
lightning="cln"
;;
LITECOIN)
network="litecoin"
lightning="lnd"
;;
MIGRATION)
migrationOS="raspiblitz"
;;
esac
# on cancel - exit with 1
if [ "${network}" == "" ] && [ "${migrationOS}" == "" ]; then
exit 1
fi
# write results to setup sate
echo "migrationOS=${migrationOS}" >> $SETUPFILE
echo "migrationVersion=''" >> $SETUPFILE
echo "lightning=${lightning}" >> $SETUPFILE
echo "network=${network}" >> $SETUPFILE
exit 0

View File

@@ -0,0 +1,164 @@
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/raspiblitz.info
# SETUPFILE
# this key/value file contains the state during the setup process
SETUPFILE="/var/cache/raspiblitz/raspiblitz.setup"
source <($SETUPFILE)
# flags for sub dialogs after choice
uploadLNDRESCUE=0
enterSEED=0
uploadSCB=0
OPTIONS=()
OPTIONS+=(NEW "Setup a brand new Lightning Node (DEFAULT)")
OPTIONS+=(OLD "I had an old Node I want to recover/restore")
CHOICE=$(dialog --backtitle "RaspiBlitz" --clear --title "LND Setup" --menu "LND Data & Wallet" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
if [ "${CHOICE}" == "NEW" ]; then
# clear setup state from all fomer possible choices (previous loop)
sudo sed -i '/^setPasswordA=/d' $SETUPFILE
sudo sed -i '/^setPasswordB=/d' $SETUPFILE
sudo sed -i '/^setPasswordC=/d' $SETUPFILE
# mark all passwords to be set at the end
echo "setPasswordA=1" >> $SETUPFILE
echo "setPasswordB=1" >> $SETUPFILE
echo "setPasswordC=1" >> $SETUPFILE
elif [ "${CHOICE}" == "OLD" ]; then
CHOICE=""
while [ "${CHOICESUB}" == "" ]
do
# get more details what kind of old lightning wallet user has
OPTIONS=()
OPTIONS+=(LNDRESCUE "LND tar.gz-Backupfile (BEST)")
OPTIONS+=(SEED+SCB "Seed & channel.backup file (OK)")
OPTIONS+=(ONLYSEED "Only Seed Word List (FALLBACK)")
CHOICESUB=$(dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 "${OPTIONS[@]}" 2>&1 >/dev/tty)
if [ "${CHOICESUB}" == "LNDRESCUE" ]; then
# just activate LND rescue upload
uploadLNDRESCUE=1
# clear setup state from all fomer possible choices (previous loop)
sudo sed -i '/^setPasswordA=/d' $SETUPFILE
sudo sed -i '/^setPasswordB=/d' $SETUPFILE
sudo sed -i '/^setPasswordC=/d' $SETUPFILE
# dont set password c anymore - mark the rest
echo "setPasswordA=1" >> $SETUPFILE
echo "setPasswordB=1" >> $SETUPFILE
elif [ "${CHOICESUB}" == "SEED+SCB" ]; then
# activate SEED input & SCB upload
enterSEED=1
uploadSCB=1
elif [ "${CHOICESUB}" == "ONLYSEED" ]; then
# let people know about the difference between SEED & SEED+SCB
whiptail --title "IMPORTANT INFO" --yes-button "JUST SEED" --no-button "Go Back" --yesno "
Using JUST SEED WORDS will only recover your on-chain funds.
To also try to recover the open channel funds you need the
channel.backup file (since RaspiBlitz v1.2 / LND 0.6-beta)
or having a complete LND rescue-backup from your old node.
" 11 65
if [ $? -eq 1 ]; then
# when user wants to go back
CHOICESUB=""
else
# activate SEED input & SCB upload
enterSEED=1
fi
else
echo "# you selected cancel - exited to terminal"
echo "# use command 'restart' to reboot & start again"
exit 1
fi
done
else
echo "# you selected cancel - exited to terminal"
echo "# use command 'restart' to reboot & start again"
exit 1
fi
# UPLOAD LND RESCUE FILE dialog (if activated by dialogs above)
if [ ${uploadLNDRESCUE} -eq 1 ]; then
# run upload dialog and get result
_temp="/var/cache/raspiblitz/.temp.tmp"
/home/admin/config.scripts/lnd.backup.sh lnd-import-gui setup $_temp
source <($_temp) 2>/dev/null
sudo rm $_temp
# if user canceled upload
if [ "${lndrescue}" == "" ]; then
# signal cancel to the calling script by exit code
exit 1
fi
# clear setup state from all fomer possible choices (previous loop)
sudo sed -i '/^lndrescue=/d' $SETUPFILE
# store result in setup state
echo "lndrescue='${lndrescue}'" >> $SETUPFILE
fi
# INPUT LIGHTNING SEED dialog (if activated by dialogs above)
if [ ${enterSEED} -eq 1 ]; then
# start seed input and get results
_temp="/var/cache/raspiblitz/.temp.tmp"
/home/admin/config.scripts/lnd.backup.sh seed-import-gui $_temp
source <($_temp) 2>/dev/null
sudo rm $_temp
# if user canceled the seed input
if [ "${seedWords}" == "" ]; then
# signal cancel to the calling script by exit code
exit 1
fi
# clear setup state from all fomer possible choices (previous loop)
sudo sed -i '/^seedWords=/d' $SETUPFILE
sudo sed -i '/^seedPassword=/d' $SETUPFILE
# write the seed data into the setup state
echo "seedWords='${seedWords}'" >> $SETUPFILE
echo "seedPassword='${seedPassword}'" >> $SETUPFILE
fi
# UPLOAD STATIC CHANNEL BACKUP FILE dialog (if activated by dialogs above)
if [ ${uploadSCB} -eq 1 ]; then
# start seed input and get results
_temp="/var/cache/raspiblitz/.temp.tmp"
/home/admin/config.scripts/lnd.backup.sh scb-import-gui setup $_temp
source <($_temp) 2>/dev/null
sudo rm $_temp
# if user canceled the upload
if [ "${staticchannelbackup}" == "" ]; then
# signal cancel to the calling script by exit code
exit 1
fi
# clear setup state from all fomer possible choices (previous loop)
sudo sed -i '/^staticchannelbackup=/d' $SETUPFILE
# write the filename into the setup state
echo "staticchannelbackup='${staticchannelbackup}'" >> $SETUPFILE
fi

View File

@@ -1,41 +1,36 @@
#!/bin/bash
# TODO: use blitz.upload.sh for uploading the migration file
# TODO: also the migration might need to be adapted to work with an already mounted HDD later
# TODO: also the raspiblitz-migration & other-node-migration might need to be adapted to work with an already mounted HDD later
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "# dialog to get all data needed for migration-setup"
echo "# 00migrationDialog.sh [raspiblitz|mynode|umbrel]"
exit 1
fi
## get basic info
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/raspiblitz.info
# tempfile for result of dialogs
_temp=$(mktemp -p /dev/shm/)
# SETUPFILE
# this key/value file contains the state during the setup process
SETUPFILE="/var/cache/raspiblitz/raspiblitz.setup"
source <($SETUPFILE)
# prepare the setup file (that constains info just needed for the rest of setup process)
SETUPFILE="/home/admin/raspiblitz.setup"
rm $SETUPFILE 2>/dev/null
echo "# RASPIBLITZ SETUP FILE" > $SETUPFILE
#########################
# Parameters
# this is useful for testing the dialog outside of the setup process
# normally migrationOS & migrationVersion are provided by raspiblitz.info or raspiblitz.setup
# flags of what passwords are to set by user
setPasswordA=1
setPasswordB=0
setPasswordC=0
# 1st PARAMATER: [raspiblitz|mynode|umbrel]
migrationOS="$1"
if [ "${migrationOS}" != "raspiblitz" ] && [ "${migrationOS}" != "mynode" ] && [ "${migrationOS}" != "umbrel" ]; then
echo "parameter1(${migrationOS})"
echo "error='not supported'"
exit 1
fi
# 1st PARAMATER (optional): [raspiblitz|mynode|umbrel]
if [ "${migrationOS}" == "" ]; then
migrationOS="$1"
fi
# 2nd PARAMATER (optional): the version of the former fullnode OS if available
migrationVersion="$2"
if [ "${migrationVersion}" == "" ]; then
migrationVersion="$2"
fi
# check parameter values
if [ "${migrationOS}" != "raspiblitz" ] && [ "${migrationOS}" != "mynode" ] && [ "${migrationOS}" != "umbrel" ]; then
echo "# FAIL: the given migrationOS '${migrationOS}' is not supported yet"
exit 1
fi
####################################################
# RASPIBLITZ
@@ -44,10 +39,6 @@ migrationVersion="$2"
if [ "${migrationOS}" == "raspiblitz" ]; then
# write migration info
echo "migrationOS='${migrationOS}'" >> $SETUPFILE
echo "migrationVersion='${migrationVersion}'" >> $SETUPFILE
# get defaultUploadPath, localIP, etc
source <(sudo /home/admin/config.scripts/blitz.upload.sh prepare-upload)
@@ -95,18 +86,19 @@ if [ "${migrationOS}" == "raspiblitz" ]; then
echo "PRESS ENTER to continue & retry"
read key
else
echo "!! WARNING !! Unknown State (report to devs)"
echo "!! WARNING !! Unknown State (report to devs) error(${error})"
exit 1
fi
done
# further checks and unpacking will be done when migration is processed (not part of dialog)
echo "OK: Migration data was imported - will process after password reset"
echo "migrationFile='${filename}'" >> $SETUPFILE
echo "OK: Migration file was imported - will process after password reset"
sleep 4
# migration OS & Version were already set earlier in setup process - now add migration filename
echo "migrationFile='${filename}'" >> $SETUPFILE
# user needs to reset password A
setPasswordA=1
echo "setPasswordA=1" >> $SETUPFILE
exit 0
fi
@@ -127,20 +119,20 @@ Please make sure to have your UMBREL seed words & static channel backup file (ju
Do you want to start migration to RaspiBlitz now?
" 16 58
if [ $? -eq 0 ]; then
# write migration info
echo "migrationOS='umbrel'" >> $SETUPFILE
echo "migrationVersion='${migrationVersion}'" >> $SETUPFILE
else
# user cancel - request shutdown
echo "shutdown=1" >> $SETUPFILE
if [ "$?" != "0" ]; then
# user cancel - signal by exit code
exit 1
fi
# user needs to reset password A
setPasswordA=1
setPasswordB=1
setPasswordC=1
# write migration info
echo "migrationOS='umbrel'" >> $SETUPFILE
echo "migrationVersion='${migrationVersion}'" >> $SETUPFILE
# user needs to reset password A, B & C
echo "setPasswordA=1" >> $SETUPFILE
echo "setPasswordB=1" >> $SETUPFILE
echo "setPasswordC=1" >> $SETUPFILE
exit 0
fi
@@ -161,76 +153,21 @@ Please make sure to have your MYNODE seed words & static channel backup file (ju
Do you want to start migration to RaspiBlitz now?
" 16 58
if [ $? -eq 0 ]; then
# write migration info
echo "migrationOS='mynode'" >> $SETUPFILE
echo "migrationVersion='${migrationVersion}'" >> $SETUPFILE
else
# user cancel - request shutdown
echo "shutdown=1" >> $SETUPFILE
if [ "$?" != "0" ]; then
# user cancel - signal by exit code
exit 1
fi
# write migration info
echo "migrationOS='mynode'" >> $SETUPFILE
echo "migrationVersion='${migrationVersion}'" >> $SETUPFILE
# user needs to reset password A
setPasswordA=1
setPasswordB=1
setPasswordC=1
echo "setPasswordA=1" >> $SETUPFILE
echo "setPasswordB=1" >> $SETUPFILE
echo "setPasswordC=1" >> $SETUPFILE
exit 0
fi
####################################################
# INPUT PASSWORDS (based on flags above set)
# dynamic info string on what passwords need to be changed
passwordinfo="A" # always so far
if [ ${setPasswordB} -eq 1 ]; then
passwordinfo = "${passwordinfo}, B"
fi
if [ ${setPasswordC} -eq 1 ]; then
passwordinfo = "${passwordinfo}, C"
fi
# basic information in RaspiBlitz passwords
dialog --backtitle "RaspiBlitz - Migration Setup" --msgbox "You will need to set new passwords.
RaspiBlitz works with 3 different passwords:
PASSWORD A) Main User Password (SSH & WebUI, sudo)
PASSWORD B) APP Password (RPC & Additional Apps)
PASSWORD C) Lightning Wallet Password for Unlock
You will need to set Password: ${passwordinfo}
(other passwords might stay like on your old node)
Follow Password Rules: Minimal of 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 17 64
if [ ${setPasswordA} -eq 1 ]; then
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD A - Main User Password" $_temp
password=$(sudo cat $_temp)
echo "passwordA='${password}'" >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password A set" 7 20
fi
if [ ${setPasswordB} -eq 1 ]; then
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD B - APP Password" $_temp
password=$(sudo cat $_temp)
echo "passwordB='${password}'" >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password B set" 7 20
fi
if [ ${setPasswordC} -eq 1 ]; then
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD C - Lightning Wallet Password" $_temp
password=$(sudo cat $_temp)
echo "passwordC='${password}'" >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password C set" 7 20
fi
clear
echo "# data from dialogs stored in to be further processed:"
echo "${SETUPFILE}"
exit 0
echo "FAIL: Exited in unknown state from migration dialog."
exit 1

View File

@@ -0,0 +1,31 @@
#!/bin/bash
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/raspiblitz.info
# SETUPFILE
# this key/value file contains the state during the setup process
SETUPFILE="/var/cache/raspiblitz/raspiblitz.setup"
source <($SETUPFILE)
###################
# ENTER NAME
###################
# temp file for password results
_temp="/var/cache/raspiblitz/.temp.tmp"
# ask for name of RaspiBlitz
result=""
while [ ${#result} -eq 0 ]
do
l1="Please enter the name of your new RaspiBlitz:\n"
l2="one word, keep characters basic & not too long"
dialog --backtitle "RaspiBlitz - Setup (${network}/${chain})" --inputbox "$l1$l2" 11 52 2>$_temp
result=$( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' )
sudo rm $_temp
done
# store name in setup state
echo "hostname=${result}" >> $SETUPFILE

View File

@@ -0,0 +1,99 @@
#!/bin/bash
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/raspiblitz.info
# SETUPFILE
# this key/value file contains the state during the setup process
SETUPFILE="/var/cache/raspiblitz/raspiblitz.setup"
source <($SETUPFILE)
####################################################
# INPUT PASSWORDS (based on flags from raspiblitz.setup)
# dynamic info string on what passwords need to be changed
passwordinfo="A" # always so far
if [ "${setPasswordB}" == "1" ]; then
passwordinfo = "${passwordinfo}, B"
fi
if [ "${setPasswordC}" == "1" ]; then
passwordinfo = "${passwordinfo}, C"
fi
# if passwords are set in a migration situation, use different info text
if [ "${migrationOS}" == "" ]; then
# info text on normal setup
dialog --backtitle "RaspiBlitz - Setup" --msgbox "RaspiBlitz uses 3 different passwords.
Referenced as password A, B & C.
PASSWORD A) Main User Password (SSH & WebUI, sudo)
PASSWORD B) APP Password (Additional Apps & API)
PASSWORD C) Lightning Wallet Password for Unlock
You will need to set now Password: ${passwordinfo}
Follow Password Rule: Minimal of 8 chars,,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 16 54
else
# info text on migration setup
dialog --backtitle "RaspiBlitz - Migration Setup" --msgbox "You will need to set new passwords.
RaspiBlitz works with 3 different passwords:
PASSWORD A) Main User Password (SSH & WebUI, sudo)
PASSWORD B) APP Password (Additional Apps & API)
PASSWORD C) Lightning Wallet Password for Unlock
You will need to set now Password: ${passwordinfo}
(other passwords might stay like on your old node)
Follow Password Rules: Minimal of 8 chars,
no spaces and only special characters - or .
Write them down & store them in a safe place.
" 17 64
fi
# temp file for password results
_temp="/var/cache/raspiblitz/.temp.tmp"
# PASSWORD A
if [ "${setPasswordA}" == "1" ]; then
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD A - Main User Password" $_temp
password=$(sudo cat $_temp)
sudo rm $_temp
echo "passwordA='${password}'" >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password A set" 7 20
fi
# PASSWORD B
if [ "${setPasswordB}" == "1" ]; then
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD B - APP Password" $_temp
password=$(sudo cat $_temp)
sudo rm $_temp
echo "passwordB='${password}'" >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password B set" 7 20
fi
# PASSWORD C
if [ "${setPasswordC}" == "1" ]; then
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD C - Lightning Wallet Password" $_temp
password=$(sudo cat $_temp)
sudo rm $_temp
echo "passwordC='${password}'" >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password C set" 7 20
fi
# debug info
clear
echo "# data from dialogs stored in to be further processed:"
echo "${SETUPFILE}"
exit 0

View File

@@ -0,0 +1,113 @@
#!/bin/bash
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/raspiblitz.info
# SETUPFILE
# this key/value file contains the state during the setup process
SETUPFILE="/var/cache/raspiblitz/raspiblitz.setup"
# init SETUPFILE
rm $SETUPFILE 2>/dev/null
echo "# RASPIBLITZ SETUP STATE" > $SETUPFILE
############################################
# Basic Setup (Blockchain & Lightning Impl)
# (skip if migration was auto-detected)
if [ "${migrationOS}" == "" ]; then
/home/admin/setup/dialogBasicSetup.sh
# on cancel - let user exit to terminal
if [ "$?" != "0" ]; then
echo "# you selected cancel - exited to terminal"
echo "# to re-start setup use command --> setup"
exit 1
fi
fi
if [ "${migrationOS}" != "" ]; then
###############################################
# MIGRATION
# other fullnodesOS or RaspiBlitz migration file
echo "# Starting migration dialog ..."
/home/admin/setup/dialogMigration.sh
# on cancel - let user exit to terminal
if [ "$?" != "0" ]; then
echo "# you selected cancel - exited to terminal"
echo "# to re-start setup use command --> setup"
exit 1
fi
else
###############################################
# FRESH SETUP
echo "# Starting all dialogs for fresh setup ..."
############################################
# Setting Name for Node
/home/admin/setup/dialogPasswords.sh
############################################
# Lightning Wallet (new or restore) do this before passwords
# because password C not needed if LND rescue file is uploaded
while loop
fi
############################################
# Enter Passwords
# for fresh setup & migration
/home/admin/setup/dialogPasswords.sh
############################################
# PROCESS SETUP CHOICES
# TODO: move this part later outside of dialog controller and combine with data from WebUI
if [ "${migrationOS}" == "" ]; then
############################################
# Normal Setup
echo "# CREATING raspiblitz.conf from your setup choices"
# prepare the config file (what will later become the raspiblitz.config)
source /home/admin/_version.info
CONFIGFILE="/mnt/hdd/raspiblitz.config"
rm $CONFIGFILE 2>/dev/null
echo "# RASPIBLITZ CONFIG FILE" > $CONFIGFILE
echo "raspiBlitzVersion='${codeVersion}'" >> $CONFIGFILE
echo "lcdrotate=1" >> $CONFIGFILE
echo "lightning=${lightning}" >> $CONFIGFILE
echo "network=${network}" >> $CONFIGFILE
echo "chain=main" >> $CONFIGFILE
echo "runBehindTor=on" >> $CONFIGFILE
else
############################################
# Process Migration
# TODO: move this part later outside of dialog controller and combine with data from WebUI
echo "TODO: Process Migration"
exit 1
fi
clear
echo "# setup dialog done - results in:"
echo "# $SETUPFILE"
echo "# $CONFIGFILE"