setup 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. set -e
  3. cd /app
  4. export LC_ALL=en_US.UTF-8
  5. # Ensure the huginn user has access to the required directories
  6. sudo -u huginn -H mkdir -p tmp/pids tmp/cache tmp/sockets log
  7. sudo -u huginn -H touch log/production.log
  8. # Get rid of annoying "fatal: Not a git repository (or any of the parent directories): .git" messages
  9. sudo -u huginn -H git init
  10. # HACK: We need a database connection to precompile the assets, use sqlite for that
  11. cp Gemfile Gemfile.bak
  12. echo "gem 'sqlite3', '~> 1.3.11'" >> /app/Gemfile
  13. RAILS_ENV=production APP_SECRET_TOKEN=secret DATABASE_ADAPTER=sqlite3 ON_HEROKU=true bundle install --without test development --path vendor/bundle -j 4
  14. RAILS_ENV=production APP_SECRET_TOKEN=secret DATABASE_ADAPTER=sqlite3 ON_HEROKU=true bundle exec rake assets:clean assets:precompile
  15. # Bundle again to get rid of the sqlite3 gem
  16. cp Gemfile.bak Gemfile
  17. RAILS_ENV=production APP_SECRET_TOKEN=secret DATABASE_ADAPTER=sqlite3 ON_HEROKU=true bundle install --without test development --path vendor/bundle -j 4
  18. chown huginn:huginn Gemfile.lock
  19. # Configure the unicorn server
  20. mv config/unicorn.rb.example config/unicorn.rb
  21. sed -ri 's/^listen .*$/listen ENV["PORT"]/' config/unicorn.rb
  22. sed -ri 's/^stderr_path.*$//' config/unicorn.rb
  23. sed -ri 's/^stdout_path.*$//' config/unicorn.rb
  24. # Add ENV variables to .env.example which are not present in it but usable
  25. cat >> /app/.env.example <<EOF
  26. ASSET_HOST=
  27. DEFAULT_SCENARIO_FILE=
  28. RAILS_SERVE_STATIC_FILES=
  29. SEED_EMAIL=
  30. SEED_PASSWORD=
  31. SEED_USERNAME=
  32. SMTP_OPENSSL_CA_FILE=
  33. SMTP_OPENSSL_CA_PATH=
  34. SMTP_OPENSSL_VERIFY_MODE=
  35. EOF