raspiblitz/home.admin/30initHDD.sh

107 lines
3.2 KiB
Bash
Raw Normal View History

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
source /home/admin/raspiblitz.info
2019-02-13 02:33:27 +01:00
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
# 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."
exit 1
fi
# 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"
exit 1
fi
# 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"
exit 1
fi
# 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"
exit 1
fi
2019-12-13 20:10:29 +01:00
echo "OK"
# check minimal size of data drive needed
2019-12-13 20:10:29 +01:00
echo
echo "# --> Check HDD/SSD for Size ..."
# 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
fi
2019-12-13 20:10:29 +01:00
echo " OK"
2019-02-11 15:04:36 +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 20:10:29 +01:00
echo "# --> Check HDD/SSD for Blockchain ..."
echo "# hddGotBlockchain=${hddGotBlockchain}"
if [ ${hddGotBlockchain} -eq 0 ]; then
2018-07-17 13:12:03 +02: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-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."
read key
format="btrfs"
fi
2018-07-17 13:12:03 +02:00
# now partition/format HDD
2019-12-13 20:10:29 +01:00
echo
echo "# --> Formatting HDD/SSD ..."
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh format ${format} ${hddCandidate})
if [ ${#error} -gt 0 ]; then
2019-12-13 20:10:29 +01:00
echo "# FAIL blitz.datadrive.sh format --> ${error}"
echo "# Please report issue to the raspiblitz github."
exit 1
2018-07-17 13:12:03 +02:00
fi
2018-07-17 13:12:03 +02:00
fi
2019-12-13 20:10:29 +01:00
echo "# OK"
# set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=30/g" /home/admin/raspiblitz.info
# automatically now add the HDD to the system
./40addHDD.sh