redde 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/.gitignore +20 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +4 -0
  4. data/Guardfile +24 -0
  5. data/LICENSE +22 -0
  6. data/README.md +57 -0
  7. data/Rakefile +2 -0
  8. data/lib/generators/redde/deploy/deploy_generator.rb +34 -0
  9. data/lib/generators/redde/deploy/templates/Capfile +4 -0
  10. data/lib/generators/redde/deploy/templates/deploy.rb +33 -0
  11. data/lib/generators/redde/deploy/templates/recipes/base.rb +16 -0
  12. data/lib/generators/redde/deploy/templates/recipes/check.rb +13 -0
  13. data/lib/generators/redde/deploy/templates/recipes/database.rb +66 -0
  14. data/lib/generators/redde/deploy/templates/recipes/imagemagick.rb +8 -0
  15. data/lib/generators/redde/deploy/templates/recipes/memcached.rb +10 -0
  16. data/lib/generators/redde/deploy/templates/recipes/monit.rb +35 -0
  17. data/lib/generators/redde/deploy/templates/recipes/nginx.rb +26 -0
  18. data/lib/generators/redde/deploy/templates/recipes/nodejs.rb +10 -0
  19. data/lib/generators/redde/deploy/templates/recipes/postfix.rb +37 -0
  20. data/lib/generators/redde/deploy/templates/recipes/rbenv.rb +17 -0
  21. data/lib/generators/redde/deploy/templates/recipes/templates/database.yml.erb +8 -0
  22. data/lib/generators/redde/deploy/templates/recipes/templates/dkim-filter.conf.erb +57 -0
  23. data/lib/generators/redde/deploy/templates/recipes/templates/dkim-filter.defaults.erb +11 -0
  24. data/lib/generators/redde/deploy/templates/recipes/templates/dkim-keys.conf.erb +2 -0
  25. data/lib/generators/redde/deploy/templates/recipes/templates/gemrc.erb +1 -0
  26. data/lib/generators/redde/deploy/templates/recipes/templates/main.cf.erb +43 -0
  27. data/lib/generators/redde/deploy/templates/recipes/templates/memcached.erb +47 -0
  28. data/lib/generators/redde/deploy/templates/recipes/templates/monit_monitrc.erb +21 -0
  29. data/lib/generators/redde/deploy/templates/recipes/templates/monit_nginx.erb +5 -0
  30. data/lib/generators/redde/deploy/templates/recipes/templates/monit_unicorn.erb +14 -0
  31. data/lib/generators/redde/deploy/templates/recipes/templates/nginx_unicorn.erb +28 -0
  32. data/lib/generators/redde/deploy/templates/recipes/templates/unicorn.rb.erb +36 -0
  33. data/lib/generators/redde/deploy/templates/recipes/templates/unicorn_init.erb +84 -0
  34. data/lib/generators/redde/deploy/templates/recipes/unicorn.rb +27 -0
  35. data/lib/generators/redde/layout/layout_generator.rb +57 -0
  36. data/lib/generators/redde/layout/templates/assets/images/admin/addphoto.png +0 -0
  37. data/lib/generators/redde/layout/templates/assets/images/admin/ajaxloader2.gif +0 -0
  38. data/lib/generators/redde/layout/templates/assets/images/admin/arrow_down.png +0 -0
  39. data/lib/generators/redde/layout/templates/assets/images/admin/arrow_enter.png +0 -0
  40. data/lib/generators/redde/layout/templates/assets/images/admin/arrow_right.png +0 -0
  41. data/lib/generators/redde/layout/templates/assets/images/admin/coins.png +0 -0
  42. data/lib/generators/redde/layout/templates/assets/images/admin/confirm.png +0 -0
  43. data/lib/generators/redde/layout/templates/assets/images/admin/del.png +0 -0
  44. data/lib/generators/redde/layout/templates/assets/images/admin/delete.png +0 -0
  45. data/lib/generators/redde/layout/templates/assets/images/admin/email.png +0 -0
  46. data/lib/generators/redde/layout/templates/assets/images/admin/error.png +0 -0
  47. data/lib/generators/redde/layout/templates/assets/images/admin/fio.png +0 -0
  48. data/lib/generators/redde/layout/templates/assets/images/admin/folder.png +0 -0
  49. data/lib/generators/redde/layout/templates/assets/images/admin/folder_.png +0 -0
  50. data/lib/generators/redde/layout/templates/assets/images/admin/icon_eye.gif +0 -0
  51. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/css/jquery.lightbox-0.5.css +101 -0
  52. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/images/lightbox-blank.gif +0 -0
  53. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/images/lightbox-btn-close.gif +0 -0
  54. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/images/lightbox-btn-next.gif +0 -0
  55. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/images/lightbox-btn-prev.gif +0 -0
  56. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/images/lightbox-ico-loading.gif +0 -0
  57. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/js/jquery.js +32 -0
  58. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/js/jquery.lightbox-0.5.js +477 -0
  59. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/js/jquery.lightbox-0.5.min.js +42 -0
  60. data/lib/generators/redde/layout/templates/assets/images/admin/lightbox/js/jquery.lightbox-0.5.pack.js +14 -0
  61. data/lib/generators/redde/layout/templates/assets/images/admin/logo.png +0 -0
  62. data/lib/generators/redde/layout/templates/assets/images/admin/logo_reddeshop.png +0 -0
  63. data/lib/generators/redde/layout/templates/assets/images/admin/move_handler.png +0 -0
  64. data/lib/generators/redde/layout/templates/assets/images/admin/phone.png +0 -0
  65. data/lib/generators/redde/layout/templates/assets/images/admin/photo_ico.png +0 -0
  66. data/lib/generators/redde/layout/templates/assets/images/admin/print.png +0 -0
  67. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/css/docstyle.css +123 -0
  68. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/css/redactor.css +369 -0
  69. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/css/style.css +119 -0
  70. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/css/wym.css +136 -0
  71. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/img/icons.png +0 -0
  72. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/by.js +72 -0
  73. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/de.js +75 -0
  74. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/en.js +76 -0
  75. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/es.js +76 -0
  76. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/fr.js +74 -0
  77. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/hu.js +76 -0
  78. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/it.js +76 -0
  79. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/ja.js +76 -0
  80. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/lv.js +74 -0
  81. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/nl.js +76 -0
  82. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/pl.js +75 -0
  83. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/pt_br.js +81 -0
  84. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/ru.js +75 -0
  85. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/sq.js +76 -0
  86. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/tr.js +76 -0
  87. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/ua.js +75 -0
  88. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/langs/zh_cn.js +77 -0
  89. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/file.html +3 -0
  90. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/image.html +39 -0
  91. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/image_edit.html +35 -0
  92. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/link.html +74 -0
  93. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/table.html +25 -0
  94. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/plugins/video.html +15 -0
  95. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/redactor.js.erb +2260 -0
  96. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/redactor.min.js +1 -0
  97. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/toolbars/default.js +219 -0
  98. data/lib/generators/redde/layout/templates/assets/images/admin/redactor/toolbars/mini.js +103 -0
  99. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/_jquery.reddebox.js.erb +214 -0
  100. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/close.png +0 -0
  101. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/jquery.reddebox.js.erb +246 -0
  102. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/jquery.reddebox.scss +31 -0
  103. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/next.png +0 -0
  104. data/lib/generators/redde/layout/templates/assets/images/admin/reddebox/prev.png +0 -0
  105. data/lib/generators/redde/layout/templates/assets/images/admin/refresh.png +0 -0
  106. data/lib/generators/redde/layout/templates/assets/images/admin/submit.png +0 -0
  107. data/lib/generators/redde/layout/templates/assets/images/admin/submit_hover.png +0 -0
  108. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/change-log.txt +19 -0
  109. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/check-exists.php +15 -0
  110. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/index.php +50 -0
  111. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/jquery.uploadifive.js +888 -0
  112. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/jquery.uploadifive.min.js +6 -0
  113. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/license-standard.txt +71 -0
  114. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/uploadifive-cancel.png +0 -0
  115. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/uploadifive-image-only.php +66 -0
  116. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/uploadifive.css +100 -0
  117. data/lib/generators/redde/layout/templates/assets/images/admin/uploadifive/uploadifive.php +33 -0
  118. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/#swfobject.js +4 -0
  119. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/cancel.png +0 -0
  120. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/jquery.uploadify.min.js +315 -0
  121. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/uploadify-cancel.png +0 -0
  122. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/uploadify.css +66 -0
  123. data/lib/generators/redde/layout/templates/assets/images/admin/uploadify/uploadify.swf +0 -0
  124. data/lib/generators/redde/layout/templates/assets/images/admin/view.png +0 -0
  125. data/lib/generators/redde/layout/templates/assets/images/admin/view_mk.png +0 -0
  126. data/lib/generators/redde/layout/templates/assets/javascripts/admin/jquery.ui.nestedSortable.js +390 -0
  127. data/lib/generators/redde/layout/templates/assets/javascripts/admin/swfobject.js +4 -0
  128. data/lib/generators/redde/layout/templates/assets/javascripts/admin/zen_textarea.min.js +17 -0
  129. data/lib/generators/redde/layout/templates/assets/javascripts/admin.js +88 -0
  130. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/_reset.scss +32 -0
  131. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_list.scss +22 -0
  132. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_notice.scss +39 -0
  133. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_orders.scss +22 -0
  134. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_partners.scss +15 -0
  135. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_photos.scss +31 -0
  136. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/blocks/_sortable.scss +17 -0
  137. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/default.scss +127 -0
  138. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/defaults/_input.scss +43 -0
  139. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/defaults/_table.scss +24 -0
  140. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/_header.scss +57 -0
  141. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/_launchbar.scss +35 -0
  142. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/_login.scss +10 -0
  143. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/_main.scss +59 -0
  144. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/layouts/_sidebar.scss +35 -0
  145. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/shop/_filter.scss +16 -0
  146. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/shop/_order-sh.scss +59 -0
  147. data/lib/generators/redde/layout/templates/assets/stylesheets/admin/shop/_pe.scss +43 -0
  148. data/lib/generators/redde/layout/templates/assets/stylesheets/admin.scss +12 -0
  149. data/lib/generators/redde/layout/templates/controllers/base_controller.rb +6 -0
  150. data/lib/generators/redde/layout/templates/helpers/admin_helper.rb +37 -0
  151. data/lib/generators/redde/layout/templates/layouts/admin.html.haml +30 -0
  152. data/lib/generators/redde/layout/templates/layouts/login.html.haml +32 -0
  153. data/lib/generators/redde/layout/templates/shared/_header.html.haml +13 -0
  154. data/lib/generators/redde/layout/templates/shared/_launchbar.html.haml +9 -0
  155. data/lib/generators/redde/layout/templates/shared/_sidebar.html.haml +23 -0
  156. data/lib/generators/redde/scaffold/scaffold_generator.rb +114 -0
  157. data/lib/generators/redde/scaffold/templates/controllers/controller.rb +55 -0
  158. data/lib/generators/redde/scaffold/templates/edit.html.haml +36 -0
  159. data/lib/generators/redde/scaffold/templates/index.html.haml +37 -0
  160. data/lib/redde/version.rb +3 -0
  161. data/lib/redde.rb +4 -0
  162. data/redde.gemspec +26 -0
  163. data/spec/deploy_generator_spec.rb +29 -0
  164. data/spec/layout_generator_spec.rb +41 -0
  165. data/spec/scaffold_generator_spec.rb +25 -0
  166. data/spec/spec_helper.rb +10 -0
  167. metadata +327 -0
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.DS_Store
19
+ .rvmrc
20
+ .powrc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redde.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Oleg Bovykin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Redde
2
+
3
+ Redde admin generator
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'redde', :group => :development
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Requirements
16
+
17
+ Layout requires 'devise' gem with generated user model. If You use another auth solution, feel free to modify partial with user info and logout link.
18
+
19
+ ## Usage
20
+
21
+ To generate admin layout type:
22
+
23
+ rails g redde:layout
24
+
25
+ To set admin login layout you need to modify application controller:
26
+
27
+ layout :layout_by_resource
28
+
29
+ def layout_by_resource
30
+ if devise_controller? && controller_name == "sessions"
31
+ 'login'
32
+ else
33
+ "application"
34
+ end
35
+ end
36
+
37
+ To generate admin views and controller for model type:
38
+
39
+ rails g redde:scaffold ModelNames
40
+
41
+ Add to your config/prodcution.rb these files: admin.scss and admin.js
42
+
43
+ config.assets.precompile += %w( admin.js admin.css )
44
+
45
+ ## Options
46
+ If you have these fields in your model:
47
+
48
+ * `visible:boolean` for toggle option
49
+ * `position:integer` for sortable option
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,34 @@
1
+ require 'rails/generators'
2
+
3
+ module Redde
4
+ module Generators
5
+ class DeployGenerator < ::Rails::Generators::Base
6
+ source_root File.expand_path("../templates", __FILE__)
7
+ desc "Redde deploy recipes generator"
8
+
9
+ attr_reader :app_name, :ip, :domain
10
+
11
+ argument :ip, :type => :string, :required => true, :banner => "Enter ip addres of the host"
12
+
13
+ argument :domain, :type => :string, :required => false, :banner => "Enter domain name for postfix config"
14
+
15
+ def generate_layout
16
+ # copy Capfile
17
+ template "Capfile", "Capfile"
18
+
19
+ # copy deploy.rb
20
+ template "deploy.rb", "config/deploy.rb"
21
+
22
+ # copy capistrano recipes
23
+ directory "recipes", "config/recipes"
24
+ end
25
+
26
+ private
27
+
28
+ def app_name
29
+ Rails.application.class.to_s.split("::").first.downcase || "TestApp"
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ load 'deploy'
2
+ # Uncomment if you are using Rails' asset pipeline
3
+ load 'deploy/assets'
4
+ load 'config/deploy' # remove this line to skip loading any of the default tasks
@@ -0,0 +1,33 @@
1
+ require "bundler/capistrano"
2
+
3
+ load "config/recipes/base"
4
+ load "config/recipes/nginx"
5
+ load "config/recipes/unicorn"
6
+ load "config/recipes/database"
7
+ load "config/recipes/imagemagick"
8
+ load "config/recipes/nodejs"
9
+ load "config/recipes/rbenv"
10
+ load "config/recipes/check"
11
+ load "config/recipes/monit"
12
+ load "config/recipes/memcached"
13
+ <% if domain.present? %>
14
+ load "config/recipes/postfix"
15
+ set :fqdn, "<%= domain %>"
16
+ <% end %>
17
+
18
+ server "<%= ip %>", :web, :app, :db, primary: true
19
+
20
+ set :user, "webmaster"
21
+ set :application, "<%= app_name %>"
22
+ set :deploy_to, "/home/#{user}/projects/#{application}"
23
+ set :deploy_via, :remote_cache
24
+ set :use_sudo, false
25
+
26
+ set :scm, "git"
27
+ set :repository, "webmaster@<%= ip %>:<%= app_name %>"
28
+ set :branch, "master"
29
+
30
+ default_run_options[:pty] = true
31
+ ssh_options[:forward_agent] = true
32
+
33
+ after "deploy", "deploy:cleanup" # keep only the last 5 releases
@@ -0,0 +1,16 @@
1
+ def template(from, to)
2
+ erb = File.read(File.expand_path("../templates/#{from}", __FILE__))
3
+ put ERB.new(erb).result(binding), to
4
+ end
5
+
6
+ def set_default(name, *args, &block)
7
+ set(name, *args, &block) unless exists?(name)
8
+ end
9
+
10
+ namespace :deploy do
11
+ desc "Install base requirements"
12
+ task :install do
13
+ run "#{sudo} apt-get -y update"
14
+ run "#{sudo} apt-get -y install python-software-properties build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison"
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ namespace :check do
2
+ desc "Make sure local git is in sync with remote."
3
+ task :revision, roles: :web do
4
+ unless `git rev-parse HEAD` == `git rev-parse origin/#{branch}`
5
+ puts "WARNING: HEAD is not the same as origin/#{branch}"
6
+ puts "Run `git push` to sync changes."
7
+ exit
8
+ end
9
+ end
10
+ before "deploy", "check:revision"
11
+ before "deploy:migrations", "check:revision"
12
+ before "deploy:cold", "check:revision"
13
+ end
@@ -0,0 +1,66 @@
1
+ #coding: utf-8
2
+ set_default(:database_host, "localhost")
3
+ set_default(:database_user, "root")
4
+ set_default(:database_database) { "#{application}_production" }
5
+
6
+ namespace :database do
7
+ desc "Install MySQL-Server with non-interactive mode"
8
+ task :install, roles: :db do
9
+ begin
10
+ put %Q{
11
+ Name: mysql-server/root_password
12
+ Template: mysql-server/root_password
13
+ Value:
14
+ Owners: mysql-server-5.1
15
+ Flags: seen
16
+
17
+ Name: mysql-server/root_password_again
18
+ Template: mysql-server/root_password_again
19
+ Value:
20
+ Owners: mysql-server-5.1
21
+ Flags: seen
22
+
23
+ Name: mysql-server/root_password
24
+ Template: mysql-server/root_password
25
+ Value:
26
+ Owners: mysql-server-5.0
27
+ Flags: seen
28
+
29
+ Name: mysql-server/root_password_again
30
+ Template: mysql-server/root_password_again
31
+ Value:
32
+ Owners: mysql-server-5.0
33
+ Flags: seen
34
+ }, "non-interactive.txt"
35
+ sudo "DEBIAN_FRONTEND=noninteractive DEBCONF_DB_FALLBACK=Pipe apt-get -qq -y install mysql-server < non-interactive.txt"
36
+ rescue
37
+ raise
38
+ ensure
39
+ sudo "rm non-interactive.txt"
40
+ end
41
+
42
+ run "#{sudo} apt-get -y install libmysql-ruby libmysqlclient-dev"
43
+ end
44
+ after "deploy:install", "database:install"
45
+
46
+ desc "Create a database for the app if not exists"
47
+ task :create_database, roles: :db, only: {primary: true} do
48
+ run "#{sudo} mysql -u #{database_user} -h #{database_host} -e 'CREATE DATABASE IF NOT EXISTS #{database_database} '"
49
+ end
50
+ after "deploy:setup", "database:create_database"
51
+
52
+ desc "Generate the database.yml config"
53
+ task :setup, roles: :app do
54
+ run "mkdir -p #{shared_path}/config"
55
+ template "database.yml.erb", "#{shared_path}/config/database.yml"
56
+ end
57
+ after "deploy:setup", "database:setup"
58
+
59
+ desc "Symlink shared files and folders"
60
+ task :symlink, roles: :app do
61
+ run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
62
+ run "rm -Rf #{release_path}/public/uploads"
63
+ run "ln -s #{shared_path}/uploads #{release_path}/public/uploads"
64
+ end
65
+ after "deploy:finalize_update", "database:symlink"
66
+ end
@@ -0,0 +1,8 @@
1
+ namespace :imagemagick do
2
+ desc "Install latest imagemagick"
3
+ task :install, roles: :web do
4
+ run "#{sudo} apt-get install -y imagemagick libmagickcore-dev libmagickwand-dev"
5
+ end
6
+ after "deploy:install", "imagemagick:install"
7
+
8
+ end
@@ -0,0 +1,10 @@
1
+ namespace :memcached do
2
+ desc "Install memcached"
3
+ task :install, roles: :app do
4
+ run "#{sudo} apt-get -y install memcached"
5
+ template "memcached.erb", "/tmp/memcached_conf"
6
+ run "#{sudo} mv /tmp/memcached_conf /etc/memcached.conf"
7
+ run "#{sudo} service memcached restart"
8
+ end
9
+ after "deploy:install", "memcached:install"
10
+ end
@@ -0,0 +1,35 @@
1
+ namespace :monit do
2
+ desc "Install Monit"
3
+ task :install do
4
+ run "#{sudo} apt-get -y install monit"
5
+ end
6
+ after "deploy:install", "monit:install"
7
+
8
+ desc "Setup all Monit configuration"
9
+ task :setup do
10
+ monit_config "monitrc", "/etc/monit/monitrc"
11
+ nginx
12
+ unicorn
13
+ syntax
14
+ restart
15
+ end
16
+ after "deploy:setup", "monit:setup"
17
+
18
+ task(:nginx, roles: :web) { monit_config "nginx" }
19
+ task(:unicorn, roles: :app) { monit_config "unicorn" }
20
+
21
+ %w[start stop restart syntax reload].each do |command|
22
+ desc "Run Monit #{command} script"
23
+ task command do
24
+ run "#{sudo} service monit #{command}"
25
+ end
26
+ end
27
+ end
28
+
29
+ def monit_config(name, destination = nil)
30
+ destination ||= "/etc/monit/conf.d/#{name}.conf"
31
+ template "monit_#{name}.erb", "/tmp/monit_#{name}"
32
+ run "#{sudo} mv /tmp/monit_#{name} #{destination}"
33
+ run "#{sudo} chown root #{destination}"
34
+ run "#{sudo} chmod 600 #{destination}"
35
+ end
@@ -0,0 +1,26 @@
1
+ namespace :nginx do
2
+ desc "Install Ngnix"
3
+ task :install, roles: :web do
4
+ run "#{sudo} sh -c 'echo \"deb http://ppa.launchpad.net/nginx/stable/ubuntu lucid main\" > /etc/apt/sources.list.d/nginx-stable-lucid.list'"
5
+ run "#{sudo} apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C"
6
+ run "#{sudo} apt-get -y update"
7
+ run "#{sudo} apt-get -y install nginx"
8
+ end
9
+ after "deploy:install", "nginx:install"
10
+
11
+ desc "Setup Nginx"
12
+ task :setup, roles: :web do
13
+ template "nginx_unicorn.erb", "/tmp/nginx_conf"
14
+ run "#{sudo} mv /tmp/nginx_conf /etc/nginx/sites-enabled/#{application}"
15
+ run "#{sudo} rm -f /etc/nginx/sites-enabled/default"
16
+ restart
17
+ end
18
+ after "deploy:setup", "nginx:setup"
19
+
20
+ %w[start stop restart].each do |command|
21
+ desc "#{command} nginx"
22
+ task command, roles: :web do
23
+ run "#{sudo} service nginx #{command}"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,10 @@
1
+ namespace :nodejs do
2
+ desc "Install Node.js"
3
+ task :install, roles: :app do
4
+ run "#{sudo} sh -c 'echo \"deb http://ppa.launchpad.net/chris-lea/node.js/ubuntu lucid main\" > /etc/apt/sources.list.d/chris-lea-node.js-lucid.list'"
5
+ run "#{sudo} apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C300EE8C"
6
+ run "#{sudo} apt-get -y update"
7
+ run "#{sudo} apt-get -y --force-yes install nodejs"
8
+ end
9
+ after "deploy:install", "nodejs:install"
10
+ end
@@ -0,0 +1,37 @@
1
+ namespace :postfix do
2
+ def put_sudo(data, to)
3
+ filename = File.basename(to)
4
+ to_directory = File.dirname(to)
5
+ put data, "/tmp/#{filename}"
6
+ run "#{sudo} mv /tmp/#{filename} #{to_directory}"
7
+ end
8
+
9
+ def template_sudo(from, to)
10
+ erb = File.read(File.expand_path("../templates/#{from}", __FILE__))
11
+ put_sudo ERB.new(erb).result(binding), to
12
+ end
13
+
14
+ desc "Install latest stable release of postfix"
15
+ task :install, roles: :web do
16
+ run "#{sudo} DEBIAN_FRONTEND=noninteractive apt-get -y install postfix"
17
+ run "#{sudo} apt-get install -y dkim-filter"
18
+ run "#{sudo} mkdir -p /etc/postfix/dkim"
19
+ run "#{sudo} dkim-genkey -d #{fqdn} -s mail -r -D /etc/postfix/dkim/"
20
+ run "#{sudo} mv /etc/postfix/dkim/mail.private /etc/postfix/dkim/mail"
21
+ template_sudo "dkim-keys.conf.erb", "/etc/dkim-keys.conf"
22
+ template_sudo "dkim-filter.defaults.erb", "/etc/default/dkim-filter"
23
+ run "#{sudo} chgrp postfix /etc/postfix/dkim/"
24
+ run "#{sudo} chmod 750 /etc/postfix/dkim/"
25
+ template_sudo "main.cf.erb", "/etc/postfix/main.cf"
26
+ template_sudo "dkim-filter.conf.erb", "/etc/dkim-filter.conf"
27
+ restart
28
+ end
29
+ after "deploy:install", "postfix:install"
30
+
31
+ %w[start stop restart].each do |command|
32
+ desc "#{command} postfix"
33
+ task command, roles: :web do
34
+ run "#{sudo} service postfix #{command} && #{sudo} service dkim-filter #{command}"
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,17 @@
1
+ set_default :ruby_version, "1.9.3-p194"
2
+
3
+ namespace :rbenv do
4
+ desc "Install rbenv, Ruby, and the Bundler gem"
5
+ task :install, roles: :app do
6
+ run "sudo apt-get -y install curl git-core"
7
+ run "curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash"
8
+ run "echo 'export PATH=\"$HOME/.rbenv/bin:$PATH\"' > ~/.bashrc"
9
+ run "echo 'eval \"$(rbenv init -)\"' >> ~/.bashrc"
10
+ run "rbenv install #{ruby_version}"
11
+ run "rbenv global #{ruby_version}"
12
+ run "gem install bundler --no-ri --no-rdoc"
13
+ run "rbenv rehash"
14
+ template "gemrc.erb", "/home/webmaster/.gemrc"
15
+ end
16
+ after "deploy:install", "rbenv:install"
17
+ end
@@ -0,0 +1,8 @@
1
+ production:
2
+ adapter: mysql2
3
+ #encoding: unicode
4
+ database: <%= database_database %>
5
+ pool: 5
6
+ username: <%= database_user %>
7
+ password:
8
+ host: <%= database_host %>
@@ -0,0 +1,57 @@
1
+ # Log to syslog
2
+ Syslog yes
3
+ # Required to use local socket with MTAs that access the socket as a non-
4
+ # privileged user (e.g. Postfix)
5
+ UMask 002
6
+
7
+ # Sign for example.com with key in /etc/mail/dkim.key using
8
+ # selector '2007' (e.g. 2007._domainkey.example.com)
9
+ #Domain example.com
10
+ #KeyFile /etc/mail/dkim.key
11
+ #Selector 2007
12
+
13
+ # Common settings. See dkim-filter.conf(5) for more information.
14
+ #AutoRestart no
15
+ #Background yes
16
+ #Canonicalization simple
17
+ #DNSTimeout 5
18
+ #Mode sv
19
+ #SignatureAlgorithm rsa-sha256
20
+ #SubDomains no
21
+ #ADSPDiscard no
22
+ #Version rfc4871
23
+ #X-Header no
24
+
25
+ ###############################################
26
+ # Other (less-standard) configuration options #
27
+ ###############################################
28
+ #
29
+ # If enabled, log verification stats here
30
+ #Statistics /var/run/dkim-filter/dkim-stats
31
+ #
32
+ # KeyList is a file containing tuples of key information. Requires
33
+ # KeyFile to be unset. Each line of the file should be of the format:
34
+ # sender glob:signing domain:signing key file
35
+ # Blank lines and lines beginning with # are ignored. Selector will be
36
+ # derived from the key's filename.
37
+ #KeyList /etc/dkim-keys.conf
38
+ #
39
+ # If enabled, will generate verification failure reports for any messages
40
+ # that fail signature verification. These will be sent to the r= address
41
+ # in the policy record, if any.
42
+ #SendReports yes
43
+ #
44
+ # If enabled, will issue a Sendmail QUARANTINE for any messages that fail
45
+ # signature verification, allowing them to be inspected later.
46
+ #Quarantine yes
47
+ #
48
+ # If enabled, will check for required headers when processing messages.
49
+ # At a minimum, that means From: and Date: will be required. Messages not
50
+ # containing the required headers will not be signed or verified, but will
51
+ # be passed through
52
+ #RequiredHeaders yes
53
+ Canonicalization relaxed/relaxed
54
+ KeyList /etc/dkim-keys.conf
55
+ Domain *
56
+ BodyLengths yes
57
+ #On-DNSError accept
@@ -0,0 +1,11 @@
1
+ # Command-line options specified here will override the contents of
2
+ # /etc/dkim-filter.conf. See dkim-filter(8) for a complete list of options.
3
+ #DAEMON_OPTS=""
4
+ #
5
+ # Uncomment to specify an alternate socket
6
+ # Note that setting this will override any Socket value in dkim-filter.conf
7
+ #SOCKET="local:/var/run/dkim-filter/dkim-filter.sock" # default
8
+ #SOCKET="inet:54321" # listen on all interfaces on port 54321
9
+ #SOCKET="inet:12345@localhost" # listen on loopback on port 12345
10
+ #SOCKET="inet:12345@192.0.2.1" # listen on 192.0.2.1 on port 12345
11
+ SOCKET="inet:8891@localhost"
@@ -0,0 +1,2 @@
1
+ *@<%= fqdn %>:<%= fqdn %>:/etc/postfix/dkim/mail
2
+ *:<%= fqdn %>:/etc/postfix/dkim/mail
@@ -0,0 +1 @@
1
+ gem: --no-ri --no-rdoc
@@ -0,0 +1,43 @@
1
+ # See /usr/share/postfix/main.cf.dist for a commented, more complete version
2
+
3
+
4
+ # Debian specific: Specifying a file name will cause the first
5
+ # line of that file to be used as the name. The Debian default
6
+ # is /etc/mailname.
7
+ #myorigin = /etc/mailname
8
+
9
+ smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
10
+ biff = no
11
+
12
+ # appending .domain is the MUA's job.
13
+ append_dot_mydomain = no
14
+
15
+ # Uncomment the next line to generate "delayed mail" warnings
16
+ #delay_warning_time = 4h
17
+
18
+ readme_directory = no
19
+
20
+ # TLS parameters
21
+ smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
22
+ smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
23
+ smtpd_use_tls=yes
24
+ smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
25
+ smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
26
+
27
+ # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
28
+ # information on enabling SSL in the smtp client.
29
+
30
+ myhostname = <%= fqdn %>
31
+ alias_maps = hash:/etc/aliases
32
+ alias_database = hash:/etc/aliases
33
+ myorigin = /etc/mailname
34
+ mydestination = localhost.localdomain, localhost
35
+ relayhost =
36
+ mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
37
+ mailbox_size_limit = 0
38
+ recipient_delimiter = +
39
+ inet_interfaces = all
40
+ milter_default_action = accept
41
+ milter_protocol = 2
42
+ smtpd_milters = inet:localhost:8891
43
+ non_smtpd_milters = inet:localhost:8891
@@ -0,0 +1,47 @@
1
+ # memcached default config file
2
+ # 2003 - Jay Bonci <jaybonci@debian.org>
3
+ # This configuration file is read by the start-memcached script provided as
4
+ # part of the Debian GNU/Linux distribution.
5
+
6
+ # Run memcached as a daemon. This command is implied, and is not needed for the
7
+ # daemon to run. See the README.Debian that comes with this package for more
8
+ # information.
9
+ -d
10
+
11
+ # Log memcached's output to /var/log/memcached
12
+ logfile /var/log/memcached.log
13
+
14
+ # Be verbose
15
+ # -v
16
+
17
+ # Be even more verbose (print client commands as well)
18
+ # -vv
19
+
20
+ # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
21
+ # Note that the daemon will grow to this size, but does not start out holding this much
22
+ # memory
23
+ -m 64
24
+
25
+ # Default connection port is 11211
26
+ -p 11211
27
+
28
+ # Run the daemon as root. The start-memcached will default to running as root if no
29
+ # -u command is present in this config file
30
+ -u nobody
31
+
32
+ # Specify which IP address to listen on. The default is to listen on all IP addresses
33
+ # This parameter is one of the only security measures that memcached has, so make sure
34
+ # it's listening on a firewalled interface.
35
+ -l 127.0.0.1
36
+
37
+ # Limit the number of simultaneous incoming connections. The daemon default is 1024
38
+ # -c 1024
39
+
40
+ # Lock down all paged memory. Consult with the README and homepage before you do this
41
+ # -k
42
+
43
+ # Return error when memory is exhausted (rather than removing items)
44
+ # -M
45
+
46
+ # Maximize core file limit
47
+ # -r
@@ -0,0 +1,21 @@
1
+ set daemon 30
2
+
3
+ set logfile /var/log/monit.log
4
+ set idfile /var/lib/monit/id
5
+ set statefile /var/lib/monit/state
6
+
7
+ set eventqueue
8
+ basedir /var/lib/monit/events
9
+ slots 100
10
+
11
+ # set mailserver smtp.gmail.com port 587
12
+ # username "foo@example.com" password "secret"
13
+ # using tlsv1
14
+ # with timeout 30 seconds
15
+
16
+ check system <%= application %>
17
+ if loadavg(5min) > 2 for 2 cycles then alert
18
+ if memory > 75% for 2 cycles then alert
19
+ if cpu(user) > 75% for 2 cycles then alert
20
+
21
+ include /etc/monit/conf.d/*