Interactive bootstrap for the Common Man


(Jay Pfaffman) #1

I just submitted this PR:

It is an attempt at relieving Normal People from having to use a scary text editor.

Here’s what happens.

If any changes to config file are detected, say so and do nothing.

Otherwise, ask user for values for defaults (see output below).

If they don’t like what they entered, let them try again; once values are approved, write them to config file.

Once changes are written to config file, user gets one more chance to ^C (e.g., to start over or edit the config file with a scary text editor).

If a known smtp host is entered (e.g., sparkpost, sendgrid), then default username for that service is provided.

TODO: ask sparkpost people whether they need to set notification_email

TODO:

Here’s what it looks like:

pfaffman@sequestered:~/discourse_docker$ ./launcher bootstrap app
Getting config
hostname: [discourse.example.com]: new.literatecomputing.com
developer_emails [me@example.com]: j@pfaffman.com
smtp_address [smtp.example.com]: smtp.sparkpostmail.com
smtp_user_name [SMTP_Injection]: 
smtp_password [pa$$word]: reallylongpassword
letsencrypt_account_email (change to enable) [your.email@example.com]: user@someplace.com
Letsencrypt enabled.


That's it! Everything is set. Read carefully before continuing.

DISCOURSE_HOSTNAME: new.literatecomputing.com
DISCOURSE_DEVELOPER_EMAILS: j@pfaffman.com
DISCOURSE_SMTP_ADDRESS: smtp.sparkpostmail.com
DISCOURSE_SMTP_USER_NAME: SMTP_Injection
DISCOURSE_SMTP_PASSWORD: reallylongpassword
LETSENCRYPT_ACCOUNT_EMAIL: user@someplace.com
LETSENCRYPT will be enabled.

Enter to write these settings to containers/app.yml, 'N' to retry, or ^C to start again: n
Getting config
hostname: [new.literatecomputing.com]: 
Unchanged.
developer_emails [j@pfaffman.com]: jay@pfaffman.com
smtp_address [smtp.sparkpostmail.com]: smtp.sendgrid.net
smtp_user_name [apikey]: 
smtp_password [reallylongpassword]: 
letsencrypt_account_email (Enter 'OFF' to disable.) [user@someplace.com]: 
letsencrypt unchanged


That's it! Everything is set. Read carefully before continuing.

DISCOURSE_HOSTNAME: new.literatecomputing.com
DISCOURSE_DEVELOPER_EMAILS: jay@pfaffman.com
DISCOURSE_SMTP_ADDRESS: smtp.sendgrid.net
DISCOURSE_SMTP_USER_NAME: apikey
DISCOURSE_SMTP_PASSWORD: reallylongpassword
LETSENCRYPT_ACCOUNT_EMAIL: user@someplace.com
LETSENCRYPT will be enabled.

Enter to write these settings to containers/app.yml, 'N' to retry, or ^C to start again: 

Writing changes to containers/app.yml:
  DISCOURSE_HOSTNAME: new.literatecomputing.com
  DISCOURSE_DEVELOPER_EMAILS: 'jay@pfaffman.com'
  DISCOURSE_SMTP_ADDRESS: smtp.sendgrid.net
  DISCOURSE_SMTP_USER_NAME: apikey
  DISCOURSE_SMTP_PASSWORD: reallylongpassword
  LETSENCRYPT_ACCOUNT_EMAIL: user@someplace.com
  web.ssl.template.yml enabled
  letsencrypt.ssl.template.yml enabled

containers/app.yml updated successfully.
Enter to continue or ^C to exit: 

If anyone sees problems or has refinements, please let me know.

Would it make more sense to have a ./launcher setup app command that copied standalong.yml and then does this instead of integrating this config with bootstrap? That would save some rather tedious checking that I do now.