2018-12-05 00:07:58 +01:00
#!/bin/bash
2018-07-29 12:21:52 +02:00
2021-05-23 23:38:12 -05:00
# TODO: should be good to be deleted - it now done in _provision.setup.sh or _provision_.sh
# ---> the experimental "adding RAID drive" section for BRTFS gets dropped here
2018-12-06 14:36:02 +01:00
## get basic info
2019-02-03 23:22:58 +01:00
source /home/admin/raspiblitz.info
2018-07-29 12:21:52 +02:00
2019-12-13 19:21:59 +01:00
echo ""
2019-12-13 20:10:29 +01:00
echo "# *** 40addHDD.sh ***"
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
echo " FAIL blitz.datadrive.sh status --> ${ error } "
echo "Please report issue to the raspiblitz github."
exit 1
fi
# temp mount
2020-10-18 18:22:32 +02:00
if [ " $hddFormat " = = "btrfs" ] ; then
source <( sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${ hddCandidate } )
else
source <( sudo /home/admin/config.scripts/blitz.datadrive.sh tempmount ${ hddPartitionCandidate } )
fi
2019-12-13 19:21:59 +01:00
if [ ${# error } -gt 0 ] ; then
echo " FAIL blitz.datadrive.sh tempmount --> ${ error } "
echo "Please report issue to the raspiblitz github."
exit 1
fi
# linking drives/directories
2019-12-13 20:10:29 +01:00
echo
echo "# --> Linking drives/directories"
echo " # hddCandidate=' ${ hddCandidate } ' "
2020-09-21 21:59:37 +02:00
echo " # hddPartitionCandidate=' ${ hddPartitionCandidate } ' "
2020-09-22 18:19:58 +02:00
source <( sudo /home/admin/config.scripts/blitz.datadrive.sh link)
2019-12-13 19:21:59 +01:00
if [ ${# error } -gt 0 ] ; then
echo " FAIL blitz.datadrive.sh link --> ${ error } "
echo "Please report issue to the raspiblitz github."
exit 1
fi
# adding drives to fstab for permanent mount
2019-12-13 20:10:29 +01:00
echo
echo "# --> Adding the data drive to OS ..."
echo " # hddCandidate=' ${ hddCandidate } ' "
2020-09-21 21:59:37 +02:00
echo " # hddPartitionCandidate=' ${ hddPartitionCandidate } ' "
2020-10-18 18:22:32 +02:00
echo " # hddFormat=' ${ hddFormat } ' "
if [ " $hddFormat " = = "btrfs" ] ; then
source <( sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${ hddCandidate } )
else
source <( sudo /home/admin/config.scripts/blitz.datadrive.sh fstab ${ hddPartitionCandidate } )
fi
2019-12-13 19:21:59 +01:00
if [ ${# error } -gt 0 ] ; then
echo " FAIL blitz.datadrive.sh fstab --> ${ error } "
echo "Please report issue to the raspiblitz github."
exit 1
fi
2019-12-14 12:20:51 +01:00
# adding RAID drive
echo " # isBTRFS= ${ isBTRFS } "
echo " # raidCandidates= ${ raidCandidates } "
if [ ${ isBTRFS } -eq 1 ] && [ ${ raidCandidates } -eq 1 ] ; then
# example string: 'sdb 28 GB SanDisk'
raidDevice = $( echo " ${ raidCandidate [0] } " | cut -d " " -f 1)
raidSizeGB = $( echo " ${ raidCandidate [0] } " | cut -d " " -f 2)
echo
echo "# --> Adding Raid Drive ..."
echo " # raidDevice=' ${ raidDevice } ' "
echo " # raidSizeGB= ${ raidSizeGB } "
source <( sudo /home/admin/config.scripts/blitz.datadrive.sh raid on ${ raidDevice } )
if [ ${# error } -gt 0 ] ; then
echo " # FAIL blitz.datadrive.sh raid on --> ${ error } "
echo "# Please report issue to the raspiblitz github."
exit 1
fi
fi
2019-12-13 19:21:59 +01:00
# init the RASPIBLITZ Config
2019-12-13 20:10:29 +01:00
echo
echo "# --> Init raspiblitz.conf ..."
2019-12-13 19:21:59 +01:00
configFile = "/mnt/hdd/raspiblitz.conf"
configExists = $( sudo ls ${ configFile } 2>/dev/null | grep -c 'raspiblitz.conf' )
2019-12-13 20:10:29 +01:00
if [ ${ configExists } -eq 1 ] ; then
# config exists - nothing much to do
echo "# config file already exists on HDD/SSD"
sudo chmod 777 ${ configFile }
2019-12-13 19:21:59 +01:00
else
2019-12-13 20:10:29 +01:00
# create file and use init values from raspiblitz.info
echo " # CREATING new ${ configFile } "
source /home/admin/_version.info
2020-08-02 21:01:02 +02:00
echo "# RASPIBLITZ CONFIG FILE" > /home/admin/raspiblitz.conf
echo " raspiBlitzVersion=' ${ codeVersion } ' " >> /home/admin/raspiblitz.conf
echo " network= ${ network } " >> /home/admin/raspiblitz.conf
echo " chain= ${ chain } " >> /home/admin/raspiblitz.conf
echo " hostname= ${ hostname } " >> /home/admin/raspiblitz.conf
2021-04-08 00:02:57 +02:00
echo " displayClass= ${ displayClass } " >> /home/admin/raspiblitz.conf
echo " displayType= ${ displayType } " >> /home/admin/raspiblitz.conf
2020-08-02 21:01:02 +02:00
echo "lcdrotate=1" >> /home/admin/raspiblitz.conf
2019-12-13 20:10:29 +01:00
2020-08-02 21:03:43 +02:00
sudo mv /home/admin/raspiblitz.conf $configFile
sudo chown root:root ${ configFile }
sudo chmod 777 ${ configFile }
sleep 3
2020-10-29 19:58:26 +01:00
# try to determine publicIP and make sure its in raspiblitz.conf
# https://github.com/rootzoll/raspiblitz/issues/312#issuecomment-462675101
/home/admin/config.scripts/internet.sh update-publicip
2019-12-13 19:21:59 +01:00
fi
2020-11-25 11:39:19 +01:00
# link ssh directory from SD card to HDD
2019-12-13 20:10:29 +01:00
echo "# --> SSH key settings"
2020-11-25 11:39:19 +01:00
echo "# copying SSH pub keys to HDD"
2019-12-13 19:21:59 +01:00
sudo cp -r /etc/ssh /mnt/hdd/ssh
2020-11-25 11:39:19 +01:00
# just copy dont link anymore
# see: https://github.com/rootzoll/raspiblitz/issues/1798
#sudo rm -rf /etc/ssh
#sudo ln -s /mnt/hdd/ssh /etc/ssh
#sudo /home/admin/config.scripts/blitz.systemd.sh update-sshd
2019-12-13 20:10:29 +01:00
echo "# OK"
2019-12-13 19:21:59 +01:00
echo ""
# set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=40/g" /home/admin/raspiblitz.info
# check if HDD contains a blockchain to work with
echo " hddGotBlockchain= ${ hddGotBlockchain } "
if [ ${ hddGotBlockchain } -eq 1 ] ; then
2019-12-13 20:10:29 +01:00
echo "# Looks like the HDD is prepared with the Blockchain."
2019-12-13 19:21:59 +01:00
# 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 "
2019-08-07 12:32:52 +02:00
On the HDD/SSD Blockchain data was found.\n
Continue if you trust that data to be valid.\n
If you dont trust that data you can now choose to delete it - but keep in mind that this can add multiple days of waiting time to your setup process to regain or self-validate the initial blockchain data.
" 14 75
2019-12-13 19:21:59 +01:00
if [ $? -eq 1 ] ; then
# DELETE
2019-12-13 20:10:29 +01:00
echo "# Deleting old blockchain data .."
2019-12-13 19:21:59 +01:00
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
2019-12-13 20:10:29 +01:00
echo "# HDD now empty --> follow further setup"
2019-12-13 19:21:59 +01:00
./10setupBlitz.sh
else
# CONTINUE
2019-12-13 20:10:29 +01:00
echo "# Continuing with finishing the system setup ..."
2019-12-13 19:21:59 +01:00
./60finishHDD.sh
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
else
2019-12-13 19:21:59 +01:00
# HDD is empty - let setupBlitz - display next options
2019-12-13 20:10:29 +01:00
echo "# HDD empty --> follow further setup"
2019-12-13 19:21:59 +01:00
./10setupBlitz.sh
2020-09-21 21:59:37 +02:00
fi