From 34322fd1692fa9e22e1ff5117eb8a97602bdb59f Mon Sep 17 00:00:00 2001 From: rootzoll Date: Tue, 27 Nov 2018 16:31:39 +0100 Subject: [PATCH] start presync in background --- home.admin/_bootstrap.presync.sh | 33 ++++++++++++++++++++++++++++++++ home.admin/_bootstrap.sh | 18 ++++------------- 2 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 home.admin/_bootstrap.presync.sh diff --git a/home.admin/_bootstrap.presync.sh b/home.admin/_bootstrap.presync.sh new file mode 100644 index 0000000..bebc1c3 --- /dev/null +++ b/home.admin/_bootstrap.presync.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# This script runs on every start calles by boostrap.service +# It makes sure that the system is configured like the +# default values or as in the config. +# For more details see background_raspiblitzSettings.md + +# LOGFILE - store debug logs of bootstrap +# resets on every start +logFile="/home/admin/raspiblitz.log" + +# INFOFILE - state data from bootstrap +# used by display and later setup steps +infoFile="/home/admin/raspiblitz.info" + +echo "presync: waiting 2 secs" >> $logFile +sleep 2 + +echo "presync: copying files" >> $logFile +sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf +sudo cp /home/admin/assets/bitcoind.service /etc/systemd/system/bitcoind.service +sudo chmod +x /etc/systemd/system/bitcoind.service +sudo ln -s /mnt/hdd/bitcoin /home/bitcoin/.bitcoin +echo "presync: starting services" >> $logFile +sudo systemctl daemon-reload +sudo systemctl enable bitcoind.service +sudo systemctl start bitcoind.service +echo "presync: started" >> $logFile + +# update info file +echo "state=presync" > $infoFile +echo "message='started pre-sync'" >> $infoFile +echo "device=${hddDeviceName}" >> $infoFile diff --git a/home.admin/_bootstrap.sh b/home.admin/_bootstrap.sh index 9f29d29..a89c3f6 100644 --- a/home.admin/_bootstrap.sh +++ b/home.admin/_bootstrap.sh @@ -183,20 +183,10 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then # activating presync # so that on a hackathon you can just connect a RaspiBlitz # to the network and have it up-to-date for setting up - echo "Found pre-loaded blockchain - starting pre-sync" >> $logFile - sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf - sudo cp /home/admin/assets/bitcoind.service /etc/systemd/system/bitcoind.service - sudo chmod +x /etc/systemd/system/bitcoind.service - sudo ln -s /mnt/hdd/bitcoin /home/bitcoin/.bitcoin - echo "pre-sync: starting services" >> $logFile - sudo systemctl enable bitcoind.service - sudo systemctl start bitcoind.service - echo "pre-sync: started" >> $logFile - - # update info file - echo "state=presync" > $infoFile - echo "message='started pre-sync'" >> $infoFile - echo "device=${hddDeviceName}" >> $infoFile + echo "Found pre-loaded blockchain - starting pre-sync in background" >> $logFile + # starting in background, because this scripts is part of systemd + # so to change systemd needs to happen after delay in seperate process + sudo /home/admin/_bootstrap.presync.sh 2>/home/admin/_bootstrap.presync.error & # after admin login, presync will be stoped and HDD unmounted exit 1