From fb957d2de74517d28dc062a29d9d14eeba969d47 Mon Sep 17 00:00:00 2001 From: Michael Kropat Date: Sun, 8 Jun 2014 18:44:08 -0400 Subject: [PATCH] Populate default values before echoing help text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Testing showed that it may take a few seconds for the default values to populate. If the help text is shown, “Enter the public IP address…,” but no prompt is shown, the user may get confused and try to enter the IP address before mailinabox has had a chance to figure out and display a suitable default value. --- setup/start.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/setup/start.sh b/setup/start.sh index 6cda9561..301adead 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -24,6 +24,11 @@ fi # Gather information from the user about the hostname and public IP # address of this host. if [ -z "$PUBLIC_HOSTNAME" ]; then + if [ -z "$DEFAULT_PUBLIC_HOSTNAME" ]; then + # set a default on first run + DEFAULT_PUBLIC_HOSTNAME=`get_default_hostname` + fi + echo echo "Enter the hostname you want to assign to this machine." echo "We've guessed a value. Just backspace it if it's wrong." @@ -31,39 +36,34 @@ if [ -z "$PUBLIC_HOSTNAME" ]; then echo "be similar." echo - if [ -z "$DEFAULT_PUBLIC_HOSTNAME" ]; then - # set a default on first run - DEFAULT_PUBLIC_HOSTNAME=`get_default_hostname` - fi - read -e -i "$DEFAULT_PUBLIC_HOSTNAME" -p "Hostname: " PUBLIC_HOSTNAME fi if [ -z "$PUBLIC_IP" ]; then + if [ -z "$DEFAULT_PUBLIC_IP" ]; then + # set a default on first run + DEFAULT_PUBLIC_IP=`get_default_publicip` + fi + echo echo "Enter the public IP address of this machine, as given to" echo "you by your ISP. We've guessed a value, but just backspace" echo "it if it's wrong." echo - if [ -z "$DEFAULT_PUBLIC_IP" ]; then - # set a default on first run - DEFAULT_PUBLIC_IP=`get_default_publicip` - fi - read -e -i "$DEFAULT_PUBLIC_IP" -p "Public IP: " PUBLIC_IP fi if [ -z "$PUBLIC_IPV6" ]; then - echo - echo "(Optional) Enter the IPv6 address of this machine. Leave blank" - echo " if the machine does not have an IPv6 address." - - if [ -z "$DEFAULT_PUBLIC_IPV6" ]; then + if [ -z "$DEFAULT_PUBLIC_IPV6" ]; then # set a default on first run DEFAULT_PUBLIC_IPV6=`get_default_publicipv6` fi + echo + echo "(Optional) Enter the IPv6 address of this machine. Leave blank" + echo " if the machine does not have an IPv6 address." + read -e -i "$DEFAULT_PUBLIC_IPV6" -p "Public IPv6: " PUBLIC_IPV6 fi