Guest User

Untitled

a guest
Mar 8th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. module ::Rails
  2. class TemplateRunner
  3. def run_with_windows(command, log_action = true)
  4. command = command.sub(/^(?:sudo\s+)?(rake|capify)\b/, '\1.bat')
  5. run_without_windows(command, log_action)
  6. end
  7.  
  8. alias_method_chain :run, :windows if RUBY_PLATFORM =~ /mswin32/
  9. end
  10. end
  11.  
  12. git :init
  13.  
  14. plugin 'exception_notifier', :git => 'git://github.com/rails/exception_notification.git', :submodule => true
  15. plugin 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git', :submodule => true
  16. plugin 'asset_packager', :git => 'git://github.com/sbecker/asset_packager.git', :submodule => true
  17. plugin 'aasm', :git => 'git://github.com/rubyist/aasm.git', :submodule => true
  18. plugin 'acts_as_list', :git => 'git://github.com/rails/acts_as_list.git', :submodule => true
  19. plugin 'awesome_nested_set', :git => 'git://github.com/collectiveidea/awesome_nested_set.git', :submodule => true
  20. plugin 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git', :submodule => true
  21. plugin 'shoulda', :git => 'git://github.com/thoughtbot/shoulda.git', :submodule => true
  22. plugin 'mocha', :git => 'git://github.com/floehopper/mocha.git', :submodule => true
  23. plugin 'authlogic', :git => 'git://github.com/binarylogic/authlogic.git', :submodule => true
  24. plugin 'searchlogic', :git => 'git://github.com/binarylogic/searchlogic.git', :submodule => true
  25.  
  26. run 'cp config/database.yml config/database.example.yml'
  27. run 'rm public/index.html'
  28. run 'rm public/favicon.ico'
  29. run 'rm public/robots.txt'
  30. run 'rm public/images/rails.png'
  31.  
  32. rake 'asset:packager:create_yml'
  33. generate 'session', 'UserSession'
  34. generate 'controller', 'index index'
  35. generate 'controller', 'admin/index index'
  36. route <<-END
  37. map.root :controller => 'index'
  38.  
  39. map.namespace :admin do |admin|
  40. admin.root :controller => 'index'
  41. end
  42. END
  43.  
  44. capify!
  45.  
  46. file '.gitignore', <<-END
  47. log/*.log
  48. db/*.db
  49. db/*.sqlite3
  50. tmp/**/*
  51. doc/api
  52. doc/app
  53. config/database.yml
  54. nbproject
  55. END
  56.  
  57. file 'public/.htaccess', <<-END
  58. <IfModule mod_deflate.c>
  59. SetOutputFilter DEFLATE
  60. <IfModule mod_headers.c>
  61. Header append Vary User-Agent
  62. </IfModule>
  63. </IfModule>
  64.  
  65. <IfModule mod_expires.c>
  66. ExpiresActive On
  67. ExpiresDefault A9030400
  68. </IfModule>
  69.  
  70. <IfModule !mod_expires.c>
  71. <IfModule mod_headers.c>
  72. Header set Cache-Control "max-age=29030400, public"
  73. </IfModule>
  74. </IfModule>
  75. END
  76.  
  77. file 'config/deploy.rb', <<-END
  78. set :application, 'helloworld'
  79. set :domain, 'helloworld.com'
  80.  
  81. set :user, 'deploy'
  82. set :admin_runner, 'deploy'
  83. set :runner, 'root'
  84. set :use_sudo, true
  85. default_run_options[:pty] = true
  86.  
  87. role :app, domain
  88. role :web, domain
  89. role :db, domain, :primary => true
  90.  
  91. set :scm, :git
  92. set :repository, "git@\#{domain}:\#{application}.git"
  93. set :branch, 'master'
  94. set :deploy_to, "/home/\#{user}/sites/\#{domain}"
  95. set :deploy_via, :remote_cache
  96. set :git_shallow_clone, 1
  97. set :git_enable_submodules, 1
  98.  
  99. set :db_name, proc{Capistrano::CLI.password_prompt('Database name:' )}
  100. set :db_user, proc{Capistrano::CLI.password_prompt('Database user:' )}
  101. set :db_password, proc{Capistrano::CLI.password_prompt('Database password:' )}
  102.  
  103. namespace :deploy do
  104. desc 'Restart'
  105. task :restart, :roles => :app do
  106. run "touch \#{current_path}/tmp/restart.txt"
  107. end
  108.  
  109. desc 'Create database.yml in shared/config'
  110. task :after_setup do
  111. require 'erb'
  112. db_config = ERB.new <<-EOF
  113. production:
  114. adapter: mysql
  115. encoding: utf8
  116. reconnect: false
  117. database: <%= db_name %>
  118. pool: 5
  119. username: <%= db_user %>
  120. password: <%= db_password %>
  121. socket: /var/run/mysqld/mysqld.sock
  122. EOF
  123. run "mkdir -p \#{shared_path}/config"
  124. put db_config.result(binding), "\#{shared_path}/config/database.yml"
  125. end
  126.  
  127. desc "Make configuration symlinks"
  128. task :after_update_code do
  129. run "ln -nfs \#{deploy_to}/\#{shared_dir}/config/database.yml \#{release_path}/config/database.yml"
  130. end
  131. end
  132. END
  133.  
  134. git :submodule => "init"
  135. git :add => '.'
  136. git :commit => '-a -m "Initial commit"'
Add Comment
Please, Sign In to add comment