Revert "Remove nginx-common package"
[discourse_docker.git] / discourse-setup
index 205d4a0fb1ae5ba351365e7771f24e489f3118ca..2b86fca40617256e3e5d61c87cb6528c8e7ac684 100755 (executable)
@@ -68,11 +68,9 @@ check_IP_match() {
       echo
       echo Google: \"open ports YOUR CLOUD SERVICE\" for information for resolving this problem.
       echo
-      echo You should probably answer \"n\" at the next prompt and disable Let\'s Encrypt.
-      echo
-      echo This test might not work for all situations,
-      echo "so if you can access Discourse at http://$HOST, you might try anyway."
-      sleep 3
+      echo If you want to proceed anyway, you will need to
+      echo edit the containers/app.yml file manually.
+      exit 1
       ;;
     2)
       echo "Continuing without port check."
@@ -114,7 +112,15 @@ check_osx_memory() {
 ## Linux available memory
 ##
 check_linux_memory() {
-  echo `free -g --si | awk ' /Mem:/  {print $2} '`
+  ## some VMs report just under 1GB of RAM, so
+  ## make an exception and allow those with more
+  ## than 989MB
+  mem=`free -m --si | awk ' /Mem:/ {print $2}'`
+  if [ "$mem" -ge 990 -a "$mem" -lt 1000 ]; then
+    echo 1
+  else
+    echo `free -g --si | awk ' /Mem:/  {print $2} '`
+  fi
 }
 
 ##
@@ -366,6 +372,8 @@ ask_user_for_config() {
       fi
     fi
 
+    check_IP_match $hostname
+
     if [ ! -z "$developer_emails" ]
     then
       read -p "Email address for admin account(s)? [$developer_emails]: " new_value
@@ -429,7 +437,7 @@ ask_user_for_config() {
 
     if [ ! -z $letsencrypt_account_email ]
     then
-      read -p "Optional email address for setting up Let's Encrypt? ($letsencrypt_status) [$letsencrypt_account_email]: " new_value
+      read -p "Optional email address for Let's Encrypt warnings? ($letsencrypt_status) [$letsencrypt_account_email]: " new_value
       if [ ! -z "$new_value" ]
       then
           letsencrypt_account_email="$new_value"
@@ -442,11 +450,6 @@ ask_user_for_config() {
       fi
     fi
 
-    if [ "$letsencrypt_status" == "Enter 'OFF' to disable." ]
-    then
-       check_IP_match $hostname
-    fi
-
     echo -e "\nDoes this look right?\n"
     echo "Hostname      : $hostname"
     echo "Email         : $developer_emails"
@@ -551,57 +554,37 @@ ask_user_for_config() {
       update_ok="n"
     fi
   fi
-  if [ "$letsencrypt_status" = "ENTER to skip" ]
-  then
-      local src='^  #\?- "templates\/web.ssl.template.yml"'
-      local dst='  #\- "templates\/web.ssl.template.yml"'
-      sed -i -e "s/$src/$dst/w $changelog" $web_file
-      if [ ! -s $changelog ]
-      then
-        update_ok="n"
-        echo "web.ssl.template.yml NOT DISABLED--Are you using a non-standard template?"
-      fi
-      local src='^  #\?- "templates\/web.letsencrypt.ssl.template.yml"'
-      local dst='  #- "templates\/web.letsencrypt.ssl.template.yml"'
 
-      sed -i -e "s/$src/$dst/w $changelog" $web_file
-      if [ ! -s $changelog ]
-      then
-        update_ok="n"
-        echo "web.ssl.template.yml NOT DISABLED--Are you using a non-standard template?"
-      fi
-  else # enable let's encrypt
-    echo "Let's Encrypt will be enabled for $letsencrypt_account_email"
-      sed -i -e "s/^  #\?LETSENCRYPT_ACCOUNT_EMAIL:.*/  LETSENCRYPT_ACCOUNT_EMAIL: $letsencrypt_account_email/w $changelog" $web_file
-      if [ -s $changelog ]
-      then
-        rm $changelog
-      else
-        echo "LETSENCRYPT_ACCOUNT_EMAIL change failed."
-        update_ok="n"
-      fi
-      local src='^  #\?- "templates\/web.ssl.template.yml"'
-      local dst='  \- "templates\/web.ssl.template.yml"'
-      sed -i -e "s/$src/$dst/w $changelog" $web_file
-      if [ -s $changelog ]
-      then
-         echo "web.ssl.template.yml enabled"
-      else
-        update_ok="n"
-        echo "web.ssl.template.yml NOT ENABLED--was it on already?"
-      fi
-      local src='^  #\?- "templates\/web.letsencrypt.ssl.template.yml"'
-      local dst='  - "templates\/web.letsencrypt.ssl.template.yml"'
+  echo "Enabling Let's Encrypt"
+    sed -i -e "s/^  #\?LETSENCRYPT_ACCOUNT_EMAIL:.*/  LETSENCRYPT_ACCOUNT_EMAIL: $letsencrypt_account_email/w $changelog" $web_file
+    if [ -s $changelog ]
+    then
+      rm $changelog
+    else
+      echo "LETSENCRYPT_ACCOUNT_EMAIL change failed."
+      update_ok="n"
+    fi
+    local src='^  #\?- "templates\/web.ssl.template.yml"'
+    local dst='  \- "templates\/web.ssl.template.yml"'
+    sed -i -e "s/$src/$dst/w $changelog" $web_file
+    if [ -s $changelog ]
+    then
+  echo "web.ssl.template.yml enabled"
+    else
+      update_ok="n"
+      echo "web.ssl.template.yml NOT ENABLED--was it on already?"
+    fi
+    local src='^  #\?- "templates\/web.letsencrypt.ssl.template.yml"'
+    local dst='  - "templates\/web.letsencrypt.ssl.template.yml"'
 
-      sed -i -e "s/$src/$dst/w $changelog" $web_file
-      if [ -s $changelog ]
-      then
-             echo "letsencrypt.ssl.template.yml enabled"
-      else
-        update_ok="n"
-        echo "letsencrypt.ssl.template.yml NOT ENABLED -- was it on already?"
-      fi
-  fi
+    sed -i -e "s/$src/$dst/w $changelog" $web_file
+    if [ -s $changelog ]
+    then
+      echo "letsencrypt.ssl.template.yml enabled"
+    else
+      update_ok="n"
+      echo "letsencrypt.ssl.template.yml NOT ENABLED -- was it on already?"
+    fi
 
   if [ "$update_ok" == "y" ]
   then