From 7cc5c6d42db0b22b17723a69e8a42433054be767 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sat, 18 May 2019 21:25:46 +0200 Subject: [PATCH 01/17] CopyStation Script --- home.admin/00infoLCD.sh | 9 ++ home.admin/XXcopyStation.sh | 310 ++++++++++++++++++++++++++++++++++++ 2 files changed, 319 insertions(+) create mode 100755 home.admin/XXcopyStation.sh diff --git a/home.admin/00infoLCD.sh b/home.admin/00infoLCD.sh index 41b00d52c..cc19c01cb 100755 --- a/home.admin/00infoLCD.sh +++ b/home.admin/00infoLCD.sh @@ -198,6 +198,15 @@ while : continue fi + if [ "${state}" = "copystation" ]; then + l1="COPYSTATION MODE\n" + l2="${message}\n" + l3="reboot 4 back to normal" + dialog --backtitle "RaspiBlitz ${codeVersion} ${localip}" --infobox "$l1$l2$l3" 6 ${boxwidth} + sleep 2 + continue + fi + # if LND is syncing or scanning lndSynced=$(sudo -u bitcoin /usr/local/bin/lncli --chain=${network} --network=${chain}net getinfo 2>/dev/null | jq -r '.synced_to_chain' | grep -c true) if [ ${lndSynced} -eq 0 ]; then diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh new file mode 100755 index 000000000..97e0a1436 --- /dev/null +++ b/home.admin/XXcopyStation.sh @@ -0,0 +1,310 @@ +#!/bin/bash + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "# Turns the RaspiBlitz into HDD CopyStation Mode" + echo "# lightning is deactivated during CopyStationMode" + echo "# reboot RaspiBlitz to set back to normal mode" + exit 1 +fi + +####### CONFIG ############# + +# where to find the BITCOIN data directory (no trailing /) +pathBitcoinBlockchain="/mnt/hdd/bitcoin" + +# where to find the LITECOIN data directory (no trailing /) +pathLitecoinBlockchain="/mnt/hdd/litecoin" + +# where to find the RaspiBlitz HDD template directory (no trailing /) +pathTemplateHDD="/mnt/hdd/templateHDD" + +# 0 = ask before formatting/init new HDD +# 1 = auto-formatting every new HDD that needs init +autoformat=1 + +# override values if XXcopyStation.conf files exists +# use when you run this outside RaspiBlitz +source ./XXcopyStation.conf 2>/dev/null + +####### SCRIPT ############# + +# check sudo +if [ "$EUID" -ne 0 ]; then + echo "Please run as root (with sudo)" + exit 1 +fi + +# make sure that its running in screen +# call with '-foreground' to prevent running in screen +if [ "$1" != "-foreground" ]; then + screenPID=$(screen -ls | grep "copystation" | cut -d "." -f1 | xargs) + if [ ${#screenPID} -eq 0 ]; then + # start copystation in sreen + echo "starting copystation screen session" + screen -S copystation -dm /home/admin/XXcopyStation.sh -foreground + else + echo "changing into running copystation screen session" + screen -S copystation + fi +fi + +clear +echo "******************************" +echo "RASPIBLITZ COPYSTATION SCRIPT" +echo "******************************" +echo + +echo "*** CHECKING CONFIG" + +# check that path information is valid +if [ -d "$pathBitcoinBlockchain" ]; then + echo "OK found $pathBitcoinBlockchain" +else + echo "FAIL path of 'pathBitcoinBlockchain' does not exists: ${pathBitcoinBlockchain}" + exit 1 +fi + +# check that path information is valid +if [ -d "$pathTemplateHDD" ]; then + echo "OK found $pathTemplateHDD" +else + echo "Creating: ${pathTemplateHDD}" + mkdir ${pathTemplateHDD} + chmod 777 ${pathTemplateHDD} +fi + +# make sure that lnd is stopped (if runnning) +systemctl stop lnd 2>/dev/null +systemctl stop background 2>/dev/null + + +if [ "${autoformat}" == "1" ]; then + echo "setting RaspiBlitz LCD info" + sudo sed -i "s/^state=.*/state=copystation/g" /home/admin/raspiblitz.info 2>/dev/null + sudo sed -i "s/^message=.*/message='Make sure target HDDs are not connected yet.\nContinue after 10 seconds ...'/g" /home/admin/raspiblitz.info 2>/dev/null + sleep 10 +else + echo + echo "*** INIT HDD SCAN" + echo "Please make sure that no HDDs that you want to sync later to are not connected now." + echo "PRESS ENTER when ready." + read key +fi + +# finding system drives (the drives that should not be synced to) +systemDrives=$(lsblk -o NAME | grep "^sd") +echo "OK - the following drives detected as system drives:" +echo "$systemDrives" +echo + +if [ "${autoformat}" == "1" ]; then + sudo sed -i "s/^message=.*/message='Connect now HDDs to sync ..'/g" /home/admin/raspiblitz.info 2>/dev/null + sleep 5 +fi + +# BASIC IDEA: +# 1. get fresh data from bitcoind --> template data +# 2. detect HDDs +# 3. sync HDDs with template data +# repeat + +echo +echo "*** RUNNING ***" +lastBlockchainUpdateTimestamp=1 + +while : +do + + ################################################ + # 1. get fresh data from bitcoind for template data + + # only execute every 30min + nowTimestamp=$(date +%s) + secondsDiff=$(echo "${nowTimestamp}-${lastBlockchainUpdateTimestamp}" | bc) + echo "seconds since last update from bitcoind: ${secondsDiff}" + echo + + if [ ${secondsDiff} -gt 3000 ]; then + + echo "******************************" + echo "Bitcoin Blockchain Update" + echo "******************************" + + # stop blockchains + echo "Stopping Blockchain ..." + systemctl stop bitcoind 2>/dev/null + systemctl stop litecoind 2>/dev/null + sleep 10 + + # sync bitcoin + echo "Syncing Bitcoin ..." + + # make sure the bitcoin directory in template folder exists + if [ ! -d "$pathTemplateHDD/bitcoin" ]; then + echo "creating the bitcoin subfolder in the template folder" + mkdir ${pathTemplateHDD}/bitcoin + chmod 777 ${pathTemplateHDD}/bitcoin + fi + + rsync -a --info=progress2 ${pathBitcoinBlockchain}/chainstate ${pathBitcoinBlockchain}/indexes ${pathBitcoinBlockchain}/blocks ${pathBitcoinBlockchain}/testnet3 ${pathTemplateHDD}/bitcoin + + if [ ! -d "${pathLitecoinBlockchain}" ]; then + + # sync bitcoin + echo "Syncing Litecoin ..." + + # make sure the litecoin directory in template folder exists + if [ ! -d "$pathTemplateHDD/litecoin" ]; then + echo "creating the litecoin subfolder in the template folder" + mkdir ${pathTemplateHDD}/litecoin + chmod 777 ${pathTemplateHDD}/litecoin + fi + + rsync -a --info=progress2 ${pathLitecoinBlockchain}/chainstate ${pathLitecoinBlockchain}/indexes ${pathLitecoinBlockchain}/blocks ${pathTemplateHDD}/litecoin + + fi + + # restart bitcoind (to let further setup while syncing HDDs) + echo "Restarting Blockchain ..." + systemctl start bitcoind 2>/dev/null + systemctl start litecoind 2>/dev/null + + # update timer + lastBlockchainUpdateTimestamp=$(date +%s) + fi + + ################################################ + # 2. detect connected HDDs and loop thru them + + sleep 4 + echo "" > ./.syncinfo.tmp + lsblk -o NAME | grep "^sd" | while read -r detectedDrive ; do + isSystemDrive=$(echo "${systemDrives}" | grep -c "${detectedDrive}") + if [ ${isSystemDrive} -eq 0 ]; then + + # check if drives 1st partition is named BLOCKCHAIN & in EXT4 format + isNamedBlockchain=$(lsblk -o NAME,FSTYPE,LABEL | grep "${detectedDrive}" | grep -c "BLOCKCHAIN") + isFormatExt4=$(lsblk -o NAME,FSTYPE,LABEL | grep "${detectedDrive}" | grep -c "ext4") + + # init a fresh device + if [ ${isNamedBlockchain} -eq 0 ] || [ ${isFormatExt4} -eq 0 ]; then + + echo "*** NEW EMPTY HDD FOUND ***" + echo "Device: ${detectedDrive}" + echo "isNamedBlockchain: ${isNamedBlockchain}" + echo "isFormatExt4:" ${isFormatExt4} + + # check if size is OK + size=$(lsblk -o NAME,SIZE -b | grep "^${detectedDrive}" | awk '$1=$1' | cut -d " " -f 2) + echo "size: ${size}" + if [ ${size} -lt 250000000000 ]; then + read key + whiptail --title "FAIL" --msgbox " +THE DEVICE IS TOO SMALL <250GB +Please remove device and PRESS ENTER + " 9 46 + else + + # find biggest partition + biggestSize=0 + lsblk -o NAME,SIZE -b | grep "─${detectedDrive}" | while read -r partitionLine ; do + partition=$(echo "${partitionLine}" | cut -d ' ' -f 1 | tr -cd "[:alnum:]") + size=$(echo "${partitionLine}" | tr -cd "[0-9]") + if [ ${size} -gt ${biggestSize} ]; then + formatPartition="${partition}" + biggestSize=$size + fi + echo "${formatPartition}" > .formatPartition.tmp + done + + formatPartition=$(cat .formatPartition.tmp) + rm .formatPartition.tmp + + if [ ${#formatPartition} -eq 0 ]; then + whiptail --title "FAIL" --msgbox " +NO PARTITIONS FOUND ON THAT DEVICE +Format on external computer with FAT32 first. +Please remove device now. + " 10 46 + else + + # if config value "autoformat=1" default to format + if [ "${autoformat}" != "1" ]; then + whiptail --title "Format HDD" --yes-button "Format" --no-button "Cancel" --yesno " +Found new HDD. Do you want to FORMAT now? +Please temp lable device with: ${formatPartition} + " 10 54 + choice=$? + else + choice=0 + fi + + # on cancel + if [ "${choice}" != "0" ]; then + whiptail --title "Format HDD" --msgbox " +OK NO FORMAT - Please remove decive now. + " 8 46 + exit 1 + fi + + # format the HDD + echo "Starting Formatting of device ..." + sudo mkfs.ext4 /dev/${formatPartition} -F -L BLOCKCHAIN + + fi + + fi + + fi # end init new HDD + + ################################################ + # 3. sync HDD with template data + + partition=$(lsblk -o NAME,FSTYPE,LABEL | grep "${detectedDrive}" | grep "BLOCKCHAIN" | cut -d ' ' -f 1 | tr -cd "[:alnum:]") + if [ ${#partition} -gt 0 ]; then + + # temp mount device + echo "mounting: ${partition}" + mkdir /mnt/hdd2 2>/dev/null + sudo mount -t ext4 /dev/${partition} /mnt/hdd2 + + # rsync device + mountOK=$(lsblk -o NAME,MOUNTPOINT | grep "${detectedDrive}" | grep -c "/mnt/hdd2") + if [ ${mountOK} -eq 1 ]; then + rsync -a --info=progress2 ${pathTemplateHDD}/* /mnt/hdd2 + chmod -r 777 /mnt/hdd2 + echo "${partition} " >> ./.syncinfo.tmp + else + echo "FAIL: was not able to mount --> ${partition}" + fi + + # unmount device + sudo umount -l /mnt/hdd2 + + fi + + fi + done + + clear + echo "**** SYNC LOOP DONE ****" + synced=$(cat ./.syncinfo.tmp | tr '\r\n' ' ') + echo "HDDs ready synced: ${synced}" + echo "*************************" + echo "Its safe to disconnect/remove HDDs now." + echo "To stop copystation script: CTRL+c" + echo "" + + + if [ "${autoformat}" == "1" ]; then + sudo sed -i "s/^message=.*/message='Ready & Synced HDDs:\n${synced}'/g" /home/admin/raspiblitz.info 2>/dev/null + fi + + sleep 25 + + clear + echo "starting new sync loop" + sleep 5 + +done \ No newline at end of file From d3918ddc70af2855c457ac37108eab0878bd0f2a Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sat, 18 May 2019 21:58:30 +0200 Subject: [PATCH 02/17] Fix Copystation LCD Info --- home.admin/00infoLCD.sh | 6 +----- home.admin/XXcopyStation.sh | 9 +++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/home.admin/00infoLCD.sh b/home.admin/00infoLCD.sh index cc19c01cb..99fdd553d 100755 --- a/home.admin/00infoLCD.sh +++ b/home.admin/00infoLCD.sh @@ -53,16 +53,12 @@ while : fi # get config info if already available + source ${infoFile} configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf') if [ ${configExists} -eq 1 ]; then source ${configFile} fi - # if setup not marked as done (=100) load boostrap info file - if [ "${setupStep}" != "100" ]; then - source ${infoFile} - fi - # if no information available from files - set default if [ ${#setupStep} -eq 0 ]; then setupStep=0 diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index 97e0a1436..fa0f10750 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -1,7 +1,7 @@ #!/bin/bash # command info -if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then +if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then echo "# Turns the RaspiBlitz into HDD CopyStation Mode" echo "# lightning is deactivated during CopyStationMode" echo "# reboot RaspiBlitz to set back to normal mode" @@ -82,7 +82,7 @@ systemctl stop background 2>/dev/null if [ "${autoformat}" == "1" ]; then echo "setting RaspiBlitz LCD info" sudo sed -i "s/^state=.*/state=copystation/g" /home/admin/raspiblitz.info 2>/dev/null - sudo sed -i "s/^message=.*/message='Make sure target HDDs are not connected yet.\nContinue after 10 seconds ...'/g" /home/admin/raspiblitz.info 2>/dev/null + sudo sed -i "s/^message=.*/message='Disconnect target HDDs!'/g" /home/admin/raspiblitz.info 2>/dev/null sleep 10 else echo @@ -99,7 +99,7 @@ echo "$systemDrives" echo if [ "${autoformat}" == "1" ]; then - sudo sed -i "s/^message=.*/message='Connect now HDDs to sync ..'/g" /home/admin/raspiblitz.info 2>/dev/null + sudo sed -i "s/^message=.*/message='Connect now target HDDs ..'/g" /home/admin/raspiblitz.info 2>/dev/null sleep 5 fi @@ -238,6 +238,7 @@ Please temp lable device with: ${formatPartition} choice=$? else choice=0 + sudo sed -i "s/^message=.*/message='Formatting new HDD: ${formatPartition}'/g" /home/admin/raspiblitz.info 2>/dev/null fi # on cancel @@ -298,7 +299,7 @@ OK NO FORMAT - Please remove decive now. if [ "${autoformat}" == "1" ]; then - sudo sed -i "s/^message=.*/message='Ready & Synced HDDs:\n${synced}'/g" /home/admin/raspiblitz.info 2>/dev/null + sudo sed -i "s/^message=.*/message='Ready & Synced HDDs: ${synced}'/g" /home/admin/raspiblitz.info 2>/dev/null fi sleep 25 From 9587b1a3d84d6ce22fc464ed2938c05ef8557e46 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sat, 18 May 2019 22:33:49 +0200 Subject: [PATCH 03/17] Copystation fix Infoscreen --- home.admin/00infoLCD.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/home.admin/00infoLCD.sh b/home.admin/00infoLCD.sh index 99fdd553d..4bc0fc3a4 100755 --- a/home.admin/00infoLCD.sh +++ b/home.admin/00infoLCD.sh @@ -195,10 +195,9 @@ while : fi if [ "${state}" = "copystation" ]; then - l1="COPYSTATION MODE\n" - l2="${message}\n" - l3="reboot 4 back to normal" - dialog --backtitle "RaspiBlitz ${codeVersion} ${localip}" --infobox "$l1$l2$l3" 6 ${boxwidth} + l1="COPY STATION MODE\n" + l2="${message}" + dialog --backtitle "RaspiBlitz ${codeVersion} ${localip}" --infobox "$l1$l2" 6 56 sleep 2 continue fi From 5ebfc3aaae07c62364417e8592f4eb5f04f5cdaa Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sat, 18 May 2019 23:19:10 +0200 Subject: [PATCH 04/17] update copyStationScript --- home.admin/XXcopyStation.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index fa0f10750..02c42ee2e 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -21,7 +21,7 @@ pathTemplateHDD="/mnt/hdd/templateHDD" # 0 = ask before formatting/init new HDD # 1 = auto-formatting every new HDD that needs init -autoformat=1 +nointeraction=1 # override values if XXcopyStation.conf files exists # use when you run this outside RaspiBlitz @@ -79,7 +79,7 @@ systemctl stop lnd 2>/dev/null systemctl stop background 2>/dev/null -if [ "${autoformat}" == "1" ]; then +if [ "${nointeraction}" == "1" ]; then echo "setting RaspiBlitz LCD info" sudo sed -i "s/^state=.*/state=copystation/g" /home/admin/raspiblitz.info 2>/dev/null sudo sed -i "s/^message=.*/message='Disconnect target HDDs!'/g" /home/admin/raspiblitz.info 2>/dev/null @@ -98,7 +98,7 @@ echo "OK - the following drives detected as system drives:" echo "$systemDrives" echo -if [ "${autoformat}" == "1" ]; then +if [ "${nointeraction}" == "1" ]; then sudo sed -i "s/^message=.*/message='Connect now target HDDs ..'/g" /home/admin/raspiblitz.info 2>/dev/null sleep 5 fi @@ -140,6 +140,8 @@ do # sync bitcoin echo "Syncing Bitcoin ..." + sudo sed -i "s/^message=.*/message='Updating Template: Bitcoin/g" /home/admin/raspiblitz.info 2>/dev/null + # make sure the bitcoin directory in template folder exists if [ ! -d "$pathTemplateHDD/bitcoin" ]; then echo "creating the bitcoin subfolder in the template folder" @@ -154,6 +156,8 @@ do # sync bitcoin echo "Syncing Litecoin ..." + sudo sed -i "s/^message=.*/message='Updating Template: Litecoin/g" /home/admin/raspiblitz.info 2>/dev/null + # make sure the litecoin directory in template folder exists if [ ! -d "$pathTemplateHDD/litecoin" ]; then echo "creating the litecoin subfolder in the template folder" @@ -229,8 +233,8 @@ Please remove device now. " 10 46 else - # if config value "autoformat=1" default to format - if [ "${autoformat}" != "1" ]; then + # if config value "nointeraction=1" default to format + if [ "${nointeraction}" != "1" ]; then whiptail --title "Format HDD" --yes-button "Format" --no-button "Cancel" --yesno " Found new HDD. Do you want to FORMAT now? Please temp lable device with: ${formatPartition} @@ -273,6 +277,9 @@ OK NO FORMAT - Please remove decive now. # rsync device mountOK=$(lsblk -o NAME,MOUNTPOINT | grep "${detectedDrive}" | grep -c "/mnt/hdd2") if [ ${mountOK} -eq 1 ]; then + if [ "${nointeraction}" == "1" ]; then + sudo sed -i "s/^message=.*/message='Syncing from Template: ${partition}'/g" /home/admin/raspiblitz.info 2>/dev/null + fi rsync -a --info=progress2 ${pathTemplateHDD}/* /mnt/hdd2 chmod -r 777 /mnt/hdd2 echo "${partition} " >> ./.syncinfo.tmp @@ -298,7 +305,7 @@ OK NO FORMAT - Please remove decive now. echo "" - if [ "${autoformat}" == "1" ]; then + if [ "${nointeraction}" == "1" ]; then sudo sed -i "s/^message=.*/message='Ready & Synced HDDs: ${synced}'/g" /home/admin/raspiblitz.info 2>/dev/null fi From aec49a842bfcacb58fe97d2f3bd8a52c20da4bda Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sat, 18 May 2019 23:37:34 +0200 Subject: [PATCH 05/17] copystation exit after --- home.admin/XXcopyStation.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index 02c42ee2e..f67bc4e42 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -43,9 +43,11 @@ if [ "$1" != "-foreground" ]; then # start copystation in sreen echo "starting copystation screen session" screen -S copystation -dm /home/admin/XXcopyStation.sh -foreground + exit 0 else echo "changing into running copystation screen session" screen -S copystation + exit 0 fi fi From f400246482b2306a54ff7f4074af1cb6f53f87a5 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sat, 18 May 2019 23:43:29 +0200 Subject: [PATCH 06/17] copystation auto return --- home.admin/00raspiblitz.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index 5dd68ebe9..eea4f8564 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -75,6 +75,14 @@ if [ "${state}" = "retorrent" ]; then exit fi +# singal that copstation is running +if [ "${state}" = "copystation" ]; then + echo "Copy Station is Runnning ..." + echo "reboot to return to normal" + /home/admin/XXcopyStation.sh + exit +fi + # if pre-sync is running - stop it - before continue if [ "${state}" = "presync" ]; then # stopping the pre-sync From 00fe79e92e3d35e5e490190d5aa5c78d5a3ef7b5 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 19 May 2019 01:46:52 +0200 Subject: [PATCH 07/17] copystation fix screen sessions --- home.admin/XXcopyStation.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index f67bc4e42..6259e286e 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -42,11 +42,11 @@ if [ "$1" != "-foreground" ]; then if [ ${#screenPID} -eq 0 ]; then # start copystation in sreen echo "starting copystation screen session" - screen -S copystation -dm /home/admin/XXcopyStation.sh -foreground + screen -S copystation -dr /home/admin/XXcopyStation.sh -foreground exit 0 else echo "changing into running copystation screen session" - screen -S copystation + screen -d -r exit 0 fi fi @@ -85,7 +85,7 @@ if [ "${nointeraction}" == "1" ]; then echo "setting RaspiBlitz LCD info" sudo sed -i "s/^state=.*/state=copystation/g" /home/admin/raspiblitz.info 2>/dev/null sudo sed -i "s/^message=.*/message='Disconnect target HDDs!'/g" /home/admin/raspiblitz.info 2>/dev/null - sleep 10 + sleep 30 else echo echo "*** INIT HDD SCAN" From 0585c91f0aaca9eb22c25ec943f343162f5f1176 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 19 May 2019 02:06:34 +0200 Subject: [PATCH 08/17] copystation fix starting screen session --- home.admin/XXcopyStation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index 6259e286e..d2cd7d3a1 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -42,7 +42,7 @@ if [ "$1" != "-foreground" ]; then if [ ${#screenPID} -eq 0 ]; then # start copystation in sreen echo "starting copystation screen session" - screen -S copystation -dr /home/admin/XXcopyStation.sh -foreground + screen -S copystation -dR /home/admin/XXcopyStation.sh -foreground exit 0 else echo "changing into running copystation screen session" From 71f2aea3c69a57ac939224ad99f48766f2431238 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 19 May 2019 02:06:53 +0200 Subject: [PATCH 09/17] copystation fix starting screen session --- home.admin/XXcopyStation.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index d2cd7d3a1..30897e95c 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -42,7 +42,8 @@ if [ "$1" != "-foreground" ]; then if [ ${#screenPID} -eq 0 ]; then # start copystation in sreen echo "starting copystation screen session" - screen -S copystation -dR /home/admin/XXcopyStation.sh -foreground + screen -S copystation -dm /home/admin/XXcopyStation.sh -foreground + screen -d -r exit 0 else echo "changing into running copystation screen session" From 15dd44182eb1841a9095d55e9dc3f6c0f437139b Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 19 May 2019 02:11:42 +0200 Subject: [PATCH 10/17] copystation more console output --- home.admin/XXcopyStation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index 30897e95c..3ab5ad1f6 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -86,6 +86,7 @@ if [ "${nointeraction}" == "1" ]; then echo "setting RaspiBlitz LCD info" sudo sed -i "s/^state=.*/state=copystation/g" /home/admin/raspiblitz.info 2>/dev/null sudo sed -i "s/^message=.*/message='Disconnect target HDDs!'/g" /home/admin/raspiblitz.info 2>/dev/null + echo "Disconnect target HDDs! .. 30ses until continue." sleep 30 else echo @@ -307,7 +308,6 @@ OK NO FORMAT - Please remove decive now. echo "To stop copystation script: CTRL+c" echo "" - if [ "${nointeraction}" == "1" ]; then sudo sed -i "s/^message=.*/message='Ready & Synced HDDs: ${synced}'/g" /home/admin/raspiblitz.info 2>/dev/null fi From 4f499fc91a8bcfaa505d37e5e5864f32a23df635 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 19 May 2019 02:20:32 +0200 Subject: [PATCH 11/17] copystation fix autostart --- home.admin/00raspiblitz.sh | 2 +- home.admin/XXcopyStation.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index eea4f8564..fb5ade07e 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -79,7 +79,7 @@ fi if [ "${state}" = "copystation" ]; then echo "Copy Station is Runnning ..." echo "reboot to return to normal" - /home/admin/XXcopyStation.sh + sudo /home/admin/XXcopyStation.sh exit fi diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index 3ab5ad1f6..1157528a4 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -144,7 +144,7 @@ do # sync bitcoin echo "Syncing Bitcoin ..." - sudo sed -i "s/^message=.*/message='Updating Template: Bitcoin/g" /home/admin/raspiblitz.info 2>/dev/null + sudo sed -i "s/^message=.*/message='Updating Template: Bitcoin'/g" /home/admin/raspiblitz.info 2>/dev/null # make sure the bitcoin directory in template folder exists if [ ! -d "$pathTemplateHDD/bitcoin" ]; then @@ -160,7 +160,7 @@ do # sync bitcoin echo "Syncing Litecoin ..." - sudo sed -i "s/^message=.*/message='Updating Template: Litecoin/g" /home/admin/raspiblitz.info 2>/dev/null + sudo sed -i "s/^message=.*/message='Updating Template: Litecoin'/g" /home/admin/raspiblitz.info 2>/dev/null # make sure the litecoin directory in template folder exists if [ ! -d "$pathTemplateHDD/litecoin" ]; then From fd567d2f719495c5d31a9caada490bd0cbc89c4d Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 19 May 2019 02:25:06 +0200 Subject: [PATCH 12/17] copystation fix litecoin --- README.md | 4 ++++ home.admin/XXcopyStation.sh | 13 +++++-------- home.admin/config.scripts/blitz.datadrive.sh | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cc720a1fa..f833337de 100644 --- a/README.md +++ b/README.md @@ -446,6 +446,8 @@ The RTL Webinterface is a LND Control Dashboard you can run in your browser with ![RTL](pictures/RTL-dashboard.png) +Read an Intro-Tutorial to RTL: https://medium.com/@suheb.khan/how-to-ride-the-lightning-447af999dcd2 + Feedback is welcome by the RTL programmer: https://github.com/ShahanaFarooqui/RTL ##### LND Auto-Unlock @@ -477,6 +479,8 @@ and [Zeus (iOS/Android)](https://github.com/ZeusLN/zeus) are available. Please keep in mind that if you also want to connect to your smartphone also from the outside (when you are outside of your local network) with your RaspiBlitz you might need to open/forward ports on your router and should look into the DynamicDNS features to handle changeing IP of our Home-DSL. +This youtube video explains the "port forwarding" on your router in more detail: https://www.youtube.com/watch?v=KESo7hHXQtg + * [How do I shrink the QR code for connecting my Shango/Zap/Zeus mobile phone?](FAQ.md#how-do-i-shrink-the-qr-code-for-connecting-my-shangozap-mobile-phone) #### EXPORT: Macaroons and TLS.cert diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index 1157528a4..aa4187950 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -157,17 +157,14 @@ do if [ ! -d "${pathLitecoinBlockchain}" ]; then - # sync bitcoin + # sync litecoin echo "Syncing Litecoin ..." - sudo sed -i "s/^message=.*/message='Updating Template: Litecoin'/g" /home/admin/raspiblitz.info 2>/dev/null + echo "creating the litecoin subfolder in the template folder" + mkdir ${pathTemplateHDD}/litecoin 2>/dev/null + chmod 777 ${pathTemplateHDD}/litecoin 2>/dev/null - # make sure the litecoin directory in template folder exists - if [ ! -d "$pathTemplateHDD/litecoin" ]; then - echo "creating the litecoin subfolder in the template folder" - mkdir ${pathTemplateHDD}/litecoin - chmod 777 ${pathTemplateHDD}/litecoin - fi + sudo sed -i "s/^message=.*/message='Updating Template: Litecoin'/g" /home/admin/raspiblitz.info 2>/dev/null rsync -a --info=progress2 ${pathLitecoinBlockchain}/chainstate ${pathLitecoinBlockchain}/indexes ${pathLitecoinBlockchain}/blocks ${pathTemplateHDD}/litecoin diff --git a/home.admin/config.scripts/blitz.datadrive.sh b/home.admin/config.scripts/blitz.datadrive.sh index 2ef203b8e..b0709c6b6 100644 --- a/home.admin/config.scripts/blitz.datadrive.sh +++ b/home.admin/config.scripts/blitz.datadrive.sh @@ -105,7 +105,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then # mount the BTRFS drive echo "Mounting under /mnt/data ..." sudo mkdir -p /mnt/data - sudo mount /dev/${dev1} /mnt/data + sudo mount barrier=1 /dev/${dev1} /mnt/data echo "OK" echo "" From 82e0664f5f8623c88362964af126f66adbfafa20 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Sun, 19 May 2019 13:09:58 +0200 Subject: [PATCH 13/17] #615 adding more info on HDDs with partitions --- home.admin/30initHDD.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/home.admin/30initHDD.sh b/home.admin/30initHDD.sh index 5fbd5c2a2..379c33535 100755 --- a/home.admin/30initHDD.sh +++ b/home.admin/30initHDD.sh @@ -50,6 +50,8 @@ if [ ${existsHDD} -eq 1 ]; then echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "You HDD was detected with the size of ${isSize} bytes" echo "For ${network} at least ${minSize} bytes is recommended" + echo "If you know the HDD is bigger then detected, please" + echo "change HDD to 1 partition on another computer first," echo "If you want to change to a bigger HDD:" echo "* Unplug power of RaspiBlitz" echo "* Make a fresh SD card again" From 5696f3eb4bcf998a730b88a27052a2b4dc5728eb Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 20 May 2019 00:55:25 +0200 Subject: [PATCH 14/17] copystation small fixes --- home.admin/XXcopyStation.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index aa4187950..53cffafe0 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -25,7 +25,13 @@ nointeraction=1 # override values if XXcopyStation.conf files exists # use when you run this outside RaspiBlitz +# - clean Ubuntu install +# - install bitcoind as systemd service +# - disable automount: https://askubuntu.com/questions/89244/how-to-disable-automount-in-nautiluss-preferences#102601 +# - clone the github to get script (or download) +# - set your pathes bitcoin/template in conf file source ./XXcopyStation.conf 2>/dev/null +# -- start script with parameter "-foreground" ####### SCRIPT ############# @@ -155,7 +161,7 @@ do rsync -a --info=progress2 ${pathBitcoinBlockchain}/chainstate ${pathBitcoinBlockchain}/indexes ${pathBitcoinBlockchain}/blocks ${pathBitcoinBlockchain}/testnet3 ${pathTemplateHDD}/bitcoin - if [ ! -d "${pathLitecoinBlockchain}" ]; then + if [ -d "${pathLitecoinBlockchain}" ]; then # sync litecoin echo "Syncing Litecoin ..." @@ -305,9 +311,7 @@ OK NO FORMAT - Please remove decive now. echo "To stop copystation script: CTRL+c" echo "" - if [ "${nointeraction}" == "1" ]; then - sudo sed -i "s/^message=.*/message='Ready & Synced HDDs: ${synced}'/g" /home/admin/raspiblitz.info 2>/dev/null - fi + sudo sed -i "s/^message=.*/message='Ready & Synced HDDs: ${synced}'/g" /home/admin/raspiblitz.info 2>/dev/null sleep 25 From 0bb19b07661f045455bebbbac6d9573c91af1ae8 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 20 May 2019 01:05:57 +0200 Subject: [PATCH 15/17] copystation small fixes --- home.admin/XXcopyStation.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index 53cffafe0..acd3cebec 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -289,6 +289,7 @@ OK NO FORMAT - Please remove decive now. fi rsync -a --info=progress2 ${pathTemplateHDD}/* /mnt/hdd2 chmod -r 777 /mnt/hdd2 + rm -r /mnt/hdd2/lost+found 2>/dev/null echo "${partition} " >> ./.syncinfo.tmp else echo "FAIL: was not able to mount --> ${partition}" From 82d9bb54edf7e2d191ce88c7b57e09be77195e93 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 20 May 2019 15:21:24 +0200 Subject: [PATCH 16/17] copystation fixing LCD message --- home.admin/XXcopyStation.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home.admin/XXcopyStation.sh b/home.admin/XXcopyStation.sh index acd3cebec..ca7357b1f 100755 --- a/home.admin/XXcopyStation.sh +++ b/home.admin/XXcopyStation.sh @@ -312,7 +312,7 @@ OK NO FORMAT - Please remove decive now. echo "To stop copystation script: CTRL+c" echo "" - sudo sed -i "s/^message=.*/message='Ready & Synced HDDs: ${synced}'/g" /home/admin/raspiblitz.info 2>/dev/null + sudo sed -i "s/^message=.*/message='Ready HDDs: ${synced}'/g" /home/admin/raspiblitz.info 2>/dev/null sleep 25 From 181e1cc51d823870687f5066b8b4cfd3ae433eec Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Mon, 27 May 2019 20:31:19 +0200 Subject: [PATCH 17/17] added copystation info --- WORKSHOP.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/WORKSHOP.md b/WORKSHOP.md index 9efc376ec..4b207e3b3 100644 --- a/WORKSHOP.md +++ b/WORKSHOP.md @@ -133,7 +133,7 @@ Basically you follow the assemble instructions on the RaspiBlitz GuitHUb README. ## Prepare HDDs with Blockchain Data -This is the most time consuming part of the preparation. Try it once to get a feel for how much time you need to prepare one HDD. +This is the most time consuming part of the preparation. Try it once to get a feel for how much time you need to prepare one HDD. If you prepare more then one HDD check out the "Copystation" script below. A prepared HDD is formatted in EXT4 and named "BLOCKCHAIN". In folder called `bitcoin` it contains a copy of the following data folders from a running Bitcoin core client (same version on RaspiBlitz). @@ -159,6 +159,20 @@ Once you have that "template" you can make a image from that and write that imag ## Prepare Blockchain Copy Station +In the RaspiBlitz Github repo and also on every RaspiBlitz (since v1.3) you can find the script: +`/home/admin/CCcopyStation.sh` + +This can be used to prepare and keep multiple HDDs in snyc with blockchain data in preparation of a workshop. You can start it directly on a RaspiBlitz and turn it into "Copy Station Mode" with executing on the command line: + +`sudo /home/admin/CCcopyStation.sh` + +*Beware that it will not run as a Lightning Node during that time (LND is stopped). And to reset it back into normal mode you need to stop the script with `CTLR+c` and the reboot with `sudo shutdown -r now`.* + +In "COpy Station Mode" the RaspiBlitz will just run the bitcoind (so it needs network connection), copy fresh blockchain data over to a template folder on the HDD called `/mnt/hdd/templateHDD` and from there syncs it to further HDDs that get connected to it. + +If you run it in a setup lke on this photo with an extra powered USB hub, you can connect up to 10 HDDs at once to be synced with an almost up-to-date blockchain. + + At the moment the "Blockchain Copy Station" is just a computer (laptop - not a RaspberryPi) having a image of a "template" HDD (see above) and you can attach (with a USB3.0 Hub) multiple fresh HHDs to it and start writing in the template image to that. To update the "template" HDD for the next workshop use it for a fresh clean RaspiBllitz setup just days before, sync the blockchain to 100% and repeat the process above.