Skip to content

Instantly share code, notes, and snippets.

@shogochiai
Last active March 8, 2020 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shogochiai/bac3e4cb49a3699ffd4b36e01719d9d8 to your computer and use it in GitHub Desktop.
Save shogochiai/bac3e4cb49a3699ffd4b36e01719d9d8 to your computer and use it in GitHub Desktop.
#!/bin/bash
# For
# - ubuntu18.04
# - t2.medium
# - Security Rule: port 22,25,80,443
# - EBS 16GB
# - Discourse v2.3.0.beta9
# - Amazon SES
# - bash ./discourse-build.sh forum bitcoin.com AKKSISNHFDCVBPDEOJBN BCokAid4stoJaOKSqnRJXpwJKKSvuA7thhomFajjKAp/
# Docs
# 1. Buy a domain
# 2.Log in to AWS
# 3. Create a zone in Route 53 with the domain
# 4. Copy NS (name server) records for the zone from the domain seller
# 5. Adding a Custom Name Server to Your Domain
# 6. Launch 16 GB Storage with EC2 SSH, SMTP, HTTP.HTTPS on Ubuntu 18.04 t2.medium
# 7. Map the instance's Public IP to forum. <purchased domain> with Route 53.
# 8. Create a SMPT Credential with Amazon Simple Email Service (SES) and note the 2 strings
# 9. DKIM is set to [Verify with SES] (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-domain-procedure.html) the purchased domain. "Use Route 53" button ( [Data] ( https://aws.amazon.com/jp/premiumsupport/knowledge-center/ses-receive-inbound-emails/))
# 10. Verify that SES has verified the domain on the SES domain list screen (If not verified, try 9 again and the verification will be re-triggered)
# 11. Make a Bucket with your favorite name on S3
# 12. Set up a Bucket Policy ([Data] (https://aws.amazon.com/jp/premiumsupport/knowledge-center/ses-receive-inbound-emails/))
# 13. Set the Recipient Rule Set in SES ([Data] (https://aws.amazon.com/jp/premiumsupport/knowledge-center/ses-receive-inbound-emails/))
# 14. Test Sending button confirms mail is delivered to S3
# 15. Verify info@<domain> to enable sending email to new users
# 16. Ask AWS CS to open the limit of email
# 17. SSH login into server
# 18. Copy and paste [Discourse Build Script] (https://gist.github.com/shogochiai/bac3e4cb49a3699ffd4b36e01719d9d8)
# 19. Run `./discourse-build.sh forum <purchased domain name> <SMTP-key> <SMTP-secret>`
# 20. Open `forum. <purchased domain name> `in a browser and make sure it is the discovery screen.
# 21. Activate the Admin account
# 22. Create a logo or theme
name=$1
domain=$2
smtp_user=$3
smtp_pass=$4
# install
if hash expect 2>/dev/null; then
echo 'expect is already installed'
else
sudo apt-get update -y
sudo apt-get install -y expect
fi
if hash docker 2>/dev/null; then
echo 'docker is already installed'
else
curl https://get.docker.com/ | sh
fi
if [ -d "/var/discourse" ]; then
echo 'discourse is already cloned'
else
sudo git clone https://github.com/discourse/discourse_docker.git /var/discourse
fi
sudo chown ubuntu:ubuntu -R /var/discourse
sudo chmod 777 /var/discourse/cids
cd /var/discourse
rm -f ./containers/*
expect -c "
set timeout -1
spawn sudo ./discourse-setup
expect \"Hostname for your Discourse?\"
send -- \"${name}.${domain}\r\"
expect \"Email address for admin account(s)?\"
send -- \"info@${domain}\r\"
expect \"SMTP server address?\"
send -- \"email-smtp.us-west-2.amazonaws.com\r\"
expect \"SMTP port?\"
send -- \"25\r\"
expect \"SMTP user name?\"
send -- \"${smtp_user}\r\"
expect \"SMTP password?\"
send -- \"${smtp_pass}\r\"
expect \"Optional email address for Let's Encrypt warnings?\"
send -- \"info@${domain}\r\"
expect \"ENTER to continue\"
send -- \"\r\"
expect eof
"
echo '=== done ==='
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment