From c09945434412f078a59370997d7f340fbb97d301 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Wed, 5 Sep 2018 16:39:07 +0200 Subject: [PATCH 01/20] changed torrent client to lftp --- home.admin/50torrentHDD.old.sh | 68 ++++++++++++ home.admin/50torrentHDD.sh | 183 ++++++++++++++++++++++++++------- 2 files changed, 213 insertions(+), 38 deletions(-) create mode 100755 home.admin/50torrentHDD.old.sh diff --git a/home.admin/50torrentHDD.old.sh b/home.admin/50torrentHDD.old.sh new file mode 100755 index 000000000..0118d34f4 --- /dev/null +++ b/home.admin/50torrentHDD.old.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +# *** BITCOIN Torrent *** +bitcoinTorrent="raspiblitz-bitcoin-2018-07-16" +bitcoinTorrentsize=231230512 + +# *** LITECOIN Torrent *** +litecoinTorrent="raspiblitz-litecoin-2018-07-29" +litecoinTorrentsize=10240000 + +# load network +network=`cat .network` + +# settings based on network +torrent=$bitcoinTorrent +torrentsize=$bitcoinTorrentsize +if [ "$network" = "litecoin" ]; then + torrent=$litecoinTorrent + torrentsize=$litecoinTorrentsize +fi +echo "" +echo "torrentFile: ${torrent}" + +echo "" +echo "*** Downloading TORRENT ***" +echo "IN CASE DOWNLOAD DOES NOT START OR TOO SLOW:" +echo "CTRL+z start ./10setupBlitz.sh choose other option" +echo "***************************" +echo "" +tmpfile=$(mktemp) +chmod a+x $tmpfile +echo "killall transmission-cli" > $tmpfile +sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile +echo "OK - Download closed" +echo "" + +echo "*** Checking TORRENT ***" +echo "wait a moment" +sleep 5 +downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9') +if [ ${#downloadsize} -eq 0 ]; then + downloadsize=0 +fi +# add some tolerance for checking +size="$(($size-1024000))" +echo "download size is(${downloadsize}) needs to be minimum(${size})" +if [ ${downloadsize} -lt ${size} ]; then + 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 + response=$? + case $response in + 1) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;; + esac + ./00mainMenu.sh + exit 1; +fi + +echo "*** Moving Files ***" +echo "moving files ..." +sudo mv /mnt/hdd/$torrent /mnt/hdd/${network} +echo "" + +# set SetupState +echo "50" > /home/admin/.setup + +# continue setup +./60finishHDD.sh \ No newline at end of file diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 0118d34f4..ba86b23c1 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -1,4 +1,5 @@ -#!/bin/sh +#!/bin/bash +echo "" # *** BITCOIN Torrent *** bitcoinTorrent="raspiblitz-bitcoin-2018-07-16" @@ -13,56 +14,162 @@ network=`cat .network` # settings based on network torrent=$bitcoinTorrent -torrentsize=$bitcoinTorrentsize +size=$bitcoinTorrentsize if [ "$network" = "litecoin" ]; then torrent=$litecoinTorrent - torrentsize=$litecoinTorrentsize + size=$litecoinTorrentsize fi -echo "" -echo "torrentFile: ${torrent}" -echo "" -echo "*** Downloading TORRENT ***" -echo "IN CASE DOWNLOAD DOES NOT START OR TOO SLOW:" -echo "CTRL+z start ./10setupBlitz.sh choose other option" -echo "***************************" -echo "" -tmpfile=$(mktemp) -chmod a+x $tmpfile -echo "killall transmission-cli" > $tmpfile -sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile -echo "OK - Download closed" -echo "" +# screen background monitoring settings +name="Torrent" +targetDir="/mnt/hdd/torrent/" +targetSize=$size +maxTimeoutLoops=100000 +command="sudo lftp -c 'torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye'" -echo "*** Checking TORRENT ***" -echo "wait a moment" -sleep 5 -downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9') -if [ ${#downloadsize} -eq 0 ]; then - downloadsize=0 +echo "command to execute:" +echo ${command} +echo "Press key to continue" +read key + +# starting session if needed +echo "checking if ${name} has a running screen session" +screen -wipe 1>/dev/null +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" fi -# add some tolerance for checking -size="$(($size-1024000))" -echo "download size is(${downloadsize}) needs to be minimum(${size})" -if [ ${downloadsize} -lt ${size} ]; then +sleep 3 + +# monitor session +screenDump="... started ..." +actualSize=0 +timeout=1 +timeoutInfo="-" +while : + do + + # check if session is still running + screen -wipe 1>/dev/null + isRunning=$( screen -S ${name} -ls | grep "${name}" -c ) + if [ ${isRunning} -eq 0 ]; then + timeout=0 + echo "OK - session finished" + break + fi + + # calculate progress and write it to file for LCD to read + freshSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' ) + if [ ${#actualSize} -eq 0 ]; then + freshSize=0 + fi + progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc) + echo $progress > '.${name}.progress' + + # detect if since last loop any progress occured + if [ ${actualSize} -eq ${freshSize} ]; then + timeoutInfo="${timeout}/${maxTimeoutLoops}" + timeout=$(( $timeout + 1 )) + else + timeout=1 + timeoutInfo="no timeout detected" + fi + actualSize=$freshSize + + # detect if mx timeout loop limit is reached + if [ ${timeout} -gt ${maxTimeoutLoops} ]; then + echo "FAIL - download hit timeout" + break + fi + + # display info screen + clear + echo "****************************************************" + echo "Monitoring Screen Session: ${name}" + echo "Progress: ${progress}% (${actualSize} of ${targetSize})" + echo "Timeout: ${timeoutInfo}" + echo "If needed press key x to stop ${name}" + echo "NOTICE: This can take multiple hours or days !!" + echo "Its OK to close terminal now and SSH back in later." + echo "****************************************************" + screen -S ${name} -X hardcopy .${name}.out + newScreenDump=$(cat .Download.out | grep . | tail -8) + if [ ${#newScreenDump} -gt 0 ]; then + screenDump=$newScreenDump + fi + echo "$screenDump" + + # wait 2 seconds for key input + read -n 1 -t 2 keyPressed + + # check if user wants to abort session + if [ "${keyPressed}" = "x" ]; then + echo "" + echo "Aborting ${name}" + break + fi + + done + +# clean up +rm -f .${name}.out +rm -f .${name}.progress + +# quit session if still running +if [ ${isRunning} -eq 1 ]; then + # get the PID of screen session + sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs) + echo "killing screen session PID(${sessionPID})" + # kill all child processes of screen sceesion + pkill -P ${sessionPID} + echo "proccesses klilled" + sleep 3 + # tell the screen session to quit and wait a bit + screen -S ${name} -X quit 1>/dev/null + sleep 3 + echo "cleaning screen" + screen -wipe 1>/dev/null + sleep 3 +fi + +# the path the actual data will be in +targetPath="${targetDir}${torrent}" +echo "path to downloaded data is ${targetPath}" + +# calculate progress and write it to file for LCD to read +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}" + +# check result +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?" 8 57 response=$? case $response in - 1) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;; + 1) sudo rm -rf ${targetDir} ;; esac ./00mainMenu.sh exit 1; -fi + +else -echo "*** Moving Files ***" -echo "moving files ..." -sudo mv /mnt/hdd/$torrent /mnt/hdd/${network} -echo "" + # Download worked + echo "*** Moving Files ***" + sudo mv ${targetDir}${targetPath} /mnt/hdd/${network} + echo "OK" -# set SetupState -echo "50" > /home/admin/.setup + # continue setup + ./60finishHDD.sh -# continue setup -./60finishHDD.sh \ No newline at end of file +fi \ No newline at end of file From 05b5d06db898e33eafeb0c7d39301c94679bbf78 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Wed, 5 Sep 2018 17:09:45 +0200 Subject: [PATCH 02/20] installing lftp --- home.admin/50torrentHDD.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index ba86b23c1..ab1b68fc8 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -27,6 +27,7 @@ targetSize=$size maxTimeoutLoops=100000 command="sudo lftp -c 'torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye'" +sudo apt-get install lftp -y echo "command to execute:" echo ${command} echo "Press key to continue" From d4c850e5efbe2269af890cf17b8c0b86225faf09 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Wed, 5 Sep 2018 20:05:12 +0200 Subject: [PATCH 03/20] drop screen use lftp --- home.admin/50torrentHDD.sh | 175 ++++++++----------------------------- 1 file changed, 36 insertions(+), 139 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index ab1b68fc8..9659edbf0 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -3,174 +3,71 @@ echo "" # *** BITCOIN Torrent *** bitcoinTorrent="raspiblitz-bitcoin-2018-07-16" -bitcoinTorrentsize=231230512 # *** LITECOIN Torrent *** litecoinTorrent="raspiblitz-litecoin-2018-07-29" -litecoinTorrentsize=10240000 # load network network=`cat .network` +targetDir="/mnt/hdd/torrent/" + # settings based on network torrent=$bitcoinTorrent -size=$bitcoinTorrentsize if [ "$network" = "litecoin" ]; then torrent=$litecoinTorrent - size=$litecoinTorrentsize fi -# screen background monitoring settings -name="Torrent" -targetDir="/mnt/hdd/torrent/" -targetSize=$size -maxTimeoutLoops=100000 -command="sudo lftp -c 'torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye'" - sudo apt-get install lftp -y -echo "command to execute:" -echo ${command} -echo "Press key to continue" -read key +echo "" -# starting session if needed -echo "checking if ${name} has a running screen session" -screen -wipe 1>/dev/null -isRunning=$( screen -S ${name} -ls | grep "${name}" -c ) -echo "isRunning(${isRunning})" +# check if lftp is running in background +pid=$(pgrep lftp | head -n 1) +echo "${pid}" if [ ${isRunning} -eq 0 ]; then - echo "Starting screen session" + echo "Starting lftp" sudo mkdir ${targetDir} 2>/dev/null - screen -S ${name} -dm ${command} + sudo lftp -c "torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye" else - echo "Continue screen session" + echo "Reattaching lftp (${pid})" + sudo lftp -c "attach ${pid}" fi -sleep 3 -# monitor session -screenDump="... started ..." -actualSize=0 -timeout=1 -timeoutInfo="-" -while : - do +exit 1 - # check if session is still running - screen -wipe 1>/dev/null - isRunning=$( screen -S ${name} -ls | grep "${name}" -c ) - if [ ${isRunning} -eq 0 ]; then - timeout=0 - echo "OK - session finished" - break - fi - - # calculate progress and write it to file for LCD to read - freshSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' ) - if [ ${#actualSize} -eq 0 ]; then - freshSize=0 - fi - progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc) - echo $progress > '.${name}.progress' - - # detect if since last loop any progress occured - if [ ${actualSize} -eq ${freshSize} ]; then - timeoutInfo="${timeout}/${maxTimeoutLoops}" - timeout=$(( $timeout + 1 )) - else - timeout=1 - timeoutInfo="no timeout detected" - fi - actualSize=$freshSize - - # detect if mx timeout loop limit is reached - if [ ${timeout} -gt ${maxTimeoutLoops} ]; then - echo "FAIL - download hit timeout" - break - fi - - # display info screen - clear - echo "****************************************************" - echo "Monitoring Screen Session: ${name}" - echo "Progress: ${progress}% (${actualSize} of ${targetSize})" - echo "Timeout: ${timeoutInfo}" - echo "If needed press key x to stop ${name}" - echo "NOTICE: This can take multiple hours or days !!" - echo "Its OK to close terminal now and SSH back in later." - echo "****************************************************" - screen -S ${name} -X hardcopy .${name}.out - newScreenDump=$(cat .Download.out | grep . | tail -8) - if [ ${#newScreenDump} -gt 0 ]; then - screenDump=$newScreenDump - fi - echo "$screenDump" - - # wait 2 seconds for key input - read -n 1 -t 2 keyPressed - - # check if user wants to abort session - if [ "${keyPressed}" = "x" ]; then - echo "" - echo "Aborting ${name}" - break - fi - - done - -# clean up -rm -f .${name}.out -rm -f .${name}.progress - -# quit session if still running -if [ ${isRunning} -eq 1 ]; then - # get the PID of screen session - sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs) - echo "killing screen session PID(${sessionPID})" - # kill all child processes of screen sceesion - pkill -P ${sessionPID} - echo "proccesses klilled" - sleep 3 - # tell the screen session to quit and wait a bit - screen -S ${name} -X quit 1>/dev/null - sleep 3 - echo "cleaning screen" - screen -wipe 1>/dev/null - sleep 3 -fi +# TODO check success by size # the path the actual data will be in -targetPath="${targetDir}${torrent}" -echo "path to downloaded data is ${targetPath}" +#targetPath="${targetDir}${torrent}" +#echo "path to downloaded data is ${targetPath}" # calculate progress and write it to file for LCD to read -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}" +#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}" # check result -if [ ${finalSize} -lt ${targetSize} ]; then +#if [ ${finalSize} -lt ${targetSize} ]; then # Download failed - sleep 3 - echo -ne '\007' - 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?" 8 57 - response=$? - case $response in - 1) sudo rm -rf ${targetDir} ;; - esac - ./00mainMenu.sh - exit 1; - -else +# sleep 3 +# echo -ne '\007' +# 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?" 8 57 +# response=$? +# case $response in +# 1) sudo rm -rf ${targetDir} ;; +# esac +# ./00mainMenu.sh +# exit 1; +# +#else - # Download worked - echo "*** Moving Files ***" - sudo mv ${targetDir}${targetPath} /mnt/hdd/${network} - echo "OK" +# # Download worked +# echo "*** Moving Files ***" +# sudo mv ${targetDir}${targetPath} /mnt/hdd/${network} +# echo "OK" # continue setup - ./60finishHDD.sh - -fi \ No newline at end of file +# ./60finishHDD.sh \ No newline at end of file From bb2ced1f841fb583297633f0a57af7d7bfe682fc Mon Sep 17 00:00:00 2001 From: rootzoll Date: Wed, 5 Sep 2018 20:06:48 +0200 Subject: [PATCH 04/20] check pid --- home.admin/50torrentHDD.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 9659edbf0..cd24cc795 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -24,7 +24,7 @@ echo "" # check if lftp is running in background pid=$(pgrep lftp | head -n 1) echo "${pid}" -if [ ${isRunning} -eq 0 ]; then +if [ ${#pid} -eq 0 ]; then echo "Starting lftp" sudo mkdir ${targetDir} 2>/dev/null sudo lftp -c "torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye" From 963f39d6ed3cc871adfdd7632fb2416984dd34c8 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 17:06:59 +0200 Subject: [PATCH 05/20] using screen instead of lftp background jobs --- home.admin/50torrentHDD.sh | 182 ++++++++++++++++++++++++++++--------- 1 file changed, 141 insertions(+), 41 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index cd24cc795..1ae3cc37d 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -3,71 +3,171 @@ echo "" # *** BITCOIN Torrent *** bitcoinTorrent="raspiblitz-bitcoin-2018-07-16" +bitcoinTorrentsize=231230512 # *** LITECOIN Torrent *** litecoinTorrent="raspiblitz-litecoin-2018-07-29" +litecoinTorrentsize=10240000 # load network network=`cat .network` -targetDir="/mnt/hdd/torrent/" - # settings based on network torrent=$bitcoinTorrent +size=$bitcoinTorrentsize if [ "$network" = "litecoin" ]; then torrent=$litecoinTorrent + size=$litecoinTorrentsize fi -sudo apt-get install lftp -y -echo "" +# screen background monitoring settings +name="Torrent" +targetDir="/mnt/hdd/torrent/" +targetSize=$size +maxTimeoutLoops=100000 +command="sudo lftp -c 'torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye'" -# check if lftp is running in background -pid=$(pgrep lftp | head -n 1) -echo "${pid}" -if [ ${#pid} -eq 0 ]; then - echo "Starting lftp" +# starting session if needed +echo "checking if ${name} has a running screen session" +screen -wipe 1>/dev/null +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 - sudo lftp -c "torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye" + screen -S ${name} -dm ${command} else - echo "Reattaching lftp (${pid})" - sudo lftp -c "attach ${pid}" + echo "Continue screen session" +fi +sleep 3 + +# monitor session +screenDump="... started ..." +actualSize=0 +timeout=1 +timeoutInfo="-" +while : + do + + # check if session is still running + screen -wipe 1>/dev/null + isRunning=$( screen -S ${name} -ls | grep "${name}" -c ) + if [ ${isRunning} -eq 0 ]; then + timeout=0 + echo "OK - session finished" + break + fi + + # calculate progress and write it to file for LCD to read + freshSize=$( du -s ${targetDir} | head -n1 | awk '{print $1;}' ) + if [ ${#actualSize} -eq 0 ]; then + freshSize=0 + fi + progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc) + echo $progress > '.${name}.progress' + + # detect if since last loop any progress occured + if [ ${actualSize} -eq ${freshSize} ]; then + timeoutInfo="${timeout}/${maxTimeoutLoops}" + timeout=$(( $timeout + 1 )) + else + timeout=1 + timeoutInfo="no timeout detected" + fi + actualSize=$freshSize + + # detect if mx timeout loop limit is reached + if [ ${timeout} -gt ${maxTimeoutLoops} ]; then + echo "FAIL - download hit timeout" + break + fi + + # display info screen + clear + echo "****************************************************" + echo "Monitoring Screen Session: ${name}" + echo "Progress: ${progress}% (${actualSize} of ${targetSize})" + echo "Timeout: ${timeoutInfo}" + echo "If needed press key x to stop ${name}" + echo "NOTICE: This can take multiple hours or days !!" + echo "Its OK to close terminal now and SSH back in later." + echo "****************************************************" + screen -S ${name} -X hardcopy .${name}.out + newScreenDump=$(cat .Download.out | grep . | tail -8) + if [ ${#newScreenDump} -gt 0 ]; then + screenDump=$newScreenDump + fi + echo "$screenDump" + + # wait 2 seconds for key input + read -n 1 -t 2 keyPressed + + # check if user wants to abort session + if [ "${keyPressed}" = "x" ]; then + echo "" + echo "Aborting ${name}" + break + fi + + done + +# clean up +rm -f .${name}.out +rm -f .${name}.progress + +# quit session if still running +if [ ${isRunning} -eq 1 ]; then + # get the PID of screen session + sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs) + echo "killing screen session PID(${sessionPID})" + # kill all child processes of screen sceesion + pkill -P ${sessionPID} + echo "proccesses klilled" + sleep 3 + # tell the screen session to quit and wait a bit + screen -S ${name} -X quit 1>/dev/null + sleep 3 + echo "cleaning screen" + screen -wipe 1>/dev/null + sleep 3 fi -exit 1 - -# TODO check success by size - -# the path the actual data will be in -#targetPath="${targetDir}${torrent}" -#echo "path to downloaded data is ${targetPath}" +# the path torrent will download to +targetPath="${targetDir}${torrent}" +echo "path to downloaded data is ${targetPath}" # calculate progress and write it to file for LCD to read -#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}" +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}" + +echo "PRESS KEY TO CONTINUE" +read key # check result -#if [ ${finalSize} -lt ${targetSize} ]; then +if [ ${finalSize} -lt ${targetSize} ]; then # Download failed -# sleep 3 -# echo -ne '\007' -# 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?" 8 57 -# response=$? -# case $response in -# 1) sudo rm -rf ${targetDir} ;; -# esac -# ./00mainMenu.sh -# exit 1; -# -#else + sleep 3 + echo -ne '\007' + 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?" 8 57 + response=$? + case $response in + 1) sudo rm -rf ${targetDir} ;; + esac + ./00mainMenu.sh + exit 1; + +else -# # Download worked -# echo "*** Moving Files ***" -# sudo mv ${targetDir}${targetPath} /mnt/hdd/${network} -# echo "OK" + # Download worked + echo "*** Moving Files ***" + sudo mv ${targetPath} /mnt/hdd/${network} + echo "OK" # continue setup -# ./60finishHDD.sh \ No newline at end of file + ./60finishHDD.sh + +fi \ No newline at end of file From 7413831b8a5810096102dd4b50efed13d992a653 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 17:08:49 +0200 Subject: [PATCH 06/20] echo screen command --- home.admin/50torrentHDD.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 1ae3cc37d..7a7c11cbc 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -35,6 +35,7 @@ echo "isRunning(${isRunning})" if [ ${isRunning} -eq 0 ]; then echo "Starting screen session" sudo mkdir ${targetDir} 2>/dev/null + echo "screen -S ${name} -dm ${command}" screen -S ${name} -dm ${command} else echo "Continue screen session" From 5b8ee773c93766e1914ba45641d9917b8a271c61 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 17:19:36 +0200 Subject: [PATCH 07/20] chenged command --- home.admin/50torrentHDD.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 7a7c11cbc..1d4ffaaa3 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -25,7 +25,7 @@ name="Torrent" targetDir="/mnt/hdd/torrent/" targetSize=$size maxTimeoutLoops=100000 -command="sudo lftp -c 'torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye'" +command="sudo lftp -c \"torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye\"" # starting session if needed echo "checking if ${name} has a running screen session" From b8bc74ce18f94fd34f14cb6915a3e81000898634 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 17:20:44 +0200 Subject: [PATCH 08/20] changed screen name --- home.admin/50torrentHDD.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 1d4ffaaa3..0a72c9e39 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -21,7 +21,7 @@ if [ "$network" = "litecoin" ]; then fi # screen background monitoring settings -name="Torrent" +name="torrent" targetDir="/mnt/hdd/torrent/" targetSize=$size maxTimeoutLoops=100000 From fb9779d52d45be6f1fe48902d5e9f79aef1c1def Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 17:22:04 +0200 Subject: [PATCH 09/20] fix donwload path --- home.admin/50torrentHDD.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 0a72c9e39..f658186d1 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -22,7 +22,7 @@ fi # screen background monitoring settings name="torrent" -targetDir="/mnt/hdd/torrent/" +targetDir="/mnt/hdd/torrent" targetSize=$size maxTimeoutLoops=100000 command="sudo lftp -c \"torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye\"" @@ -134,7 +134,7 @@ if [ ${isRunning} -eq 1 ]; then fi # the path torrent will download to -targetPath="${targetDir}${torrent}" +targetPath="${targetDir}/${torrent}" echo "path to downloaded data is ${targetPath}" # calculate progress and write it to file for LCD to read From afd49243e74d5179211315ec15f3084463693b2f Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 17:37:17 +0200 Subject: [PATCH 10/20] add bash to command --- home.admin/50torrentHDD.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index f658186d1..fbc3b49f7 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -25,7 +25,7 @@ name="torrent" targetDir="/mnt/hdd/torrent" targetSize=$size maxTimeoutLoops=100000 -command="sudo lftp -c \"torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye\"" +command="bash -c 'sudo lftp -c \"torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye\"'" # starting session if needed echo "checking if ${name} has a running screen session" From 67cda46ba0872da46758d7273b175f4be3dc8abe Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 18:02:22 +0200 Subject: [PATCH 11/20] screen dump file --- home.admin/50downloadHDD.sh | 2 +- home.admin/50torrentHDD.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/home.admin/50downloadHDD.sh b/home.admin/50downloadHDD.sh index 126d18de4..e064ec800 100755 --- a/home.admin/50downloadHDD.sh +++ b/home.admin/50downloadHDD.sh @@ -97,7 +97,7 @@ while : echo "Its OK to close terminal now and SSH back in later." echo "****************************************************" screen -S ${name} -X hardcopy .${name}.out - newScreenDump=$(cat .Download.out | grep . | tail -8) + newScreenDump=$(cat .${name}.out | grep . | tail -8) if [ ${#newScreenDump} -gt 0 ]; then screenDump=$newScreenDump fi diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index fbc3b49f7..0a947d78e 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -25,7 +25,8 @@ name="torrent" targetDir="/mnt/hdd/torrent" targetSize=$size maxTimeoutLoops=100000 -command="bash -c 'sudo lftp -c \"torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye\"'" +#command="bash -c 'sudo lftp -c \"torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye\"'" +command="bash -c 'sudo ls'" # starting session if needed echo "checking if ${name} has a running screen session" @@ -94,7 +95,7 @@ while : echo "Its OK to close terminal now and SSH back in later." echo "****************************************************" screen -S ${name} -X hardcopy .${name}.out - newScreenDump=$(cat .Download.out | grep . | tail -8) + newScreenDump=$(cat .${name}.out | grep . | tail -8) if [ ${#newScreenDump} -gt 0 ]; then screenDump=$newScreenDump fi From 868f02ce96db759a256815bce2e8d94474001859 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 18:44:48 +0200 Subject: [PATCH 12/20] screen fix --- home.admin/50torrentHDD.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 0a947d78e..5a8c9e55e 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -21,12 +21,11 @@ if [ "$network" = "litecoin" ]; then fi # screen background monitoring settings -name="torrent" +name="Torrent" targetDir="/mnt/hdd/torrent" targetSize=$size maxTimeoutLoops=100000 -#command="bash -c 'sudo lftp -c \"torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye\"'" -command="bash -c 'sudo ls'" +command="sudo lftp -c \"torrent -O ${targetDir} /home/admin/assets/${torrent}.torrent; bye\"" # starting session if needed echo "checking if ${name} has a running screen session" @@ -36,8 +35,9 @@ echo "isRunning(${isRunning})" if [ ${isRunning} -eq 0 ]; then echo "Starting screen session" sudo mkdir ${targetDir} 2>/dev/null - echo "screen -S ${name} -dm ${command}" - screen -S ${name} -dm ${command} + screenCommand="screen -S ${name} -L screen.log -dm ${command}" + echo "${screenCommand}" + bash -c "${screenCommand}" else echo "Continue screen session" fi @@ -123,7 +123,7 @@ if [ ${isRunning} -eq 1 ]; then sessionPID=$(screen -ls | grep "${name}" | cut -d "." -f1 | xargs) echo "killing screen session PID(${sessionPID})" # kill all child processes of screen sceesion - pkill -P ${sessionPID} + sudo pkill -P ${sessionPID} echo "proccesses klilled" sleep 3 # tell the screen session to quit and wait a bit From c668fc4bdd3258a0b2dc7bdba294969c11e85f58 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 18:46:55 +0200 Subject: [PATCH 13/20] removed debug break --- home.admin/50torrentHDD.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 5a8c9e55e..ce1a6f13e 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -145,9 +145,6 @@ if [ ${#finalSize} -eq 0 ]; then fi echo "final size is ${finalSize} of targeted size ${targetSize}" -echo "PRESS KEY TO CONTINUE" -read key - # check result if [ ${finalSize} -lt ${targetSize} ]; then From d27e6df2662f41bd67a284e97f998a796816bc55 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 19:48:39 +0200 Subject: [PATCH 14/20] corrected typo --- home.admin/50torrentHDD.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index ce1a6f13e..8f9611825 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -124,7 +124,7 @@ if [ ${isRunning} -eq 1 ]; then echo "killing screen session PID(${sessionPID})" # kill all child processes of screen sceesion sudo pkill -P ${sessionPID} - echo "proccesses klilled" + echo "proccesses killed" sleep 3 # tell the screen session to quit and wait a bit screen -S ${name} -X quit 1>/dev/null From f0a4903d0203966fce87d9a11caf72fb6a1c7b4d Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Sep 2018 19:49:54 +0200 Subject: [PATCH 15/20] lftp install --- home.admin/50downloadHDD.sh | 4 ++ home.admin/50torrentHDD.old.sh | 68 ---------------------------------- home.admin/50torrentHDD.sh | 4 ++ 3 files changed, 8 insertions(+), 68 deletions(-) delete mode 100755 home.admin/50torrentHDD.old.sh diff --git a/home.admin/50downloadHDD.sh b/home.admin/50downloadHDD.sh index e064ec800..4d5e2a7a3 100755 --- a/home.admin/50downloadHDD.sh +++ b/home.admin/50downloadHDD.sh @@ -14,6 +14,10 @@ litecoinSize=19180000 # 19184960-tolerance # load network network=`cat .network` +# make sure lftp is available +sudo apt-get install lftp -y +echo "" + # settings based on network list=$bitcoinList url=$bitcoinUrl diff --git a/home.admin/50torrentHDD.old.sh b/home.admin/50torrentHDD.old.sh deleted file mode 100755 index 0118d34f4..000000000 --- a/home.admin/50torrentHDD.old.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh - -# *** BITCOIN Torrent *** -bitcoinTorrent="raspiblitz-bitcoin-2018-07-16" -bitcoinTorrentsize=231230512 - -# *** LITECOIN Torrent *** -litecoinTorrent="raspiblitz-litecoin-2018-07-29" -litecoinTorrentsize=10240000 - -# load network -network=`cat .network` - -# settings based on network -torrent=$bitcoinTorrent -torrentsize=$bitcoinTorrentsize -if [ "$network" = "litecoin" ]; then - torrent=$litecoinTorrent - torrentsize=$litecoinTorrentsize -fi -echo "" -echo "torrentFile: ${torrent}" - -echo "" -echo "*** Downloading TORRENT ***" -echo "IN CASE DOWNLOAD DOES NOT START OR TOO SLOW:" -echo "CTRL+z start ./10setupBlitz.sh choose other option" -echo "***************************" -echo "" -tmpfile=$(mktemp) -chmod a+x $tmpfile -echo "killall transmission-cli" > $tmpfile -sudo transmission-cli ./assets/$torrent.torrent -D -et -w /mnt/hdd -f $tmpfile -echo "OK - Download closed" -echo "" - -echo "*** Checking TORRENT ***" -echo "wait a moment" -sleep 5 -downloadsize=$(sudo du -s /mnt/hdd/$torrent/ | awk '{print $1}' | tr -dc '0-9') -if [ ${#downloadsize} -eq 0 ]; then - downloadsize=0 -fi -# add some tolerance for checking -size="$(($size-1024000))" -echo "download size is(${downloadsize}) needs to be minimum(${size})" -if [ ${downloadsize} -lt ${size} ]; then - 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 - response=$? - case $response in - 1) sudo rm -rf /mnt/hdd/$torrent ; sudo rm -rf /root/.config/transmission ;; - esac - ./00mainMenu.sh - exit 1; -fi - -echo "*** Moving Files ***" -echo "moving files ..." -sudo mv /mnt/hdd/$torrent /mnt/hdd/${network} -echo "" - -# set SetupState -echo "50" > /home/admin/.setup - -# continue setup -./60finishHDD.sh \ No newline at end of file diff --git a/home.admin/50torrentHDD.sh b/home.admin/50torrentHDD.sh index 8f9611825..11c8cffe4 100755 --- a/home.admin/50torrentHDD.sh +++ b/home.admin/50torrentHDD.sh @@ -12,6 +12,10 @@ litecoinTorrentsize=10240000 # load network network=`cat .network` +# make sure lftp is available +sudo apt-get install lftp -y +echo "" + # settings based on network torrent=$bitcoinTorrent size=$bitcoinTorrentsize From cdada73c34c508802d90cf975047429675f041aa Mon Sep 17 00:00:00 2001 From: rootzoll Date: Sun, 9 Sep 2018 21:34:10 +0200 Subject: [PATCH 16/20] update to litecoin 0.16.2 --- build.sdcard/raspbianStretchDesktop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sdcard/raspbianStretchDesktop.sh b/build.sdcard/raspbianStretchDesktop.sh index 9edf5d874..c20b2ad51 100644 --- a/build.sdcard/raspbianStretchDesktop.sh +++ b/build.sdcard/raspbianStretchDesktop.sh @@ -179,7 +179,7 @@ echo "*** LITECOIN ***" # based on https://medium.com/@jason.hcwong/litecoin-lightning-with-raspberry-pi-3-c3b931a82347 # set version (change if update is available) -litecoinVersion="0.16.0" +litecoinVersion="0.16.2" cd /home/admin/download sudo -u admin wget https://download.litecoin.org/litecoin-${litecoinVersion}/linux/litecoin-${litecoinVersion}-arm-linux-gnueabihf.tar.gz sudo -u admin tar -xvf litecoin-${litecoinVersion}-arm-linux-gnueabihf.tar.gz From 65ae2d09c1fd9e0427579bea59e90d1b4873dd4e Mon Sep 17 00:00:00 2001 From: Lucas Silvestre Date: Mon, 10 Sep 2018 22:05:54 +0200 Subject: [PATCH 17/20] Fix Download.progress file name Using single quote creates a file named '.${name}.progress' rather than 'Download.progress' --- home.admin/50downloadHDD.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/50downloadHDD.sh b/home.admin/50downloadHDD.sh index 4d5e2a7a3..388ae8bbe 100755 --- a/home.admin/50downloadHDD.sh +++ b/home.admin/50downloadHDD.sh @@ -72,7 +72,7 @@ while : freshSize=0 fi progress=$(echo "scale=2; $freshSize*100/$targetSize" | bc) - echo $progress > '.${name}.progress' + echo $progress > ".${name}.progress" # detect if since last loop any progress occured if [ ${actualSize} -eq ${freshSize} ]; then From 758ec89d28595792364d5256c3d87b07ebc7efe4 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 13 Sep 2018 14:30:31 +0200 Subject: [PATCH 18/20] close issue #87 --- home.admin/BBcloseAllChannels.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/BBcloseAllChannels.sh b/home.admin/BBcloseAllChannels.sh index 3543d8dc1..6312ae9f9 100755 --- a/home.admin/BBcloseAllChannels.sh +++ b/home.admin/BBcloseAllChannels.sh @@ -4,7 +4,7 @@ network=`cat .network` chain=$(${network}-cli -datadir=/home/bitcoin/.${network} getblockchaininfo | jq -r '.chain') -command="lncli --chain=${network} --force closeallchannels " +command="lncli --chain=${network} closeallchannels --force" clear echo "***********************************" From b7223eae3af353472bb916098f42db2020e830c2 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 13 Sep 2018 14:49:57 +0200 Subject: [PATCH 19/20] linked china shopping list --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6fac5870..7ff54de83 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Fastest and cheapest way to get your own Lightning Node running - on a Raspberry **Total Price: 127,31 EUR** (thats under 150 USD) Amazon shopping lists for different countries: -[ [USA](shoppinglist_usa.md) ] [ [UK](shoppinglist_uk.md) ] [ [FR](shoppinglist_fr.md) ] +[ [USA](shoppinglist_usa.md) ] [ [UK](shoppinglist_uk.md) ] [ [FR](shoppinglist_fr.md) ] [ [China](shoppinglist_cn.md) ] You can even pay your RaspiBlitz Amazon Shopping with Bitcoin & Lightning thru [Bitrefill](https://blog.bitrefill.com/its-here-buy-amazon-vouchers-with-bitcoin-on-bitrefill-bb2a4449724a). From 906db60e72f84878b87b6275954d4dac6eee5d22 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 13 Sep 2018 15:12:48 +0200 Subject: [PATCH 20/20] added MIT License #70 --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..c4677f01a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 The RaspiBlitz developers + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file