From ae6528d1de95474f947212774023e8126e25c3cd Mon Sep 17 00:00:00 2001
From: Robert Martin-Legene <robert@nic.ar>
Date: Mon, 30 Sep 2019 13:53:02 -0300
Subject: [PATCH] Avoiding a loop

---
 bin/generate-genesis-block.sh | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/bin/generate-genesis-block.sh b/bin/generate-genesis-block.sh
index a437fc2..1db5996 100755
--- a/bin/generate-genesis-block.sh
+++ b/bin/generate-genesis-block.sh
@@ -1,12 +1,17 @@
 #!/bin/bash
 # Robert Martin-Legene <robert@nic.ar>
 
-if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
-source ${BFAHOME}/bin/libbfa.sh || exit 1
-
-if [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ]
+# Don't let us call ourselves
+if [ -n "$LOOPCONTROL_GENESISCREATE" ]
 then
-    echo "Node is not initialised. Initialising with genesis."
-    geth --cache 0 --datadir "${BFANODEDIR}" --networkid ${BFANETWORKID} init "${BFANETWORKDIR}/genesis.json"
-fi
+    export LOOPCONTROL_GENESISCREATE=1
+    if [ -z "${BFAHOME}" ]; then echo "\$BFAHOME not set. Did you source bfa/bin/env ?" >&2; exit 1; fi
+    source ${BFAHOME}/bin/libbfa.sh || exit 1
 
+    if [ ! -d "${BFANODEDIR}" -o ! -d "${BFANODEDIR}/geth/chaindata" ]
+    then
+        echo "Node is not initialised. Initialising with genesis."
+        geth --cache 0 --datadir "${BFANODEDIR}" --networkid ${BFANETWORKID} init "${BFANETWORKDIR}/genesis.json"
+    fi
+fi
+unset LOOPCONTROL_GENESISCREATE
-- 
GitLab