#1676 fix small things for BTRFS and migration (#1736)

This commit is contained in:
geco91
2020-11-01 13:42:03 +01:00
committed by rootzoll
parent 36401d8775
commit 1494ee3ac1
3 changed files with 27 additions and 15 deletions

View File

@@ -356,15 +356,15 @@ if [ "$1" = "format" ]; then
exit 1 exit 1
fi fi
# check if device is existing and a disk (not a partition)
if [ "$2" = "btrfs" ]; then if [ "$2" = "btrfs" ]; then
# check if device is existing and a disk (not a partition)
isValid=$(lsblk -o NAME,TYPE | grep disk | grep -c "${hdd}") isValid=$(lsblk -o NAME,TYPE | grep disk | grep -c "${hdd}")
else else
#TODO: Validate ext4 # check if device is existing (its OK when its a partition)
isValid=1 isValid=$(lsblk -o NAME,TYPE | grep -c "${hdd}")
fi fi
if [ ${isValid} -eq 0 ]; then if [ ${isValid} -eq 0 ]; then
>&2 echo "# either given device was not found" >&2 echo "# given device was not found"
>&2 echo "# or is not of type disk - see 'lsblk'" >&2 echo "# or is not of type disk - see 'lsblk'"
echo "error='device not valid'" echo "error='device not valid'"
exit 1 exit 1

View File

@@ -28,17 +28,23 @@ isBTRFS=$(lsblk -o FSTYPE,MOUNTPOINT | grep /mnt/hdd | awk '$1=$1' | cut -d " "
# set place where zipped TAR file gets stored # set place where zipped TAR file gets stored
defaultZipPath="/mnt/hdd/temp" defaultZipPath="/mnt/hdd/temp"
# get local ip
source <(/home/admin/config.scripts/internet.sh status local)
# SCP download and upload links # SCP download and upload links
localip=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | grep 'eth0\|wlan0\|enp0' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') scpDownloadUnix="scp -r 'bitcoin@${localip}:${defaultZipPath}/raspiblitz-*.tar.gz' ./"
scpDownload="scp -r 'bitcoin@${localip}:${defaultZipPath}/raspiblitz-*.tar.gz' ./" scpDownloadWin="scp -r bitcoin@${localip}:${defaultZipPath}/raspiblitz-*.tar.gz ./"
scpUpload="scp -r './raspiblitz-*.tar.gz bitcoin@${localip}:${defaultZipPath}'" scpUploadUnix="scp -r './raspiblitz-*.tar.gz bitcoin@${localip}:${defaultZipPath}'"
scpUploadWin="scp -r ./raspiblitz-*.tar.gz bitcoin@${localip}:${defaultZipPath}"
# output status data & exit # output status data & exit
if [ "$1" = "status" ]; then if [ "$1" = "status" ]; then
echo "# RASPIBLITZ Data Import & Export" echo "# RASPIBLITZ Data Import & Export"
echo "isBTRFS=${isBTRFS}" echo "isBTRFS=${isBTRFS}"
echo "scpDownload=\"${scpDownload}\"" echo "scpDownloadUnix=\"${scpDownloadUnix}\""
echo "scpUpload=\"${scpUpload}\"" echo "scpUploadUnix=\"${scpUploadUnix}\""
echo "scpDownloadWin=\"${scpDownloadWin}\""
echo "scpUploadWin=\"${scpUploadWin}\""
exit 1 exit 1
fi fi
@@ -110,7 +116,8 @@ if [ "$1" = "export" ]; then
rm ~/.exclude.temp rm ~/.exclude.temp
rm ~/.include.temp rm ~/.include.temp
echo "scpDownload=\"${scpDownload}\"" echo "scpDownloadUnix=\"${scpDownloadUnix}\""
echo "scpDownloadWin=\"${scpDownloadWin}\""
echo "# OK - Export done" echo "# OK - Export done"
exit 0 exit 0
fi fi
@@ -141,8 +148,10 @@ if [ "$1" = "export-gui" ]; then
echo "* DOWNLOAD THE MIGRATION FILE *" echo "* DOWNLOAD THE MIGRATION FILE *"
echo "*******************************" echo "*******************************"
echo echo
echo "ON YOUR LAPTOP - RUN IN NEW TERMINAL:" echo "On yoz Linux or MacOS Laptop - RUN IN NEW TERMINAL:"
echo "${scpDownload}" echo "${scpDownloadUnix}"
echo "On Windows use command:"
echo "${scpDownloadWin}"
echo "" echo ""
echo "Use password A to authenticate file transfer." echo "Use password A to authenticate file transfer."
echo echo
@@ -199,7 +208,8 @@ if [ "$1" = "import" ]; then
countZips=$(sudo ls ${importFile} 2>/dev/null | grep -c '.tar.gz') countZips=$(sudo ls ${importFile} 2>/dev/null | grep -c '.tar.gz')
if [ ${countZips} -eq 0 ]; then if [ ${countZips} -eq 0 ]; then
echo "# can just find file when ends on .tar.gz and exists" echo "# can just find file when ends on .tar.gz and exists"
echo "scpUpload=\"${scpUpload}\"" echo "scpUploadUnix=\"${scpUploadUnix}\""
echo "scpUploadWin=\"${scpUploadWin}\""
echo "error='file not found'" echo "error='file not found'"
exit 1 exit 1
elif [ ${countZips} -eq 1 ]; then elif [ ${countZips} -eq 1 ]; then
@@ -351,7 +361,9 @@ if [ "$1" = "import-gui" ]; then
echo echo
echo "ON YOUR LAPTOP open a new terminal and change into" echo "ON YOUR LAPTOP open a new terminal and change into"
echo "the directory where your migration file is and" echo "the directory where your migration file is and"
echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND:" echo "COPY, PASTE AND EXECUTE THE FOLLOWING COMMAND for Linux or MacOS:"
echo "scp -r './raspiblitz-*.tar.gz admin@${localip}:${defaultZipPath}'"
echo "OR for Windows:"
echo "scp -r ./raspiblitz-*.tar.gz admin@${localip}:${defaultZipPath}" echo "scp -r ./raspiblitz-*.tar.gz admin@${localip}:${defaultZipPath}"
echo "" echo ""
echo "Use password 'raspiblitz' to authenticate file transfer." echo "Use password 'raspiblitz' to authenticate file transfer."

View File

@@ -58,7 +58,7 @@ fi
############################################# #############################################
# get local IP (from different sources) # get local IP (from different sources)
localip_ALL=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | egrep -i '(*[eth|ens|enp|eno|wlan|wlp][0-9]$)' | tail -n1 | awk '{print $2}' | cut -f1 -d'/') localip_ALL=$(ip addr | grep 'state UP' -A2 | egrep -v 'docker0|veth' | egrep -i '(*[eth|ens|enp|eno|wlan|inet|wlp][0-9]$)' | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
if [ $(isValidIP ${localip_ALL}) -eq 0 ]; then if [ $(isValidIP ${localip_ALL}) -eq 0 ]; then
localip_ALL="" localip_ALL=""
fi fi