Guest User

Untitled

a guest
May 19th, 2018
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. #!/usr/bin/ruby
  2. module Helpers
  3. LINE = 80
  4.  
  5. def announcing(msg)
  6. print msg
  7. yield
  8. print "." * (LINE - msg.size - 6)
  9. puts "\e[32m[DONE]\e[0m"
  10. end
  11.  
  12. def silent(command)
  13. system "#{command} &> /dev/null"
  14. end
  15.  
  16. def svn(command, *args)
  17. silent "svn #{command} #{args.join(' ')}"
  18. end
  19.  
  20. def git(command, *args)
  21. silent "git #{command} #{args.join(' ')}"
  22. end
  23.  
  24. def piston(repo)
  25. silent "piston import #{repo}"
  26. end
  27.  
  28. def rake(task, args={})
  29. args = args.map {|name,value| "#{name.to_s.upcase}=#{value}"}.join(" ")
  30. silent "rake #{task} #{args}"
  31. end
  32.  
  33. def ray(task, args={})
  34. args = args.map {|name,value| "#{name.to_s.upcase}=#{value}"}.join(" ")
  35. system "rake ray:#{task} #{args}"
  36. end
  37. end
  38.  
  39. if __FILE__ == $0
  40. include Helpers
  41.  
  42. app_name = ARGV.first || exit(1)
  43.  
  44. # Used for the Capfile.
  45. admin_password = 'default_admin_pw'
  46. db_template = 'roasters.yml'
  47. repositories_root = 'kaizer@zuurstof.openminds.be:git'
  48. repositories_password = 'your_scm_password'
  49. app_server = ARGV[1] || 'pro-004.openminds.be'
  50. db_host = 'kwik.openminds.be'
  51.  
  52. announcing "Creating new Radiant instance and initializing git repository" do
  53. silent "radiant #{app_name}"
  54. Dir.chdir(app_name)
  55. git "init"
  56. end
  57.  
  58. announcing "setting up development and test db" do
  59. silent "mysqladmin -u root create #{app_name}_development"
  60. silent "mysqladmin -u root create #{app_name}_test"
  61. silent "rake ADMIN_NAME='Administrator' ADMIN_USERNAME='admin' ADMIN_PASSWORD='#{admin_password}' DATABASE_TEMPLATE=#{db_template} OVERWRITE=true db:bootstrap"
  62. end
  63.  
  64. announcing "Installing plugins" do
  65. git "submodule add git://github.com/technoweenie/attachment_fu.git vendor/plugins/attachment_fu" # requirement for gallery extension
  66. end
  67.  
  68. announcing "Installing ray extension" do
  69. git "submodule add git://gitorious.org/ray/ray.git vendor/extensions/ray"
  70. git "submodule init"
  71. git "submodule update"
  72. silent "rake ray:setup:download"
  73. silent "rake ray:setup:restart server=passenger"
  74. end
  75.  
  76. announcing "Installing default extensions" do
  77. bundle = %Q{---
  78. - name: aggregation
  79. - name: radiant-comments
  80. hub: jomz
  81. fullname: radiant-comments
  82. - name: copy-move
  83. hub: jomz
  84. - name: enkodertags
  85. hub: santry
  86. - name: first-reorder
  87. - name: gallery
  88. hub: jomz
  89. fullname: radiant-gallery
  90. - name: gorillafy
  91. hub: jomz
  92. - name: gorilla-blog
  93. - name: index-page
  94. - name: mailer
  95. hub: jomz
  96. - name: navigation_tags
  97. hub: jomz
  98. - name: nested-layouts
  99. - name: paperclipped
  100. hub: jomz
  101. - name: predefined-parts
  102. hub: DefV
  103. - name: search
  104. - name: settings
  105. hub: jomz
  106. fullname: radiant-settings-extension
  107. - name: share-layouts
  108. hub: jomz
  109. - name: tags
  110. - name: trike-tags
  111. - name: wym-editor-filter
  112. }
  113. system "touch config/extensions.yml"
  114. system "echo \"#{bundle}\" > config/extensions.yml"
  115. ray "extension:bundle"
  116. end
  117.  
  118. announcing "Tweaking mailer ext." do
  119. silent "cd vendor/extensions/mailer"
  120. silent "git pull origin clientside-validation"
  121. silent "git pull origin with_mailbuild_signups"
  122. silent "cd ../../.."
  123. silent "rake radiant:extensions:mailer:update"
  124. end
  125.  
  126. announcing "capify'ing" do
  127. system "touch Capfile"
  128. capfile = %Q{load "deploy" if respond_to?(:namespace) # cap2 differentiator
  129.  
  130. set :application, "default"
  131. set :user, "#{app_name}"
  132. set :password, "updateme"
  133.  
  134. set :repository, "#{repositories_root}/\#{user}.git"
  135. set :scm_password, "#{repositories_password}"
  136.  
  137. server "#{app_server}", :app, :web, :db, :primary => true
  138.  
  139. DatabaseYml = %Q{# By capistrano
  140. production:
  141. adapter: mysql
  142. database: #{app_name}
  143. username: #{app_name}
  144. password: updateme
  145. host: #{db_host}
  146. }
  147.  
  148. require "gorilla-capistrano-recipes/deploy"
  149. require "gorilla-capistrano-recipes/mysql"
  150. require "gorilla-capistrano-recipes/passenger"
  151. require "gorilla-capistrano-recipes/radiant"
  152. }
  153. system "echo '#{capfile}' > Capfile"
  154. end
  155.  
  156. announcing "setting ignore rules" do
  157. system "touch .gitignore"
  158. ignores = %Q{.DS_Store
  159. log/*.log
  160. db/schema.rb
  161. db/*.sqlite3
  162. config/database.yml
  163. cache
  164. tmp
  165. }
  166. system "echo \"#{ignores}\" > .gitignore"
  167. end
  168.  
  169. announcing "committing kickstart" do
  170. git "add ."
  171. git "commit -m 'kickstarted'"
  172. end
  173. end
Add Comment
Please, Sign In to add comment