better debug output

This commit is contained in:
rootzoll 2019-12-13 20:10:29 +01:00
parent d6a1790ef1
commit e916cae043
2 changed files with 91 additions and 67 deletions

View file

@ -4,38 +4,43 @@
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
echo "" echo ""
echo "*** 30initHDD.sh ***" echo "# *** 30initHDD.sh ***"
echo
echo "# --> Checking HDD/SSD status..."
# use blitz.datadrive.sh to analyse HDD situation # use blitz.datadrive.sh to analyse HDD situation
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network}) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
echo "FAIL blitz.datadrive.sh status --> ${error}" echo "# FAIL blitz.datadrive.sh status --> ${error}"
echo "Please report issue to the raspiblitz github." echo "# Please report issue to the raspiblitz github."
exit 1 exit 1
fi fi
# check if HDD is mounted (secure against formatting a mounted disk with data) # check if HDD is mounted (secure against formatting a mounted disk with data)
echo "isMounted=${isMounted}" echo "isMounted=${isMounted}"
if [ ${isMounted} -eq 1 ]; then if [ ${isMounted} -eq 1 ]; then
echo "FAIL HDD/SSD is mounted - please unmount and call ./30initHDD.sh again" echo "# FAIL HDD/SSD is mounted - please unmount and call ./30initHDD.sh again"
exit 1 exit 1
fi fi
# check if HDD contains old RaspiBlitz data (secure against wrongly formatting) # check if HDD contains old RaspiBlitz data (secure against wrongly formatting)
echo "hddRaspiData=${hddRaspiData}" echo "hddRaspiData=${hddRaspiData}"
if [ ${hddRaspiData} -eq 1 ]; then if [ ${hddRaspiData} -eq 1 ]; then
echo "FAIL HDD/SSD contains old data - please delete manual and call ./30initHDD.sh again" echo "# FAIL HDD/SSD contains old data - please delete manual and call ./30initHDD.sh again"
exit 1 exit 1
fi fi
# check if there is a HDD connectecd to use as data drive # check if there is a HDD connectecd to use as data drive
echo "hddCandidate=${hddCandidate}" echo "hddCandidate=${hddCandidate}"
if [ ${#hddCandidate} -eq 0 ]; then if [ ${#hddCandidate} -eq 0 ]; then
echo "FAIL please cnnect a HDD and call ./30initHDD.sh again" echo "# FAIL please cnnect a HDD and call ./30initHDD.sh again"
exit 1 exit 1
fi fi
echo "OK"
# check minimal size of data drive needed # check minimal size of data drive needed
echo
echo "# --> Check HDD/SSD for Size ..."
# bitcoin: 450 GB # bitcoin: 450 GB
# litecoin: 120 GB # litecoin: 120 GB
minSize=450 minSize=450
@ -43,50 +48,54 @@ if [ "${network}" = "litecoin" ]; then
minSize=120 minSize=120
fi fi
if [ ${hddGigaBytes} -lt ${minSize} ]; then if [ ${hddGigaBytes} -lt ${minSize} ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "WARNING: HDD is too small" echo "# WARNING: HDD is too small"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "" echo ""
echo "HDD was detected with the size of ${hddGigaBytes} GB" echo "# HDD was detected with the size of ${hddGigaBytes} GB"
echo "For ${network} at least ${minSize} GB is needed" echo "# For ${network} at least ${minSize} GB is needed"
echo "" echo ""
echo "If you want to change to a bigger HDD:" echo "# If you want to change to a bigger HDD:"
echo "* Unplug power of RaspiBlitz" echo "# * Unplug power of RaspiBlitz"
echo "* Make a fresh SD card again" echo "# * Make a fresh SD card again"
echo "* Start again with bigger HDD" echo "# * Start again with bigger HDD"
exit exit 1
fi fi
echo " OK"
# format drive if it does not have any blockchain or blitz data on it # format drive if it does not have any blockchain or blitz data on it
# to be sure that HDD has no faulty partions, etc. # to be sure that HDD has no faulty partions, etc.
echo "hddGotBlockchain=${hddGotBlockchain}" echo "# --> Check HDD/SSD for Blockchain ..."
echo "# hddGotBlockchain=${hddGotBlockchain}"
if [ ${hddGotBlockchain} -eq 0 ]; then if [ ${hddGotBlockchain} -eq 0 ]; then
# test feature: if there is a USB stick as a raid connected, then format in BTRFS an not in EXT4 # test feature: if there is a USB stick as a raid connected, then format in BTRFS an not in EXT4
format="ext4" format="ext4"
if [ ${raidCandidates} -eq 1 ]; then if [ ${raidCandidates} -eq 1 ]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "EXPERIMENTAL FEATURE: BTRFS + RAID" echo "# EXPERIMENTAL FEATURE: BTRFS + RAID"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "You connected an extra USB thumb drive to your RaspiBlitz." echo "# You connected an extra USB thumb drive to your RaspiBlitz."
echo "This activates the exterimental feature of running BTRFS" echo "# This activates the exterimental feature of running BTRFS"
echo "instead of EXT4 and is still unstable but needs testing." echo "# instead of EXT4 and is still unstable but needs testing."
echo "PRESS ENTER to continue with BTRFS+RAID setup or press" echo "# PRESS ENTER to continue with BTRFS+RAID setup or press"
echo "CTRL+C, remove device & call ./30initHDD.sh again." echo "# CTRL+C, remove device & call ./30initHDD.sh again."
read key read key
format="btrfs" format="btrfs"
fi fi
# now partition/format HDD # now partition/format HDD
echo "formatting HDD/SSD ..." echo
echo "# --> Formatting HDD/SSD ..."
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh format ${format} ${hddCandidate}) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh format ${format} ${hddCandidate})
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
echo "FAIL blitz.datadrive.sh format --> ${error}" echo "# FAIL blitz.datadrive.sh format --> ${error}"
echo "Please report issue to the raspiblitz github." echo "# Please report issue to the raspiblitz github."
exit 1 exit 1
fi fi
fi fi
echo "# OK"
# set SetupState # set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=30/g" /home/admin/raspiblitz.info sudo sed -i "s/^setupStep=.*/setupStep=30/g" /home/admin/raspiblitz.info

View file

@ -4,7 +4,7 @@
source /home/admin/raspiblitz.info source /home/admin/raspiblitz.info
echo "" echo ""
echo "*** 40addHDD.sh ***" echo "# *** 40addHDD.sh ***"
# use blitz.datadrive.sh to analyse HDD situation # use blitz.datadrive.sh to analyse HDD situation
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network}) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
@ -23,7 +23,9 @@ if [ ${#error} -gt 0 ]; then
fi fi
# linking drives/directories # linking drives/directories
echo "linking drives/directories" echo
echo "# --> Linking drives/directories"
echo "# hddCandidate='${hddCandidate}'"
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh link ${hddCandidate}) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh link ${hddCandidate})
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
echo "FAIL blitz.datadrive.sh link --> ${error}" echo "FAIL blitz.datadrive.sh link --> ${error}"
@ -32,7 +34,9 @@ if [ ${#error} -gt 0 ]; then
fi fi
# adding drives to fstab for permanent mount # adding drives to fstab for permanent mount
echo "adding the data drive to OS" echo
echo "# --> Adding the data drive to OS ..."
echo "# hddCandidate='${hddCandidate}'"
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${hddCandidate}) source <(sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${hddCandidate})
if [ ${#error} -gt 0 ]; then if [ ${#error} -gt 0 ]; then
echo "FAIL blitz.datadrive.sh fstab --> ${error}" echo "FAIL blitz.datadrive.sh fstab --> ${error}"
@ -41,49 +45,59 @@ if [ ${#error} -gt 0 ]; then
fi fi
# init the RASPIBLITZ Config # init the RASPIBLITZ Config
echo
echo "# --> Init raspiblitz.conf ..."
configFile="/mnt/hdd/raspiblitz.conf" configFile="/mnt/hdd/raspiblitz.conf"
configExists=$(sudo ls ${configFile} 2>/dev/null | grep -c 'raspiblitz.conf') configExists=$(sudo ls ${configFile} 2>/dev/null | grep -c 'raspiblitz.conf')
if [ ${configExists} -eq 0 ]; then if [ ${configExists} -eq 1 ]; then
# create file and use init values from raspiblitz.info # config exists - nothing much to do
source /home/admin/_version.info echo "# config file already exists on HDD/SSD"
sudo touch $configFile sudo chmod 777 ${configFile}
sudo chmod 777 ${configFile}
echo "# RASPIBLITZ CONFIG FILE" > $configFile
echo "raspiBlitzVersion='${codeVersion}'" >> $configFile
echo "network=${network}" >> $configFile
echo "chain=${chain}" >> $configFile
echo "hostname=${hostname}" >> $configFile
# try to determine publicIP and if not possible use localIP as placeholder
# https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
# sanity check on IP data
# see https://github.com/rootzoll/raspiblitz/issues/371#issuecomment-472416349
echo "-> sanity check of IP data:"
if [[ $freshPublicIP =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then
echo "OK IPv6"
elif [[ $freshPublicIP =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
echo "OK IPv4"
else else
echo "FAIL - not an IPv4 or IPv6 address"
# create file and use init values from raspiblitz.info
echo "# CREATING new ${configFile}"
source /home/admin/_version.info
sudo touch $configFile
sudo chmod 777 ${configFile}
echo "# RASPIBLITZ CONFIG FILE" > $configFile
echo "raspiBlitzVersion='${codeVersion}'" >> $configFile
echo "network=${network}" >> $configFile
echo "chain=${chain}" >> $configFile
echo "hostname=${hostname}" >> $configFile
# try to determine publicIP and if not possible use localIP as placeholder
# https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101
freshPublicIP=$(curl -s http://v4.ipv6-test.com/api/myip.php)
# sanity check on IP data
# see https://github.com/rootzoll/raspiblitz/issues/371#issuecomment-472416349
echo "# sanity check of IP data:"
if [[ $freshPublicIP =~ ^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$ ]]; then
echo "# OK IPv6"
elif [[ $freshPublicIP =~ ^([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$ ]]; then
echo "# OK IPv4"
else
echo "# FAIL - not an IPv4 or IPv6 address"
freshPublicIP="" freshPublicIP=""
fi fi
if [ ${#freshPublicIP} -eq 0 ]; then if [ ${#freshPublicIP} -eq 0 ]; then
localIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') localIP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
echo "WARNING: No publicIP information at all yet - working with placeholder : ${localIP}" echo "# WARNING: No publicIP information at all yet - working with placeholder : ${localIP}"
freshPublicIP="${localIP}" freshPublicIP="${localIP}"
fi
echo "publicIP='${freshPublicIP}'" >> $configFile
fi fi
echo "publicIP='${freshPublicIP}'" >> $configFile
# link ssh directory from SD catd to HDD # link ssh directory from SD catd to HDD
echo "-> ssh key settings" echo "# --> SSH key settings"
echo "moving SSH pub keys to HDD" echo "# moving SSH pub keys to HDD"
sudo cp -r /etc/ssh /mnt/hdd/ssh sudo cp -r /etc/ssh /mnt/hdd/ssh
sudo rm -rf /etc/ssh sudo rm -rf /etc/ssh
sudo ln -s /mnt/hdd/ssh /etc/ssh sudo ln -s /mnt/hdd/ssh /etc/ssh
echo "OK" echo "# OK"
echo "" echo ""
# set SetupState # set SetupState
@ -93,7 +107,7 @@ sudo sed -i "s/^setupStep=.*/setupStep=40/g" /home/admin/raspiblitz.info
echo "hddGotBlockchain=${hddGotBlockchain}" echo "hddGotBlockchain=${hddGotBlockchain}"
if [ ${hddGotBlockchain} -eq 1 ]; then if [ ${hddGotBlockchain} -eq 1 ]; then
echo "Looks like the HDD is prepared with the Blockchain." echo "# Looks like the HDD is prepared with the Blockchain."
# ask user if prepared blockchain is to use or self-validate # ask user if prepared blockchain is to use or self-validate
whiptail --title ' Use Blockchain from HDD/SSD? ' --yes-button='Continue' --no-button='DELETE' --yesno " whiptail --title ' Use Blockchain from HDD/SSD? ' --yes-button='Continue' --no-button='DELETE' --yesno "
@ -103,21 +117,22 @@ If you dont trust that data you can now choose to delete it - but keep in mind t
" 14 75 " 14 75
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
# DELETE # DELETE
echo "Deleting old blockchain data .." echo "# Deleting old blockchain data .."
sudo rm -R /mnt/hdd/bitcoin 2>/dev/null sudo rm -R /mnt/hdd/bitcoin 2>/dev/null
sudo rm -R /mnt/hdd/litecoin 2>/dev/null sudo rm -R /mnt/hdd/litecoin 2>/dev/null
# HDD is now empty - let setupBlitz - display next options # HDD is now empty - let setupBlitz - display next options
echo "# HDD now empty --> follow further setup"
./10setupBlitz.sh ./10setupBlitz.sh
else else
# CONTINUE # CONTINUE
echo "Continuing with finishing the system setup ..." echo "# Continuing with finishing the system setup ..."
./60finishHDD.sh ./60finishHDD.sh
fi fi
else else
# HDD is empty - let setupBlitz - display next options # HDD is empty - let setupBlitz - display next options
echo "HDD empty --> go setup" echo "# HDD empty --> follow further setup"
./10setupBlitz.sh ./10setupBlitz.sh
fi fi