From 8f6d21ad5c50cf9984a437a3560ed5bdfbb9bb25 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Thu, 18 Oct 2018 14:00:51 +0100
Subject: [PATCH] Creating scuttlebot invites

---
 src/freedombone-app-scuttlebot | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/freedombone-app-scuttlebot b/src/freedombone-app-scuttlebot
index 32a52fd6a..1b64b6a45 100755
--- a/src/freedombone-app-scuttlebot
+++ b/src/freedombone-app-scuttlebot
@@ -54,11 +54,19 @@ function logging_off_scuttlebot {
     echo -n ''
 }
 
-function scuttlebot_create_invite {
+function scuttlebot_create_single_invite {
     invite_string=$(su -c "/etc/scuttlebot/node_modules/.bin/sbot invite.create 1" - scuttlebot | sed 's/"//g')
+    if [ ! "$invite_string" ]; then
+        echo $'Unable to create scuttlebot invite'
+        exit 36583568
+    fi
+    write_config_param SCUTTLEBOT_INVITE "$invite_string"
+}
 
+function scuttlebot_create_invite {
+    scuttlebot_create_single_invite
     clear
-    echo -e "\\n\\nYour Scuttlebot invite code is:\\n\\n${invite_string}\\n\\n"
+    echo -e "\\n\\nYour Scuttlebot invite code is:\\n\\n${SCUTTLEBOT_INVITE}\\n\\n"
     # shellcheck disable=SC2034
     read -n1 -r -p $"Press any key to continue..." key
 }
@@ -360,6 +368,8 @@ EOF
 
     firewall_add scuttlebot ${SCUTTLEBOT_PORT}
 
+    scuttlebot_create_single_invite
+
     if ! grep -q "scuttlebot version:" "${COMPLETION_FILE}"; then
         echo "scuttlebot version:${SCUTTLEBOT_VERSION}" >> "${COMPLETION_FILE}"
     else
-- 
GitLab