From bb7905aefdcfcfd5bb565b08d1c9a16cb0058669 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Tue, 3 Jun 2014 21:31:13 +0000 Subject: [PATCH] on second and later runs of start.sh, recall the inputs the user entered the last time --- setup/start.sh | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/setup/start.sh b/setup/start.sh index e86ea890..aedc2c6f 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -13,6 +13,11 @@ if [ "`lsb_release -d | sed 's/.*:\s*//'`" != "Ubuntu 14.04 LTS" ]; then exit fi +# Recall the last settings used if we're running this a second time. +if [ -f /etc/mailinabox.conf ]; then + cat /etc/mailinabox.conf | sed s/^/DEFAULT_/ > /tmp/mailinabox.prev.conf + source /tmp/mailinabox.prev.conf +fi # Gather information from the user about the hostname and public IP # address of this host. @@ -23,7 +28,13 @@ if [ -z "$PUBLIC_HOSTNAME" ]; then echo "Josh uses box.occams.info as his hostname. Yours should" echo "be similar." echo - read -e -i "`hostname`" -p "Hostname: " PUBLIC_HOSTNAME + + if [ -z "$DEFAULT_PUBLIC_HOSTNAME" ]; then + # set a default on first run + DEFAULT_PUBLIC_HOSTNAME=`hostname` + fi + + read -e -i "$DEFAULT_PUBLIC_HOSTNAME" -p "Hostname: " PUBLIC_HOSTNAME fi if [ -z "$PUBLIC_IP" ]; then @@ -32,7 +43,13 @@ if [ -z "$PUBLIC_IP" ]; then echo "you by your ISP. We've guessed a value, but just backspace" echo "it if it's wrong." echo - read -e -i "`hostname -i`" -p "Public IP: " PUBLIC_IP + + if [ -z "$DEFAULT_PUBLIC_IP" ]; then + # set a default on first run + DEFAULT_PUBLIC_IP=`hostname -i` + fi + + read -e -i "$DEFAULT_PUBLIC_IP" -p "Public IP: " PUBLIC_IP fi if [ -z "$CSR_COUNTRY" ]; then @@ -41,7 +58,13 @@ if [ -z "$CSR_COUNTRY" ]; then echo "live or where your organization is based. (This is used to" echo "create an SSL certificate.)" echo - read -e -p "Country Code: " CSR_COUNTRY + + #if [ -z "$DEFAULT_CSR_COUNTRY" ]; then + # # set a default on first run + # DEFAULT_CSR_COUNTRY=...? + #fi + + read -e -i "$DEFAULT_CSR_COUNTRY" -p "Country Code: " CSR_COUNTRY fi # Create the user named "user-data" and store all persistent user