Last active
August 29, 2015 13:55
-
-
Save TannerFilip/8721886 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash --login | |
if [[ "$1" == "setup" ]]; then | |
sudo -su discourse /bin/bash --login <<'EOF' | |
cd /var/www/discourse | |
RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake db:migrate | |
RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake assets:precompile | |
EOF | |
elif [[ "$1" == "start" ]]; then | |
sudo -su discourse /bin/bash --login <<'EOF' | |
RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ROOT=/var/www/discourse RAILS_ENV=production NUM_WEBS=2 bluepill --no-privileged -c ~/.bluepill load /var/www/discourse/config/discourse.pill | |
EOF | |
elif [[ "$1" == "redis-server" ]]; then | |
sudo apt-add-repository -y ppa:rwky/redis | |
sudo apt-get update | |
sudo apt-get -y install redis-server | |
else | |
sudo tasksel install openssh-server | |
# Install deps | |
sudo apt-get -y install build-essential libssl-dev libyaml-dev git libtool libxslt-dev libxml2-dev libpq-dev gawk curl pngcrush imagemagick python-software-properties postfix | |
sudo apt-get remove '^nginx.*$' | |
cat <<'EOF' | sudo tee /etc/apt/sources.list.d/nginx.list | |
deb http://nginx.org/packages/ubuntu/ precise nginx | |
deb-src http://nginx.org/packages/ubuntu/ precise nginx | |
EOF | |
curl http://nginx.org/keys/nginx_signing.key | sudo apt-key add - | |
sudo apt-get update && sudo apt-get -y install nginx | |
sudo adduser --shell /bin/bash --gecos 'Discourse application' discourse | |
sudo install -d -m 755 -o discourse -g discourse /var/www/discourse | |
sudo -su discourse /bin/bash --login <<'EOF' | |
# Install RVM | |
curl -s -S -L https://get.rvm.io | bash -s stable | |
# Refresh your profile | |
. ~/.rvm/scripts/rvm | |
rvm --autolibs=read-fail requirements | |
read -p "The above line should say \"Requirements installation successful\". If it doesn't, quit this script and install the missing packages. Otherwise, press enter to continue" | |
##todo: start from here if cancelled | |
rvm install 2.0.0 | |
rvm use 2.0.0 --default | |
gem install bundler | |
git clone git://github.com/discourse/discourse.git /var/www/discourse | |
cd /var/www/discourse | |
git checkout latest-release | |
bundle install --deployment --without test | |
gem install bluepill | |
echo 'alias bluepill="NOEXEC_DISABLE=1 bluepill --no-privileged -c ~/.bluepill"' >> ~/.bash_aliases | |
rvm wrapper $(rvm current) bootup bluepill | |
rvm wrapper $(rvm current) bootup bundle | |
EOF | |
## Todo: how are we handing configs? | |
cd /var/www/discourse/config | |
cp discourse_quickstart.conf discourse.conf | |
cp discourse.pill.sample discourse.pill | |
echo "Installation is complete. Edit discourse.conf, database.yml and discourse.pill in /var/www/discourse/config with database details, then run ./discourse.sh setup" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment