mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-04-14 06:39:24 +02:00
small fixes and handle more than one sda
This commit is contained in:
parent
7373dac395
commit
00b07362f2
@ -51,7 +51,7 @@ if [ ${mountOK} -eq 1 ]; then
|
||||
fi
|
||||
|
||||
# check if there is a download to continue
|
||||
downloadProgressExists=$(sudo ls /home/admin/.Download.progress 2>/dev/null | grep ".Download.progress" -c)
|
||||
downloadProgressExists=$(sudo ls /home/admin/.Download.out 2>/dev/null | grep ".Download.out" -c)
|
||||
if [ ${downloadProgressExists} -eq 1 ]; then
|
||||
echo "found download in progress .."
|
||||
./50downloadHDD.sh
|
||||
|
@ -2,9 +2,32 @@
|
||||
echo ""
|
||||
echo "*** Checking if HDD is connected ***"
|
||||
sleep 5
|
||||
device="sda1"
|
||||
existsHDD=$(lsblk | grep -c sda1)
|
||||
if [ ${existsHDD} -eq 1 ]; then
|
||||
echo "OK - HDD found as sda1"
|
||||
echo "OK - HDD found at sda1"
|
||||
|
||||
# check if there is s sda2
|
||||
existsHDD2=$(lsblk | grep -c sda2)
|
||||
if [ ${existsHDD2} -eq 1 ]; then
|
||||
echo "OK - HDD found at sda2 ... determine which is bigger"
|
||||
|
||||
# get both with size
|
||||
size1=$(lsblk -o NAME,SIZE -b | grep "sda1" | awk '{ print substr( $0, 12, length($0)-2 ) }' | xargs)
|
||||
echo "sda1(${size1})"
|
||||
size2=$(lsblk -o NAME,SIZE -b | grep "sda2" | awk '{ print substr( $0, 12, length($0)-2 ) }' | xargs)
|
||||
echo "sda2(${size2})"
|
||||
|
||||
# chosse to run with the bigger one
|
||||
if [ ${size2} -gt ${size1} ]; then
|
||||
echo "sda2 is BIGGER - run with this one"
|
||||
device="sda2"
|
||||
else
|
||||
echo "sda1 is BIGGER - run with this one"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
mountOK=$(df | grep -c /mnt/hdd)
|
||||
if [ ${mountOK} -eq 1 ]; then
|
||||
echo "FAIL - HDD is mounted"
|
||||
@ -12,10 +35,10 @@ if [ ${existsHDD} -eq 1 ]; then
|
||||
else
|
||||
echo ""
|
||||
echo "*** Formatting the HDD ***"
|
||||
echo "WARNING ALL DATA ON HDD WILL GET DELETED"
|
||||
echo "WARNING ALL DATA ON HDD WILL GET DELETED - CAN TAKE SOME TIME"
|
||||
echo "Wait until you get a OK or FAIL"
|
||||
sleep 4
|
||||
sudo mkfs.ext4 /dev/sda1 -F -L BLOCKCHAIN
|
||||
sudo mkfs.ext4 /dev/${device} -F -L BLOCKCHAIN
|
||||
echo "format ext4 done - wait 6 secs"
|
||||
sleep 6
|
||||
formatExt4OK=$(lsblk -o UUID,NAME,FSTYPE,SIZE,LABEL,MODEL | grep BLOCKCHAIN | grep -c ext4)
|
||||
|
@ -6,9 +6,9 @@ network=`cat .network`
|
||||
|
||||
echo "*** Adding HDD to the System ***"
|
||||
sleep 5
|
||||
existsHDD=$(lsblk | grep -c sda1)
|
||||
if [ ${existsHDD} -eq 1 ]; then
|
||||
echo "OK - HDD found as sda1"
|
||||
existsHDD=$(lsblk | grep -c sda)
|
||||
if [ ${existsHDD} -gt 0 ]; then
|
||||
echo "OK - HDD found as sda"
|
||||
mountOK=$(df | grep -c /mnt/hdd)
|
||||
if [ ${mountOK} -eq 1 ]; then
|
||||
echo "FAIL - HDD is already mounted"
|
||||
@ -67,6 +67,6 @@ if [ ${existsHDD} -eq 1 ]; then
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "FAIL - no HDD as device sda1 found"
|
||||
echo "check if HDD is properly connected and has enough power - then try again"
|
||||
echo "FAIL - no HDD as device sda found"
|
||||
echo "check if HDD is properly connected and has enough power - then try again with reboot"
|
||||
fi
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
echo ""
|
||||
|
||||
# *** BITCOIN ***
|
||||
@ -38,6 +38,7 @@ isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
|
||||
echo "isRunning(${isRunning})"
|
||||
if [ ${isRunning} -eq 0 ]; then
|
||||
echo "Starting screen session"
|
||||
sudo mkdir ${targetDir} 2>/dev/null
|
||||
screen -S ${name} -dm ${command}
|
||||
else
|
||||
echo "Continue screen session"
|
||||
@ -139,8 +140,8 @@ targetPath=$(echo ${url} | cut -d '@' -f2)
|
||||
echo "path to downloaded data is ${targetPath}"
|
||||
|
||||
# calculate progress and write it to file for LCD to read
|
||||
finalSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' )
|
||||
if [ ${#actualSize} -eq 0 ]; then
|
||||
finalSize=$( du -s ${targetDir} 2>/dev/null | head -n1 | awk '{print $1;}' )
|
||||
if [ ${#finalSize} -eq 0 ]; then
|
||||
finalSize=0
|
||||
fi
|
||||
echo "final size is ${finalSize} of targeted size ${targetSize}"
|
||||
@ -151,7 +152,7 @@ if [ ${finalSize} -lt ${targetSize} ]; then
|
||||
# Download failed
|
||||
sleep 3
|
||||
echo -ne '\007'
|
||||
dialog --title " WARNING " --yesno "The download failed or is not complete. Do you want keep already downloaded data?" 6 57
|
||||
dialog --title " WARNING " --yesno "The download failed or is not complete. Maybe try again (later). Do you want keep already downloaded data for next try?" 6 57
|
||||
response=$?
|
||||
case $response in
|
||||
1) sudo rm -rf ${targetDir}${targetPath} ;;
|
||||
|
Loading…
x
Reference in New Issue
Block a user