Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- module Helpers
- LINE = 80
- def announcing(msg)
- print msg
- yield
- print "." * (LINE - msg.size - 6)
- puts "\e[32m[DONE]\e[0m"
- end
- def silent(command)
- system "#{command} &> /dev/null"
- end
- def svn(command, *args)
- silent "svn #{command} #{args.join(' ')}"
- end
- def git(command, *args)
- silent "git #{command} #{args.join(' ')}"
- end
- def piston(repo)
- silent "piston import #{repo}"
- end
- def rake(task, args={})
- args = args.map {|name,value| "#{name.to_s.upcase}=#{value}"}.join(" ")
- silent "rake #{task} #{args}"
- end
- def ray(task, args={})
- args = args.map {|name,value| "#{name.to_s.upcase}=#{value}"}.join(" ")
- system "rake ray:#{task} #{args}"
- end
- end
- if __FILE__ == $0
- include Helpers
- app_name = ARGV.first || exit(1)
- # Used for the Capfile.
- admin_password = 'your_password'
- db_template = 'roasters.yml'
- repositories_root = 'kaizer@zuurstof.openminds.be:git'
- repositories_password = 'your_scm_password'
- app_server = ARGV[1] || 'zink.openminds.be'
- db_host = 'kwik.openminds.be'
- announcing "Creating new Radiant instance and initializing git repository" do
- silent "radiant #{app_name}"
- Dir.chdir(app_name)
- git "init"
- end
- announcing "setting up development and test db" do
- silent "mysqladmin -u root create #{app_name}_development"
- silent "mysqladmin -u root create #{app_name}_test"
- silent "rake ADMIN_NAME='Administrator' ADMIN_USERNAME='admin' ADMIN_PASSWORD='#{admin_password}' DATABASE_TEMPLATE=#{db_template} OVERWRITE=true db:bootstrap"
- end
- announcing "Installing plugins" do
- git "submodule add git://github.com/technoweenie/attachment_fu.git vendor/plugins/attachment_fu" # requirement for gallery extension
- end
- announcing "Installing ray extension" do
- git "submodule add git://github.com/jomz/radiant-ray-extension.git vendor/extensions/ray"
- git "submodule init"
- git "submodule update"
- silent "rake ray:setup:download"
- silent "rake ray:setup:restart server=passenger"
- end
- announcing "Installing default extensions" do
- bundle = %Q{---
- - name: aggregation
- - name: comments
- hub: jomz
- fullname: radiant-comments
- - name: copy-move
- - name: enkodertags
- - name: first-reorder
- - name: gallery
- hub: jomz
- fullname: radiant-gallery
- - name: gmaps
- - name: gorillafy
- hub: jomz
- - name: gorilla-blog
- - name: index-page
- - name: mailer
- hub: jomz
- - name: navigation_tags
- hub: jomz
- - name: nested-layouts
- - name: paperclipped
- hub: jomz
- - name: search
- - name: settings
- hub: jomz
- fullname: radiant-settings-extension
- - name: share-layouts
- - name: tags
- - name: trike-tags
- - name: wym-editor-filter
- }
- system "touch config/extensions.yml"
- system "echo \"#{bundle}\" > config/extensions.yml"
- ray "extension:bundle"
- end
- announcing "Tweaking mailer ext." do
- silent "cd vendor/extensions/mailer"
- silent "git pull origin clientside-validation"
- silent "git pull origin with_mailbuild_signups"
- silent "cd ../../.."
- silent "rake radiant:extensions:mailer:update"
- end
- announcing "capify'ing" do
- system "touch Capfile"
- capfile = %Q{load "deploy" if respond_to?(:namespace) # cap2 differentiator
- require "capistrano/deepmodules"
- set :use_sudo, false
- set :group_writable, false
- set :keep_releases, 4
- set :application, "default"
- set :user, "#{app_name}"
- default_run_options[:pty] = true
- set :scm, "git"
- set :repository, "#{repositories_root}/\#{user}.git"
- set :password, "updateme"
- set :scm_password, "#{repositories_password}"
- set :git_enable_submodules,1
- set :branch, "master"
- set :deploy_via, :remote_cache
- set :deploy_to, "/home/\#{user}/apps/\#{application}"
- ssh_options[:forward_agent] = true
- server "#{app_server}", :app, :web, :db, :primary => true
- DatabaseYml = %Q{# By capistrano
- production:
- adapter: mysql
- database: #{app_name}
- username: #{app_name}
- password: updateme
- host: #{db_host}
- }
- # passenger config
- namespace :passenger do
- desc "Restart the web server"
- task :restart, :roles => :app do
- run "touch \#{current_release}/tmp/restart.txt"
- end
- [:start, :stop].each do |t|
- desc "\#{t} task is a no-op with passenger"
- task t, :roles => :app do ; end
- end
- end
- namespace :deploy do
- desc "Restart your application"
- task :restart do
- passenger::restart
- end
- desc "Start your application"
- task :start do
- passenger::start
- end
- desc "Stop your application"
- task :stop do
- passenger::stop
- end
- end
- namespace :configs do
- desc "Create all config files in shared/config"
- task :copy_database_config do
- run "mkdir -p \#{shared_path}/config"
- put DatabaseYml, "\#{shared_path}/config/database.yml"
- end
- desc "Link in the shared config files"
- task :link do
- run "ln -nfs \#{shared_path}/config/database.yml \#{release_path}/config/database.yml"
- end
- end
- namespace :public_files do
- desc "Create shared assets dir"
- task :create_shared_assets do
- run "mkdir -p \#{shared_path}/public/assets"
- end
- desc "Create shared galleries dir"
- task :create_shared_galleries do
- run "mkdir -p \#{shared_path}/public/galleries"
- end
- desc "Link public/assets to shared/public/assets"
- task :link_assets do
- run "ln -nfs \#{shared_path}/public/assets \#{release_path}/public/assets"
- end
- desc "Link public/galleries to shared/public/galleries"
- task :link_galleries do
- run "ln -nfs \#{shared_path}/public/galleries \#{release_path}/public/galleries"
- end
- end
- namespace :deploy do
- desc "Keep only 3 releases"
- task :after_default do
- cleanup
- end
- after "deploy:migrate", "deploy:radiant:migrate:extensions"
- desc "Overridden deploy:cold for Radiant."
- task :cold do
- update
- radiant::bootstrap
- start
- end
- namespace :radiant do
- desc "Radiant Bootstrap with empty template and default values."
- task :bootstrap do
- rake = fetch(:rake, "rake")
- rails_env = fetch(:rails_env, "production")
- run "cd \#{current_release}; \#{rake} RAILS_ENV=\#{rails_env} ADMIN_NAME=Administrator ADMIN_USERNAME=admin ADMIN_PASSWORD=radiant DATABASE_TEMPLATE=empty.yml OVERWRITE=true db:bootstrap"
- end
- namespace :migrate do
- desc "Runs migrations on extensions."
- task :extensions do
- rake = fetch(:rake, "rake")
- rails_env = fetch(:rails_env, "production")
- run "cd \#{current_release}; \#{rake} RAILS_ENV=\#{rails_env} db:migrate:extensions"
- end
- end
- end
- end
- desc "After Code Update"
- task :after_update_code do
- configs::link
- public_files::link_assets
- public_files::link_galleries
- end
- desc "After setup"
- task :after_setup do
- configs::copy_database_config
- public_files::create_shared_assets
- public_files::create_shared_galleries
- end
- }
- system "echo '#{capfile}' > Capfile"
- end
- announcing "committing kickstart" do
- git "add ."
- git "commit -m 'kickstarted'"
- end
- announcing "setting ignore rules" do
- system "touch .gitignore"
- ignores = %Q{.DS_Store
- log/*.log
- db/schema.rb
- db/*.sqlite3
- config/database.yml
- cache
- tmp
- }
- system "echo \"#{ignores}\" > .gitignore"
- git "add .gitignore"
- git "commit -m 'setting ignore rules'"
- end
- end
Add Comment
Please, Sign In to add comment