fix old awk, better error check, fix data.yml for 2container

This commit is contained in:
Jay Pfaffman 2018-04-13 05:57:27 -07:00
parent 275735af30
commit 04a06dd05e
2 changed files with 23 additions and 16 deletions

View File

@ -276,11 +276,15 @@ check_port() {
## ##
read_config() { read_config() {
config_line=`egrep "^ #?$1:" $web_file` config_line=`egrep "^ #?$1:" $web_file`
read_config_result=`echo $config_line | awk --field-separator=":" '{print $2}'` read_config_result=`echo $config_line | awk -F":" '{print $2}'`
read_config_result=`echo $read_config_result | sed "s/^\([\"']\)\(.*\)\1\$/\2/g"` read_config_result=`echo $read_config_result | sed "s/^\([\"']\)\(.*\)\1\$/\2/g"`
} }
read_default() {
config_line=`egrep "^ #?$1:" samples/standalone.yml`
read_default_result=`echo $config_line | awk -F":" '{print $2}'`
read_default_result=`echo $read_config_result | sed "s/^\([\"']\)\(.*\)\1\$/\2/g"`
}
## ##
## prompt user for typical Discourse config file values ## prompt user for typical Discourse config file values
@ -329,7 +333,7 @@ ask_user_for_config() {
while [[ "$config_ok" == "n" ]] while [[ "$config_ok" == "n" ]]
do do
if [ ! -z $hostname ] if [ ! -z "$hostname" ]
then then
read -p "Hostname for your Discourse? [$hostname]: " new_value read -p "Hostname for your Discourse? [$hostname]: " new_value
if [ ! -z "$new_value" ] if [ ! -z "$new_value" ]
@ -345,7 +349,7 @@ ask_user_for_config() {
fi fi
fi fi
if [ ! -z $developer_emails ] if [ ! -z "$developer_emails" ]
then then
read -p "Email address for admin account(s)? [$developer_emails]: " new_value read -p "Email address for admin account(s)? [$developer_emails]: " new_value
if [ ! -z "$new_value" ] if [ ! -z "$new_value" ]
@ -354,7 +358,7 @@ ask_user_for_config() {
fi fi
fi fi
if [ ! -z $smtp_address ] if [ ! -z "$smtp_address" ]
then then
read -p "SMTP server address? [$smtp_address]: " new_value read -p "SMTP server address? [$smtp_address]: " new_value
if [ ! -z "$new_value" ] if [ ! -z "$new_value" ]
@ -363,7 +367,7 @@ ask_user_for_config() {
fi fi
fi fi
if [ ! -z $smtp_port ] if [ ! -z "$smtp_port" ]
then then
read -p "SMTP port? [$smtp_port]: " new_value read -p "SMTP port? [$smtp_port]: " new_value
if [ ! -z "$new_value" ] if [ ! -z "$new_value" ]
@ -602,21 +606,22 @@ validate_config() {
for x in DISCOURSE_SMTP_ADDRESS DISCOURSE_SMTP_USER_NAME DISCOURSE_SMTP_PASSWORD \ for x in DISCOURSE_SMTP_ADDRESS DISCOURSE_SMTP_USER_NAME DISCOURSE_SMTP_PASSWORD \
DISCOURSE_DEVELOPER_EMAILS DISCOURSE_HOSTNAME DISCOURSE_DEVELOPER_EMAILS DISCOURSE_HOSTNAME
do do
config_line=`grep "^ $x:" $web_file` read_config $x
local result=$? local result=$read_config_result
local default="example.com" read_default $x
local default=$read_default_result
if (( result == 0 )) if [ ! -z "$result" ]
then then
if [[ "$config_line" = *"$default"* ]] if [[ "$config_line" = *"$default"* ]]
then then
echo "$x left at incorrect default of example.com" echo "$x left at incorrect default of $default"
valid_config="n" valid_config="n"
fi fi
config_val=`echo $config_line | awk '{print $2}'` config_val=`echo $config_line | awk '{print $2}'`
if [ -z $config_val ] if [ -z $config_val ]
then then
echo "$x was left blank" echo "$x was not configured"
valid_config="n" valid_config="n"
fi fi
else else

View File

@ -48,10 +48,12 @@ env:
DISCOURSE_DEVELOPER_EMAILS: 'me@example.com,you@example.com' DISCOURSE_DEVELOPER_EMAILS: 'me@example.com,you@example.com'
## TODO: The SMTP mail server used to validate new accounts and send notifications ## TODO: The SMTP mail server used to validate new accounts and send notifications
DISCOURSE_SMTP_ADDRESS: smtp.example.com # required # SMTP ADDRESS, username, and password are required
#DISCOURSE_SMTP_PORT: 587 # (optional, default 587) # WARNING the char '#' in SMTP password can cause problems!
#DISCOURSE_SMTP_USER_NAME: user@example.com # required DISCOURSE_SMTP_ADDRESS: smtp.example.com
#DISCOURSE_SMTP_PASSWORD: pa$$word # required, WARNING the char '#' in pw can cause problems! #DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: user@example.com
DISCOURSE_SMTP_PASSWORD: pa$$word
#DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true) #DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true)
## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate