mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-10-10 12:53:01 +02:00
small fixes and handle more than one sda
This commit is contained in:
@@ -51,7 +51,7 @@ if [ ${mountOK} -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check if there is a download to continue
|
# 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
|
if [ ${downloadProgressExists} -eq 1 ]; then
|
||||||
echo "found download in progress .."
|
echo "found download in progress .."
|
||||||
./50downloadHDD.sh
|
./50downloadHDD.sh
|
||||||
|
@@ -2,9 +2,32 @@
|
|||||||
echo ""
|
echo ""
|
||||||
echo "*** Checking if HDD is connected ***"
|
echo "*** Checking if HDD is connected ***"
|
||||||
sleep 5
|
sleep 5
|
||||||
|
device="sda1"
|
||||||
existsHDD=$(lsblk | grep -c sda1)
|
existsHDD=$(lsblk | grep -c sda1)
|
||||||
if [ ${existsHDD} -eq 1 ]; then
|
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)
|
mountOK=$(df | grep -c /mnt/hdd)
|
||||||
if [ ${mountOK} -eq 1 ]; then
|
if [ ${mountOK} -eq 1 ]; then
|
||||||
echo "FAIL - HDD is mounted"
|
echo "FAIL - HDD is mounted"
|
||||||
@@ -12,10 +35,10 @@ if [ ${existsHDD} -eq 1 ]; then
|
|||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo "*** Formatting the HDD ***"
|
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"
|
echo "Wait until you get a OK or FAIL"
|
||||||
sleep 4
|
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"
|
echo "format ext4 done - wait 6 secs"
|
||||||
sleep 6
|
sleep 6
|
||||||
formatExt4OK=$(lsblk -o UUID,NAME,FSTYPE,SIZE,LABEL,MODEL | grep BLOCKCHAIN | grep -c ext4)
|
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 ***"
|
echo "*** Adding HDD to the System ***"
|
||||||
sleep 5
|
sleep 5
|
||||||
existsHDD=$(lsblk | grep -c sda1)
|
existsHDD=$(lsblk | grep -c sda)
|
||||||
if [ ${existsHDD} -eq 1 ]; then
|
if [ ${existsHDD} -gt 0 ]; then
|
||||||
echo "OK - HDD found as sda1"
|
echo "OK - HDD found as sda"
|
||||||
mountOK=$(df | grep -c /mnt/hdd)
|
mountOK=$(df | grep -c /mnt/hdd)
|
||||||
if [ ${mountOK} -eq 1 ]; then
|
if [ ${mountOK} -eq 1 ]; then
|
||||||
echo "FAIL - HDD is already mounted"
|
echo "FAIL - HDD is already mounted"
|
||||||
@@ -67,6 +67,6 @@ if [ ${existsHDD} -eq 1 ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "FAIL - no HDD as device sda1 found"
|
echo "FAIL - no HDD as device sda found"
|
||||||
echo "check if HDD is properly connected and has enough power - then try again"
|
echo "check if HDD is properly connected and has enough power - then try again with reboot"
|
||||||
fi
|
fi
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# *** BITCOIN ***
|
# *** BITCOIN ***
|
||||||
@@ -38,6 +38,7 @@ isRunning=$( screen -S ${name} -ls | grep "${name}" -c )
|
|||||||
echo "isRunning(${isRunning})"
|
echo "isRunning(${isRunning})"
|
||||||
if [ ${isRunning} -eq 0 ]; then
|
if [ ${isRunning} -eq 0 ]; then
|
||||||
echo "Starting screen session"
|
echo "Starting screen session"
|
||||||
|
sudo mkdir ${targetDir} 2>/dev/null
|
||||||
screen -S ${name} -dm ${command}
|
screen -S ${name} -dm ${command}
|
||||||
else
|
else
|
||||||
echo "Continue screen session"
|
echo "Continue screen session"
|
||||||
@@ -139,8 +140,8 @@ targetPath=$(echo ${url} | cut -d '@' -f2)
|
|||||||
echo "path to downloaded data is ${targetPath}"
|
echo "path to downloaded data is ${targetPath}"
|
||||||
|
|
||||||
# calculate progress and write it to file for LCD to read
|
# calculate progress and write it to file for LCD to read
|
||||||
finalSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' )
|
finalSize=$( du -s ${targetDir} 2>/dev/null | head -n1 | awk '{print $1;}' )
|
||||||
if [ ${#actualSize} -eq 0 ]; then
|
if [ ${#finalSize} -eq 0 ]; then
|
||||||
finalSize=0
|
finalSize=0
|
||||||
fi
|
fi
|
||||||
echo "final size is ${finalSize} of targeted size ${targetSize}"
|
echo "final size is ${finalSize} of targeted size ${targetSize}"
|
||||||
@@ -151,7 +152,7 @@ if [ ${finalSize} -lt ${targetSize} ]; then
|
|||||||
# Download failed
|
# Download failed
|
||||||
sleep 3
|
sleep 3
|
||||||
echo -ne '\007'
|
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=$?
|
response=$?
|
||||||
case $response in
|
case $response in
|
||||||
1) sudo rm -rf ${targetDir}${targetPath} ;;
|
1) sudo rm -rf ${targetDir}${targetPath} ;;
|
||||||
|
Reference in New Issue
Block a user