From 580f2293339f45ee01cd39a3335e6983ed985f6a Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Mon, 12 Feb 2018 10:52:20 +0000
Subject: [PATCH] More retries

---
 src/freedombone-app-bdsmail | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/freedombone-app-bdsmail b/src/freedombone-app-bdsmail
index 541228629..5b618eff1 100755
--- a/src/freedombone-app-bdsmail
+++ b/src/freedombone-app-bdsmail
@@ -255,21 +255,26 @@ function install_bdsmail {
     chmod +x /usr/bin/bdsmail_domain
 
     # wait for domain to be generated by the daemon
-    echo $'Waiting for i2p domain to be generated...'
-    sleep 15
-    bds_domain=$(bdsmail_domain)
-    if [ ! $bds_domain ]; then
-        echo $'Waiting...'
+    # This can take a while, probably because i2p is connecting
+    bds_domain=
+    sleep_ctr=0
+    while [ ! $bds_domain ]; do
+        echo $"Waiting for i2p domain to be generated ${sleep_ctr}/30"
         systemctl restart bdsmail
-        sleep 15
+        sleep 10
         bds_domain=$(bdsmail_domain)
-        if [ ! $bds_domain ]; then
-            #systemctl stop bdsmail
-            #systemctl disable bdsmail
-            #remove_i2p
-            echo $'Failed to get the bdsmail domain'
-            exit 8934638
+        sleep_ctr=$((sleep_ctr + 1))
+        if [ $sleep_ctr -gt 30 ]; then
+            break
         fi
+    done
+
+    if [ ! $bds_domain ]; then
+        #systemctl stop bdsmail
+        #systemctl disable bdsmail
+        #remove_i2p
+        echo $'Failed to get the bdsmail domain'
+        exit 8934638
     fi
 
     # Create mutt configuration
-- 
GitLab