From a62fdd4ee50a56eab2b3ba4c7f660390c938977b Mon Sep 17 00:00:00 2001
From: Tudor Georgescu <T.Georgescu@kainos.com>
Date: Mon, 23 Jan 2017 15:27:42 +0000
Subject: [PATCH] Don't ask for mailcow hostname and time zone if already
 exported within the shell

---
 generate_config.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/generate_config.sh b/generate_config.sh
index cb1a516e..5ae9495d 100755
--- a/generate_config.sh
+++ b/generate_config.sh
@@ -12,8 +12,13 @@ if [[ -f mailcow.conf ]]; then
   esac
 fi
 
-read -p "Hostname (FQDN): " -ei "mx.example.org" MAILCOW_HOSTNAME
-read -p "Timezone: " -ei "Europe/Berlin" TZ
+if [ -z "$MAILCOW_HOSTNAME" ]; then
+  read -p "Hostname (FQDN): " -ei "mx.example.org" MAILCOW_HOSTNAME
+fi
+
+if [ -z "$TZ" ]; then
+  read -p "Timezone: " -ei "Europe/Berlin" TZ
+fi
 
 cat << EOF > mailcow.conf
 # ------------------------------