Nessuna descrizione http://j1x-huginn.herokuapp.com

default.rb 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. include_recipe 'apt'
  2. include_recipe 'build-essential'
  3. user "huginn" do
  4. system true
  5. home "/home/huginn"
  6. password "$6$ZwO6b.6tij$SMa8UIwtESGDxB37NwHsct.gJfXWmmflNbH.oypwJ9y0KkzMkCdw7D14iK7GX9C4CWSEcpGOFUow7p01rQFu5."
  7. supports :manage_home => true
  8. shell "/bin/bash"
  9. gid "sudo"
  10. end
  11. group "huginn" do
  12. members ["huginn"]
  13. end
  14. %w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl" "libshadow-ruby1.8" "libmysqlclient-dev" "libffi-dev", "libssl-dev").each do |pkg|
  15. package("#{pkg}")
  16. end
  17. gem_package("rake")
  18. gem_package("bundle")
  19. service "nginx" do
  20. supports :restart => true, :start => true, :stop => true, :reload => true
  21. action :nothing
  22. end
  23. bash "Setting huginn user with NOPASSWD option" do
  24. cwd "/etc/sudoers.d"
  25. code <<-EOH
  26. touch huginn && chmod 0440 huginn
  27. echo "huginn ALL=(ALL) NOPASSWD:ALL" >> huginn
  28. EOH
  29. end
  30. deploy "/home/huginn" do
  31. repo "https://github.com/cantino/huginn.git"
  32. user "huginn"
  33. group "huginn"
  34. environment "RAILS_ENV" => "production"
  35. keep_releases 5
  36. create_dirs_before_symlink []
  37. symlinks "log" => "log"
  38. symlink_before_migrate({})
  39. rollback_on_error true
  40. notifies :enable, "service[nginx]"
  41. notifies :start, "service[nginx]"
  42. before_symlink do
  43. %w(config log tmp).each do |dir|
  44. directory "/home/huginn/shared/#{dir}" do
  45. owner "huginn"
  46. group "huginn"
  47. recursive true
  48. end
  49. end
  50. directory("/home/huginn/shared/tmp/pids")
  51. directory("/home/huginn/shared/tmp/sockets")
  52. %w(Procfile unicorn.rb nginx.conf).each do |file|
  53. cookbook_file "/home/huginn/shared/config/#{file}" do
  54. owner "huginn"
  55. action :create_if_missing
  56. end
  57. end
  58. cookbook_file "home/huginn/shared/config/.env" do
  59. source "env.example"
  60. mode "666"
  61. owner "huginn"
  62. action :create_if_missing
  63. end
  64. end
  65. before_restart do
  66. bash "huginn dependencies" do
  67. cwd "/home/huginn/current"
  68. user "huginn"
  69. group "huginn"
  70. code <<-EOH
  71. export LANG="en_US.UTF-8"
  72. export LC_ALL="en_US.UTF-8"
  73. ln -nfs /home/huginn/shared/config/Procfile ./Procfile
  74. ln -nfs /home/huginn/shared/config/.env ./.env
  75. ln -nfs /home/huginn/shared/config/unicorn.rb ./config/unicorn.rb
  76. sudo cp /home/huginn/shared/config/nginx.conf /etc/nginx/
  77. sudo bundle install --without=development --without=test
  78. sed -i s/REPLACE_ME_NOW\!/$(sudo bundle exec rake secret)/ .env
  79. sed -i s/config\.force_ssl\ \=\ true/config\.force_ssl\ \=\ false/ config/environments/production.rb
  80. sudo bundle exec rake db:create
  81. sudo bundle exec rake db:migrate
  82. sudo bundle exec rake db:seed
  83. sudo foreman export upstart /etc/init -a huginn -u huginn -l log
  84. sudo start huginn
  85. EOH
  86. end
  87. end
  88. end