2018-12-05 00:07:58 +01:00
#!/bin/bash
2019-02-11 15:04:36 +01:00
2019-02-13 02:33:27 +01:00
## get basic info
2019-12-13 19:21:59 +01:00
source /home/admin/raspiblitz.info
2019-02-13 02:33:27 +01:00
2019-12-13 23:12:34 +01:00
clear
2018-07-17 13:12:03 +02:00
echo ""
2019-12-13 20:10:29 +01:00
echo "# *** 30initHDD.sh ***"
echo
echo "# --> Checking HDD/SSD status..."
2019-02-11 15:04:36 +01:00
2019-12-13 19:21:59 +01:00
# use blitz.datadrive.sh to analyse HDD situation
source <( sudo /home/admin/config.scripts/blitz.datadrive.sh status ${ network } )
if [ ${# error } -gt 0 ] ; then
2019-12-13 20:10:29 +01:00
echo " # FAIL blitz.datadrive.sh status --> ${ error } "
echo "# Please report issue to the raspiblitz github."
2019-12-13 19:21:59 +01:00
exit 1
fi
2018-08-02 18:03:28 +02:00
2019-12-13 19:21:59 +01:00
# check if HDD is mounted (secure against formatting a mounted disk with data)
echo " isMounted= ${ isMounted } "
if [ ${ isMounted } -eq 1 ] ; then
2019-12-13 20:10:29 +01:00
echo "# FAIL HDD/SSD is mounted - please unmount and call ./30initHDD.sh again"
2019-12-13 19:21:59 +01:00
exit 1
fi
2018-08-02 18:03:28 +02:00
2019-12-13 19:21:59 +01:00
# check if HDD contains old RaspiBlitz data (secure against wrongly formatting)
echo " hddRaspiData= ${ hddRaspiData } "
if [ ${ hddRaspiData } -eq 1 ] ; then
2019-12-13 20:10:29 +01:00
echo "# FAIL HDD/SSD contains old data - please delete manual and call ./30initHDD.sh again"
2019-12-13 19:21:59 +01:00
exit 1
fi
2018-08-02 18:03:28 +02:00
2019-12-13 19:21:59 +01:00
# check if there is a HDD connectecd to use as data drive
echo " hddCandidate= ${ hddCandidate } "
if [ ${# hddCandidate } -eq 0 ] ; then
2019-12-13 20:10:29 +01:00
echo "# FAIL please cnnect a HDD and call ./30initHDD.sh again"
2019-12-13 19:21:59 +01:00
exit 1
fi
2019-12-13 20:10:29 +01:00
echo "OK"
2018-08-02 18:03:28 +02:00
2019-12-13 19:21:59 +01:00
# check minimal size of data drive needed
2019-12-13 20:10:29 +01:00
echo
echo "# --> Check HDD/SSD for Size ..."
2019-12-13 19:21:59 +01:00
# bitcoin: 450 GB
# litecoin: 120 GB
minSize = 450
if [ " ${ network } " = "litecoin" ] ; then
minSize = 120
fi
if [ ${ hddGigaBytes } -lt ${ minSize } ] ; then
2019-12-13 20:10:29 +01:00
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "# WARNING: HDD is too small"
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
2019-02-11 15:04:36 +01:00
echo ""
2019-12-13 20:10:29 +01:00
echo " # HDD was detected with the size of ${ hddGigaBytes } GB "
echo " # For ${ network } at least ${ minSize } GB is needed "
2019-02-11 15:04:36 +01:00
echo ""
2019-12-13 20:10:29 +01:00
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
2019-12-13 19:21:59 +01:00
fi
2019-12-13 20:10:29 +01:00
echo " OK"
2019-02-11 15:04:36 +01:00
2019-12-13 19:21:59 +01:00
# format drive if it does not have any blockchain or blitz data on it
# to be sure that HDD has no faulty partions, etc.
2019-12-13 23:26:32 +01:00
echo
2019-12-13 20:10:29 +01:00
echo "# --> Check HDD/SSD for Blockchain ..."
echo " # hddGotBlockchain= ${ hddGotBlockchain } "
2019-12-14 12:02:03 +01:00
raidSizeGB = $( echo " ${ raidCandidate [0] } " | cut -d " " -f 2)
echo " # raidCandidates= ${ raidCandidates } "
echo " # raidSizeGB= ${ raidSizeGB } "
2019-12-13 19:21:59 +01:00
if [ ${ hddGotBlockchain } -eq 0 ] ; then
2018-07-17 13:12:03 +02:00
2019-12-13 19:21:59 +01:00
# 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
2019-12-14 12:02:03 +01:00
2019-12-14 12:20:51 +01:00
echo
2019-12-13 20:10:29 +01:00
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."
2019-12-13 19:21:59 +01:00
read key
format = "btrfs"
2019-12-14 12:02:03 +01:00
# check that raid cadidate is big enough
# a 32GB drive gets shown with 28GB in mby tests
if [ ${ raidSizeGB } -lt 27 ] ; then
echo "# FAIL the raid device needs to be at least a 32GB thumb drive."
echo "# Please remove or replace and call ./30initHDD.sh again"
exit 1
fi
elif [ ${ raidCandidates } -gt 1 ] ; then
echo "# FAIL more then one USB raid drive candidate connected."
echo "# Please max one extra usb drive and the call ./30initHDD.sh again"
exit 1
2019-12-13 19:21:59 +01:00
fi
2018-07-17 13:12:03 +02:00
2020-01-15 18:22:31 +01:00
2019-12-13 19:21:59 +01:00
# now partition/format HDD
2019-12-13 20:10:29 +01:00
echo
2020-01-15 20:43:42 +01:00
if ( whiptail --title "FORMAT HDD/SSD" --yesno "The connected hard drive needs to get formatted.\nIMPORTANT: This will delete all data on that drive." 8 56) ; then
clear
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."
exit 1
fi
else
clear
echo "# Not formatting the HDD/SSD - Setup Process stopped."
2020-02-23 19:45:22 +01:00
echo "# Rearrange your hardware and restart with a fresh sd card again."
2019-12-13 19:21:59 +01:00
exit 1
2018-07-17 13:12:03 +02:00
fi
2019-12-13 19:21:59 +01:00
2018-07-17 13:12:03 +02:00
fi
2019-12-13 20:10:29 +01:00
echo "# OK"
2019-12-13 19:21:59 +01:00
# set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=30/g" /home/admin/raspiblitz.info
# automatically now add the HDD to the system
./40addHDD.sh