From 3063a97a2cc63634af25cce34aa8776910d26427 Mon Sep 17 00:00:00 2001 From: Jay Pfaffman Date: Wed, 27 Jan 2021 10:30:15 -0800 Subject: [PATCH] FIX: discourse-setup MAXMIND works correctly Ouch. This was worse than I thought. Things fixed: - consistent formatting (mostly that after `then` was indented by 4, not 2) - fail if `DISCOURSE_MAXMIND_LICENSE_KEY` is not added to $web_file - detect if `web_only.yml` exists - stop `web_only` if it exists rather than non-existing `app` (but why is it stopping it anyway?) - don't try to `assert_maxmind_license_key` before `app.yml` exists --- discourse-setup | 248 +++++++++++++++++++++++++----------------------- 1 file changed, 130 insertions(+), 118 deletions(-) diff --git a/discourse-setup b/discourse-setup index 47d4386..75094e2 100755 --- a/discourse-setup +++ b/discourse-setup @@ -26,9 +26,9 @@ connect_to_port () { while true; do read -p "Would you like to continue without this check? [yn] " yn case $yn in - [Yy]*) return 2 ;; - [Nn]*) exit ;; - *) echo "Please answer y or n." ;; + [Yy]*) return 2 ;; + [Nn]*) exit ;; + *) echo "Please answer y or n." ;; esac done else @@ -185,7 +185,6 @@ check_disk_and_memory() { fi fi - free_disk="$(df /var | tail -n 1 | awk '{print $4}')" if [ "$free_disk" -lt 5000 ]; then echo "WARNING: Discourse requires at least 5GB free disk space. This system" @@ -256,8 +255,8 @@ scale_ram_and_cpu() { sed -i -e "s/^ #\?UNICORN_WORKERS:.*/ UNICORN_WORKERS: ${unicorn_workers}/w $changelog" $web_file if [ -s $changelog ] then - echo "setting UNICORN_WORKERS = ${unicorn_workers}" - rm $changelog + echo "setting UNICORN_WORKERS = ${unicorn_workers}" + rm $changelog fi echo $data_file memory parameters updated. @@ -268,9 +267,9 @@ scale_ram_and_cpu() { ## standard http / https ports must not be occupied ## check_ports() { - check_port "80" - check_port "443" - echo "Ports 80 and 443 are free for use" + check_port "80" + check_port "443" + echo "Ports 80 and 443 are free for use" } @@ -317,11 +316,24 @@ read_default() { } assert_maxmind_license_key() { - if ! grep DISCOURSE_MAXMIND_LICENSE_KEY $web_file + if ! grep DISCOURSE_MAXMIND_LICENSE_KEY $web_file >/dev/null 2>&1 then echo "Adding MAXMIND placeholder to $web_file" sed -i '/^.*LETSENCRYPT_ACCOUNT_EMAIL.*/a \ \ #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456' $web_file fi + if ! grep DISCOURSE_MAXMIND_LICENSE_KEY $web_file >/dev/null 2>&1 + then + cat <