From 5de704c7c58acf9411b03404fe4e95a1b4e44fcc Mon Sep 17 00:00:00 2001 From: rootzoll Date: Tue, 27 Nov 2018 14:47:12 +0100 Subject: [PATCH] more simple state management on admin login --- home.admin/00mainMenu.sh | 40 +++++++--------------------------------- home.admin/_bootstrap.sh | 7 +++++++ 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index ea77c9ced..533bb321c 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -14,6 +14,8 @@ if [ ${bootstrapInfoExists} -eq 1 ]; then if [ "${state}" = "presync" ]; then echo "TODO: Stop pre-sync ... press key to continue" read key + # unmount the temporary mount + sudo umount -l /mnt/hdd # update info file state=waitsetup echo "state=waitsetup" > $infoFile @@ -21,39 +23,11 @@ if [ ${bootstrapInfoExists} -eq 1 ]; then echo "device=${device}" >> $infoFile fi - # wait until boostrap process is done - keepWaiting=1 - while [ ${keepWaiting} -eq 1 ] - do - - # 1) when bootstrap on configured device - if [ "${state}" = "ready" ]; then - echo "detected bootstrap ready" - keepWaiting=0 - - # 2) when bootstrap on a fresh sd card - elif [ "${state}" = "waitsetup" ]; then - echo "detected bootstrap waitinmg for setup" - - # unmount the temporary mount - sudo umount -l /mnt/hdd - - # update info file - that setup started - echo "state=setup" > $infoFile - echo "message='SetUp Started'" >> $infoFile - echo "device=${device}" >> $infoFile - keepWaiting=0 - - # 3) when bootstap is still running - else - # wait 2 sevs and check again - echo "bootstrap still running - state(${state}) message(${message})" - echo "please wait, act or CTRL+c --> Exit to terminal" - sleep 2 - keepWaiting=1 - fi - - done + # signal if bootstrap is not ready yet + if [ "${state}" = "recovering" ]; then + echo "WARNING: bootstrap is still updating - please close SSH and login later again" + exit 1 + fi fi diff --git a/home.admin/_bootstrap.sh b/home.admin/_bootstrap.sh index d44cdffb5..c11d2e64d 100644 --- a/home.admin/_bootstrap.sh +++ b/home.admin/_bootstrap.sh @@ -134,6 +134,7 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then echo "state=waitsetup" > $infoFile echo "message='HDD failed Mounting'" >> $infoFile echo "device=${hddDeviceName}" >> $infoFile + # no need to unmount the HDD, it failed mounting exit 1 else echo "OK - HDD available under /mnt/hdd" >> $logFile @@ -148,6 +149,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then echo "state=recovering" > $infoFile echo "message='TODO: migration and recover'" >> $infoFile echo "device=${hddDeviceName}" >> $infoFile + # unmountig the HDD at the end of the process + sudo umount -l /mnt/hdd exit 1 else echo "OK - No config file found: ${configFile}" >> $logFile @@ -161,6 +164,7 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then echo "state=olddata" > $infoFile echo "message='No Auto-Update possible'" >> $infoFile echo "device=${hddDeviceName}" >> $infoFile + # keep HDD mounted if user wants to copy data exit 1 else echo "OK - No LND data found" >> $logFile @@ -175,6 +179,7 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then echo "state=presync" > $infoFile echo "message='TODO: start pre-sync'" >> $infoFile echo "device=${hddDeviceName}" >> $infoFile + # after admin login, presync will be stoped and HDD unmounted exit 1 else ls /mnt/hdd/bitcoin/blocks/blk00000.dat >> $logFile @@ -186,6 +191,8 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then echo "state=waitsetup" > $infoFile echo "message='HDD needs SetUp (2)'" >> $infoFile echo "device=${hddDeviceName}" >> $infoFile + # unmount HDD to be ready for auto-mount during setup + sudo umount -l /mnt/hdd exit 1 fi