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

View file

@ -4,7 +4,7 @@
source /home/admin/raspiblitz.info
echo ""
echo "*** 40addHDD.sh ***"
echo "# *** 40addHDD.sh ***"
# use blitz.datadrive.sh to analyse HDD situation
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status ${network})
@ -23,7 +23,9 @@ if [ ${#error} -gt 0 ]; then
fi
# 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})
if [ ${#error} -gt 0 ]; then
echo "FAIL blitz.datadrive.sh link --> ${error}"
@ -32,7 +34,9 @@ if [ ${#error} -gt 0 ]; then
fi
# 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})
if [ ${#error} -gt 0 ]; then
echo "FAIL blitz.datadrive.sh fstab --> ${error}"
@ -41,49 +45,59 @@ if [ ${#error} -gt 0 ]; then
fi
# init the RASPIBLITZ Config
echo
echo "# --> Init raspiblitz.conf ..."
configFile="/mnt/hdd/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
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
# config exists - nothing much to do
echo "# config file already exists on HDD/SSD"
sudo chmod 777 ${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"
# 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=""
fi
if [ ${#freshPublicIP} -eq 0 ]; then
fi
if [ ${#freshPublicIP} -eq 0 ]; then
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}"
fi
echo "publicIP='${freshPublicIP}'" >> $configFile
fi
echo "publicIP='${freshPublicIP}'" >> $configFile
# link ssh directory from SD catd to HDD
echo "-> ssh key settings"
echo "moving SSH pub keys to HDD"
echo "# --> SSH key settings"
echo "# moving SSH pub keys to HDD"
sudo cp -r /etc/ssh /mnt/hdd/ssh
sudo rm -rf /etc/ssh
sudo ln -s /mnt/hdd/ssh /etc/ssh
echo "OK"
echo "# OK"
echo ""
# set SetupState
@ -93,7 +107,7 @@ sudo sed -i "s/^setupStep=.*/setupStep=40/g" /home/admin/raspiblitz.info
echo "hddGotBlockchain=${hddGotBlockchain}"
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
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
if [ $? -eq 1 ]; then
# 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/litecoin 2>/dev/null
# HDD is now empty - let setupBlitz - display next options
echo "# HDD now empty --> follow further setup"
./10setupBlitz.sh
else
# CONTINUE
echo "Continuing with finishing the system setup ..."
echo "# Continuing with finishing the system setup ..."
./60finishHDD.sh
fi
else
# HDD is empty - let setupBlitz - display next options
echo "HDD empty --> go setup"
echo "# HDD empty --> follow further setup"
./10setupBlitz.sh
fi