84 lines
2.7 KiB
Bash
Executable File
84 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
apt-get update
|
|
apt-get install -y vim mc screen # not needed, I just prefer to have them around.
|
|
update-alternatives --set editor /usr/bin/vim.basic
|
|
|
|
# Install the required packages (needed to compile Ruby and native extensions to Ruby gems):
|
|
sudo apt-get install -y runit build-essential git zlib1g-dev libyaml-dev libssl-dev libgdbm-dev \
|
|
libreadline-dev libncurses5-dev libffi-dev curl openssh-server checkinstall libxml2-dev libxslt-dev \
|
|
libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake nodejs graphviz
|
|
|
|
# Remove the old Ruby versions if present:
|
|
apt-get remove -y ruby1.8 ruby1.9
|
|
|
|
# Download Ruby and compile it:
|
|
mkdir /usr/src/ruby && cd /usr/src/ruby
|
|
curl -L http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.bz2 | tar xj
|
|
cd ruby-2.2.3
|
|
./configure --disable-install-rdoc
|
|
make -j`nproc`
|
|
make install
|
|
|
|
gem install rake
|
|
|
|
# Install the bundler and foreman gems:
|
|
gem install bundler foreman --no-ri --no-rdoc
|
|
|
|
# Create a user for Huginn:
|
|
adduser --disabled-login --gecos 'Huginn' huginn
|
|
|
|
# Install database lib package
|
|
apt-get install -y libmysqlclient-dev
|
|
|
|
# Clone the Source
|
|
cd /home/huginn
|
|
sudo -u huginn -H git clone https://github.com/cantino/huginn.git -b master huginn
|
|
cd /home/huginn/huginn
|
|
sudo -u huginn mkdir -p log tmp/pids tmp/sockets
|
|
chown -R huginn log/ tmp/
|
|
chmod -R u+rwX,go-w log/ tmp/
|
|
chmod -R u+rwX,go-w log/
|
|
chmod -R u+rwX tmp/
|
|
sudo -u huginn -H cp config/unicorn.rb.example config/unicorn.rb
|
|
|
|
# Copy .env file into place
|
|
sudo -u huginn cp /vagrant/env /home/huginn/huginn/.env
|
|
sudo -u huginn -H chmod o-rwx .env
|
|
|
|
# Install the Gems
|
|
sudo -u huginn -H bundle install --deployment --without development test
|
|
|
|
# Create the database
|
|
sudo -u huginn -H bundle exec rake db:create RAILS_ENV=production
|
|
|
|
# Migrate to the latest version
|
|
sudo -u huginn -H bundle exec rake db:migrate RAILS_ENV=production
|
|
|
|
# Create admin user and example agents
|
|
sudo -u huginn -H bundle exec rake db:seed RAILS_ENV=production SEED_EMAIL=phyks@phyks.me SEED_USERNAME=phyks SEED_PASSWORD=password
|
|
|
|
# Compile Assets
|
|
sudo -u huginn -H bundle exec rake assets:precompile RAILS_ENV=production
|
|
|
|
# Copy Procfile into place
|
|
sudo -u huginn cp /vagrant/Procfile /home/huginn/huginn/Procfile
|
|
|
|
# Export the init scripts:
|
|
sudo bundle exec rake production:export
|
|
|
|
# Setup Logrotate
|
|
cp deployment/logrotate/huginn /etc/logrotate.d/huginn
|
|
|
|
# Check it's running
|
|
sudo bundle exec rake production:status
|
|
|
|
# Install nginx
|
|
apt-get install -y nginx
|
|
cp deployment/nginx/huginn /etc/nginx/sites-available/huginn
|
|
ln -s /etc/nginx/sites-available/huginn /etc/nginx/sites-enabled/huginn
|
|
cp /vagrant/huginn /etc/nginx/sites-available/huginn
|
|
rm /etc/nginx/sites-enabled/default
|
|
nginx -t
|
|
service nginx restart
|