chrisrec 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +9 -53
- data/README +14 -0
- data/Rakefile +1 -1
- data/chrisrec.gemspec +11 -12
- data/lib/chrisrec.rb +6 -11
- data/{lib → retired/lib}/backgroundrb/backgroundrb.rb +0 -0
- data/{lib → retired/lib}/gitosis/gitosis.rb +0 -0
- data/{lib → retired/lib}/memcached/memcached.rb +0 -0
- data/{lib → retired/lib}/starling/starling.rb +0 -0
- data/{lib → retired/lib}/workling/workling.rb +0 -0
- data/{pkg/chrisrec-0.1.2 → retired}/template/starling/monit.conf.erb +0 -0
- data/{pkg/chrisrec-0.1.2 → retired}/template/starling/starling-init-script.erb +0 -0
- data/{pkg/chrisrec-0.1.2 → retired}/template/workling/monit.conf.erb +0 -0
- data/{pkg/chrisrec-0.1.2 → retired}/template/workling/workling-init-script.erb +0 -0
- data/template/static/httpd-vhost-static.conf.erb +2 -2
- metadata +30 -100
- data/pkg/chrisrec-0.1.2/Manifest +0 -88
- data/pkg/chrisrec-0.1.2/README +0 -1
- data/pkg/chrisrec-0.1.2/Rakefile +0 -21
- data/pkg/chrisrec-0.1.2/chrisrec.gemspec +0 -30
- data/pkg/chrisrec-0.1.2/lib/backgroundrb/backgroundrb.rb +0 -22
- data/pkg/chrisrec-0.1.2/lib/chrisrec.rb +0 -14
- data/pkg/chrisrec-0.1.2/lib/console/console.rb +0 -19
- data/pkg/chrisrec-0.1.2/lib/daemon/daemon.rb +0 -134
- data/pkg/chrisrec-0.1.2/lib/gitosis/gitosis.rb +0 -131
- data/pkg/chrisrec-0.1.2/lib/jekyll/jekyll.rb +0 -87
- data/pkg/chrisrec-0.1.2/lib/memcached/memcached.rb +0 -140
- data/pkg/chrisrec-0.1.2/lib/munin/munin.rb +0 -135
- data/pkg/chrisrec-0.1.2/lib/mysql/mysql.rake +0 -95
- data/pkg/chrisrec-0.1.2/lib/mysql/mysql.rb +0 -51
- data/pkg/chrisrec-0.1.2/lib/rake/rake.rb +0 -19
- data/pkg/chrisrec-0.1.2/lib/rakecron/rakecron.rb +0 -35
- data/pkg/chrisrec-0.1.2/lib/starling/starling.rb +0 -124
- data/pkg/chrisrec-0.1.2/lib/static/static.rb +0 -80
- data/pkg/chrisrec-0.1.2/lib/tomcat/tomcat.rb +0 -202
- data/pkg/chrisrec-0.1.2/lib/workling/workling.rb +0 -72
- data/pkg/chrisrec-0.1.2/template/daemon/daemon-init-script.erb +0 -59
- data/pkg/chrisrec-0.1.2/template/daemon/monit.conf.erb +0 -4
- data/pkg/chrisrec-0.1.2/template/jekyll/httpd-vhost-jekyll.conf.erb +0 -16
- data/pkg/chrisrec-0.1.2/template/memcached/memcached-conf.erb +0 -1
- data/pkg/chrisrec-0.1.2/template/memcached/memcached.erb +0 -59
- data/pkg/chrisrec-0.1.2/template/memcached/monit.conf.erb +0 -8
- data/pkg/chrisrec-0.1.2/template/memcached/start-memcached.erb +0 -118
- data/pkg/chrisrec-0.1.2/template/munin/httpd-vhost-munin.conf.erb +0 -20
- data/pkg/chrisrec-0.1.2/template/munin/munin.conf.erb +0 -70
- data/pkg/chrisrec-0.1.2/template/munin/munin_nginx_vhost.conf.erb +0 -24
- data/pkg/chrisrec-0.1.2/template/rakecron/rakecron.erb +0 -12
- data/pkg/chrisrec-0.1.2/template/static/httpd-vhost-static.conf.erb +0 -16
- data/pkg/chrisrec-0.1.2/template/tomcat/conf/server.xml.erb +0 -33
- data/pkg/chrisrec-0.1.2/template/tomcat/conf/web.xml +0 -1194
- data/pkg/chrisrec-0.1.2/template/tomcat/logs/empty.txt +0 -1
- data/pkg/chrisrec-0.1.2/template/tomcat/monit.conf.erb +0 -8
- data/pkg/chrisrec-0.1.2/template/tomcat/temp/empty.txt +0 -1
- data/pkg/chrisrec-0.1.2/template/tomcat/tomcat.erb +0 -28
- data/pkg/chrisrec-0.1.2/template/tomcat/webapps/empty.txt +0 -1
- data/pkg/chrisrec-0.1.2/template/tomcat/work/empty.txt +0 -1
- data/template/starling/monit.conf.erb +0 -14
- data/template/starling/starling-init-script.erb +0 -69
- data/template/workling/monit.conf.erb +0 -4
- data/template/workling/workling-init-script.erb +0 -56
data/pkg/chrisrec-0.1.2/README
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
==EXTENSIONS FOR DEPREC
|
data/pkg/chrisrec-0.1.2/Rakefile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
## rake manifest
|
2
|
-
## rake gem
|
3
|
-
## rake install
|
4
|
-
|
5
|
-
## gem push pkg/chrisrec-X.Y.Z.gem
|
6
|
-
|
7
|
-
# Rakefile
|
8
|
-
require 'rubygems'
|
9
|
-
require 'rake'
|
10
|
-
require 'echoe'
|
11
|
-
|
12
|
-
Echoe.new('chrisrec', '0.1.3') do |p|
|
13
|
-
p.description = "Extend Deprec with other recipies."
|
14
|
-
p.url = "http://github.com/dougochris/chrisrec"
|
15
|
-
p.author = "Chris Douglas"
|
16
|
-
p.email = "dougo.chris@gmail.com"
|
17
|
-
p.ignore_pattern = ["tmp/*", "script/*"]
|
18
|
-
p.development_dependencies = []
|
19
|
-
end
|
20
|
-
|
21
|
-
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{chrisrec}
|
5
|
-
s.version = "0.1.2"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Chris Douglas"]
|
9
|
-
s.date = %q{2010-08-10}
|
10
|
-
s.description = %q{Extend Deprec with other recipies.}
|
11
|
-
s.email = %q{dougo.chris@gmail.com}
|
12
|
-
s.extra_rdoc_files = ["README", "lib/backgroundrb/backgroundrb.rb", "lib/chrisrec.rb", "lib/console/console.rb", "lib/daemon/daemon.rb", "lib/gitosis/gitosis.rb", "lib/jekyll/jekyll.rb", "lib/memcached/memcached.rb", "lib/munin/munin.rb", "lib/mysql/mysql.rake", "lib/mysql/mysql.rb", "lib/rake/rake.rb", "lib/rakecron/rakecron.rb", "lib/starling/starling.rb", "lib/static/static.rb", "lib/tomcat/tomcat.rb", "lib/workling/workling.rb"]
|
13
|
-
s.files = ["Manifest", "README", "Rakefile", "chrisrec.gemspec", "lib/backgroundrb/backgroundrb.rb", "lib/chrisrec.rb", "lib/console/console.rb", "lib/daemon/daemon.rb", "lib/gitosis/gitosis.rb", "lib/jekyll/jekyll.rb", "lib/memcached/memcached.rb", "lib/munin/munin.rb", "lib/mysql/mysql.rake", "lib/mysql/mysql.rb", "lib/rake/rake.rb", "lib/rakecron/rakecron.rb", "lib/starling/starling.rb", "lib/static/static.rb", "lib/tomcat/tomcat.rb", "lib/workling/workling.rb", "template/daemon/daemon-init-script.erb", "template/daemon/monit.conf.erb", "template/jekyll/httpd-vhost-jekyll.conf.erb", "template/memcached/memcached-conf.erb", "template/memcached/memcached.erb", "template/memcached/monit.conf.erb", "template/memcached/start-memcached.erb", "template/munin/httpd-vhost-munin.conf.erb", "template/munin/munin.conf.erb", "template/munin/munin_nginx_vhost.conf.erb", "template/rakecron/rakecron.erb", "template/starling/monit.conf.erb", "template/starling/starling-init-script.erb", "template/static/httpd-vhost-static.conf.erb", "template/tomcat/conf/server.xml.erb", "template/tomcat/conf/web.xml", "template/tomcat/logs/empty.txt", "template/tomcat/monit.conf.erb", "template/tomcat/temp/empty.txt", "template/tomcat/tomcat.erb", "template/tomcat/webapps/empty.txt", "template/tomcat/work/empty.txt", "template/workling/monit.conf.erb", "template/workling/workling-init-script.erb"]
|
14
|
-
s.homepage = %q{http://github.com/dougochris/chrisrec}
|
15
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Chrisrec", "--main", "README"]
|
16
|
-
s.require_paths = ["lib"]
|
17
|
-
s.rubyforge_project = %q{chrisrec}
|
18
|
-
s.rubygems_version = %q{1.3.7}
|
19
|
-
s.summary = %q{Extend Deprec with other recipies.}
|
20
|
-
|
21
|
-
if s.respond_to? :specification_version then
|
22
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
-
s.specification_version = 3
|
24
|
-
|
25
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
-
else
|
27
|
-
end
|
28
|
-
else
|
29
|
-
end
|
30
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
-
namespace :chrisrec do
|
3
|
-
namespace :backgroundrb do
|
4
|
-
|
5
|
-
desc "Stop the backgroundrb server"
|
6
|
-
task :stop , :roles => :app do
|
7
|
-
run "cd #{current_path} && PATH=/opt/ruby-enterprise/bin:$PATH RAILS_ENV=production ./script/backgroundrb stop"
|
8
|
-
end
|
9
|
-
|
10
|
-
desc "Start the backgroundrb server"
|
11
|
-
task :start , :roles => :app do
|
12
|
-
run "cd #{current_path} && PATH=/opt/ruby-enterprise/bin:$PATH RAILS_ENV=production ./script/backgroundrb start"
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "Start the backgroundrb server"
|
16
|
-
task :restart, :roles => :app do
|
17
|
-
stop
|
18
|
-
start
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "#{File.dirname(__FILE__)}/gitosis/gitosis.rb"
|
2
|
-
require "#{File.dirname(__FILE__)}/munin/munin.rb"
|
3
|
-
require "#{File.dirname(__FILE__)}/rakecron/rakecron.rb"
|
4
|
-
require "#{File.dirname(__FILE__)}/backgroundrb/backgroundrb.rb"
|
5
|
-
require "#{File.dirname(__FILE__)}/workling/workling.rb"
|
6
|
-
require "#{File.dirname(__FILE__)}/starling/starling.rb"
|
7
|
-
require "#{File.dirname(__FILE__)}/rake/rake.rb"
|
8
|
-
require "#{File.dirname(__FILE__)}/mysql/mysql.rb"
|
9
|
-
require "#{File.dirname(__FILE__)}/memcached/memcached.rb"
|
10
|
-
require "#{File.dirname(__FILE__)}/daemon/daemon.rb"
|
11
|
-
require "#{File.dirname(__FILE__)}/tomcat/tomcat.rb"
|
12
|
-
require "#{File.dirname(__FILE__)}/console/console.rb"
|
13
|
-
require "#{File.dirname(__FILE__)}/jekyll/jekyll.rb"
|
14
|
-
require "#{File.dirname(__FILE__)}/static/static.rb"
|
@@ -1,19 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
-
namespace :chrisrec do
|
3
|
-
namespace :script do
|
4
|
-
def interactive_ssh(cmd)
|
5
|
-
system %Q{ssh #{user}@#{roles[:app].servers.first.host} -t '#{cmd}'}
|
6
|
-
end
|
7
|
-
|
8
|
-
desc 'run the rails console on the app-server of the current stage'
|
9
|
-
task :console, :roles => :app do
|
10
|
-
interactive_ssh "cd #{deploy_to}/current && script/console #{rails_env}"
|
11
|
-
end
|
12
|
-
|
13
|
-
desc 'open a SSH prompt in the currently deployed rails app'
|
14
|
-
task :ssh, :roles => :app do
|
15
|
-
interactive_ssh "cd #{deploy_to}/current && bash"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
# chrisrec:daemon:deploy:setup
|
2
|
-
# chrisrec:daemon:install
|
3
|
-
|
4
|
-
# chrisrec:daemon:config_gen
|
5
|
-
# chrisrec:daemon:config
|
6
|
-
# chrisrec:daemon:restart
|
7
|
-
|
8
|
-
# chrisrec:daemon:deploy
|
9
|
-
# chrisrec:daemon:rollback
|
10
|
-
|
11
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
12
|
-
namespace :chrisrec do
|
13
|
-
namespace :daemon do
|
14
|
-
|
15
|
-
# set :daemon, "TODO"
|
16
|
-
# set :daemon_name, "TODO"
|
17
|
-
# set :daemon_pid, "TODO"
|
18
|
-
|
19
|
-
set :local_template_dir, "#{File.dirname(__FILE__)}/../../template"
|
20
|
-
|
21
|
-
SYSTEM_CONFIG_FILES[:daemon] = [
|
22
|
-
{:template => 'daemon-init-script.erb',
|
23
|
-
:path => 'daemon/etc/init.d/daemon',
|
24
|
-
:mode => 0755,
|
25
|
-
:owner => 'root:root'},
|
26
|
-
|
27
|
-
{:template => 'monit.conf.erb',
|
28
|
-
:path => "daemon/etc/monit.d/monit_daemon.conf",
|
29
|
-
:mode => 0600,
|
30
|
-
:owner => 'root:root'}
|
31
|
-
]
|
32
|
-
|
33
|
-
# Generating Configuration Files
|
34
|
-
desc "install any required gems"
|
35
|
-
task :install do
|
36
|
-
if gems_for_project
|
37
|
-
gems_for_project.each { |gem| gem2.install(gem) }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Generating Configuration Files
|
42
|
-
desc "Generate configuration file(s) for daemon from template(s)"
|
43
|
-
task :config_gen do
|
44
|
-
SYSTEM_CONFIG_FILES[:daemon].each do |file|
|
45
|
-
deprec2.render_template(:daemon, file)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
desc 'Deploy configuration files(s) for daemon'
|
50
|
-
task :config, :roles => :app do
|
51
|
-
deprec2.push_configs(:daemon, SYSTEM_CONFIG_FILES[:daemon])
|
52
|
-
symlink_init_d
|
53
|
-
symlink_monit_d
|
54
|
-
|
55
|
-
activate
|
56
|
-
end
|
57
|
-
|
58
|
-
desc "Stop daemon"
|
59
|
-
task :stop , :roles => :app do
|
60
|
-
sudo "/etc/init.d/#{daemon_name} stop"
|
61
|
-
end
|
62
|
-
|
63
|
-
desc "Start daemon"
|
64
|
-
task :start , :roles => :app do
|
65
|
-
sudo "/etc/init.d/#{daemon_name} start"
|
66
|
-
end
|
67
|
-
|
68
|
-
desc "Start the daemon server"
|
69
|
-
task :restart, :roles => :app do
|
70
|
-
stop
|
71
|
-
sleep(2)
|
72
|
-
start
|
73
|
-
end
|
74
|
-
|
75
|
-
task :activate, :roles => :app do
|
76
|
-
send(run_method, "update-rc.d #{daemon_name} defaults")
|
77
|
-
end
|
78
|
-
|
79
|
-
task :deactivate, :roles => :app do
|
80
|
-
send(run_method, "update-rc.d -f #{daemon_name} remove")
|
81
|
-
end
|
82
|
-
|
83
|
-
task :symlink_init_d do
|
84
|
-
sudo "ln -fs #{deploy_to}/daemon/daemon/etc/init.d/daemon /etc/init.d/#{daemon_name}"
|
85
|
-
end
|
86
|
-
|
87
|
-
task :symlink_monit_d do
|
88
|
-
sudo "ln -fs #{deploy_to}/daemon/daemon/etc/monit.d/monit_daemon.conf /etc/monit.d/monit_daemon_#{daemon_name}.conf"
|
89
|
-
end
|
90
|
-
|
91
|
-
namespace :deploy do
|
92
|
-
desc 'deploy'
|
93
|
-
task :default do
|
94
|
-
strategy.deploy!
|
95
|
-
|
96
|
-
run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
|
97
|
-
|
98
|
-
# mkdir -p is making sure that the directories are there for some SCM's that don't
|
99
|
-
# save empty folders
|
100
|
-
run <<-CMD
|
101
|
-
rm -rf #{latest_release}/log #{latest_release}/tmp/pids &&
|
102
|
-
mkdir -p #{latest_release}/tmp &&
|
103
|
-
ln -s #{shared_path}/log #{latest_release}/log &&
|
104
|
-
ln -s #{shared_path}/pids #{latest_release}/tmp/pids
|
105
|
-
CMD
|
106
|
-
|
107
|
-
top.chrisrec.daemon.restart
|
108
|
-
end
|
109
|
-
|
110
|
-
desc 'setup'
|
111
|
-
task :setup do
|
112
|
-
dirs = [deploy_to, releases_path, shared_path]
|
113
|
-
dirs += shared_children.map { |d| File.join(shared_path, d) }
|
114
|
-
sudo "mkdir -p #{dirs.join(' ')}"
|
115
|
-
sudo "chgrp -R #{group} #{dirs.join(' ')}"
|
116
|
-
sudo "chmod g+w #{dirs.join(' ')}"
|
117
|
-
end
|
118
|
-
|
119
|
-
desc 'rollback'
|
120
|
-
task :rollback do
|
121
|
-
if previous_release
|
122
|
-
run "rm #{current_path}; ln -s #{previous_release} #{current_path}"
|
123
|
-
else
|
124
|
-
abort "could not rollback the code because there is no prior release"
|
125
|
-
end
|
126
|
-
|
127
|
-
run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
|
128
|
-
|
129
|
-
top.chrisrec.daemon.restart
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
@@ -1,131 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
-
namespace :chrisrec do
|
3
|
-
namespace :gitosis do
|
4
|
-
|
5
|
-
desc "Sets up the remote user's public key on remote git user"
|
6
|
-
task :create_remote_user_key, :roles => :scm do
|
7
|
-
default(:target_user) {
|
8
|
-
Capistrano::CLI.ui.ask "Setup keys for which user?" do |q|
|
9
|
-
q.default = user
|
10
|
-
end
|
11
|
-
}
|
12
|
-
|
13
|
-
set (:git_ip) {
|
14
|
-
Capistrano::CLI.ui.ask "Enter git ip address" do |q|
|
15
|
-
q.default = repository.scan(/@(.*):/).flatten.to_s
|
16
|
-
end
|
17
|
-
}
|
18
|
-
|
19
|
-
FileUtils.rm_rf("config/_gitosis_temp_#{domain}") if File.directory?("config/_gitosis_temp_#{domain}")
|
20
|
-
FileUtils.mkdir_p("config/_gitosis_temp_#{domain}") if !File.directory?("config/_gitosis_temp_#{domain}")
|
21
|
-
system("git clone git@#{git_ip}:gitosis-admin.git config/_gitosis_temp_#{domain}/gitosis-admin.git") if !File.exists?("config/_gitosis_temp_#{domain}/gitosis-admin.git")
|
22
|
-
|
23
|
-
# create key pair if it doesn't exist, and fetch public key
|
24
|
-
run "sh -c 'test -f /home/#{target_user}/.ssh/id_rsa.pub || /usr/bin/ssh-keygen -q -t rsa -N \"\" -f /home/#{target_user}/.ssh/id_rsa'"
|
25
|
-
|
26
|
-
get("/home/#{target_user}/.ssh/id_rsa.pub", "config/_gitosis_temp_#{domain}/#{target_user}.pub")
|
27
|
-
gitosis_server = File.open("config/_gitosis_temp_#{domain}/#{target_user}.pub", "r") do |line|
|
28
|
-
line.gets.split(" ").last
|
29
|
-
end
|
30
|
-
system("mv config/_gitosis_temp_#{domain}/#{target_user}.pub config/_gitosis_temp_#{domain}/gitosis-admin.git/keydir/#{gitosis_server}.pub")
|
31
|
-
system "cd config/_gitosis_temp_#{domain}/gitosis-admin.git && git add . && git commit -m \"Added write permission to new user\" && git push"
|
32
|
-
FileUtils.rm_rf("config/_gitosis_temp_#{domain}") if File.directory?("config/_gitosis_temp_#{domain}")
|
33
|
-
end
|
34
|
-
|
35
|
-
desc "Create the gitosis settings for remote repository"
|
36
|
-
task :config_gen, :roles => :scm do
|
37
|
-
set (:git_ip) {
|
38
|
-
Capistrano::CLI.ui.ask "Enter git ip address" do |q|
|
39
|
-
q.default = repository.scan(/@(.*):/).flatten.to_s
|
40
|
-
end
|
41
|
-
}
|
42
|
-
|
43
|
-
FileUtils.rm_rf("config/_gitosis_temp_") if File.directory?("config/_gitosis_temp_")
|
44
|
-
FileUtils.mkdir_p("config/_gitosis_temp_")
|
45
|
-
system("git clone git@#{git_ip}:gitosis-admin.git config/_gitosis_temp_/gitosis-admin.git")
|
46
|
-
|
47
|
-
puts "[group #{application}]"
|
48
|
-
puts "writable = #{application}"
|
49
|
-
puts "members = user1 user2 ..."
|
50
|
-
puts ""
|
51
|
-
puts "See config/_gitosis_temp_/gitosis-admin.git/keydir for available users"
|
52
|
-
puts ""
|
53
|
-
end
|
54
|
-
|
55
|
-
desc "Push the gitosis settings for remote repository"
|
56
|
-
task :config, :roles => :scm do
|
57
|
-
system "cd config/_gitosis_temp_/gitosis-admin.git && git add . && git commit -m \"Added repository #{application} and write permission to users\" && git push"
|
58
|
-
FileUtils.rm_rf("config/_gitosis_temp_") if File.directory?("config/_gitosis_temp_")
|
59
|
-
end
|
60
|
-
|
61
|
-
desc "Create remote git repository and import project into it"
|
62
|
-
task :setup_repo, :roles => :scm do
|
63
|
-
create_local_repos
|
64
|
-
push_local_repo
|
65
|
-
end
|
66
|
-
|
67
|
-
# Create git repository in local project
|
68
|
-
task :create_local_repos do
|
69
|
-
unless File.exists?(".git")
|
70
|
-
system("git init")
|
71
|
-
system("git remote add origin git@#{domain}:#{application}.git")
|
72
|
-
system("git add .")
|
73
|
-
system("git commit -a -m 'Initial import'")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# Import project into git repository.
|
78
|
-
task :push_local_repo, :roles => :scm do
|
79
|
-
add_ignores
|
80
|
-
set (:git_ip) {
|
81
|
-
Capistrano::CLI.ui.ask "Enter git ip address" do |q|
|
82
|
-
q.default = repository.scan(/@(.*):/).flatten.to_s
|
83
|
-
end
|
84
|
-
}
|
85
|
-
|
86
|
-
puts "Importing application."
|
87
|
-
system "git push git@#{git_ip}:#{application}.git master:refs/heads/master"
|
88
|
-
system "git config --add branch.master.remote origin"
|
89
|
-
system "git config --add branch.master.merge refs/heads/master"
|
90
|
-
puts "Your repository is: git@#{git_ip}:#{application}.git"
|
91
|
-
end
|
92
|
-
|
93
|
-
# Ignore log files, tmp, sqlite3
|
94
|
-
task :add_ignores, :roles => :scm do
|
95
|
-
ignore = <<-FILE
|
96
|
-
.DS_Store
|
97
|
-
log/*.log
|
98
|
-
tmp/**/*
|
99
|
-
db/*.sqlite3
|
100
|
-
FILE
|
101
|
-
["log", "tmp/cache", "tmp/pids", "tmp/sessions", "tmp/sockets"].each do |dir|
|
102
|
-
system("touch #{dir}/.gitignore")
|
103
|
-
end
|
104
|
-
File.open(".gitignore", "w") { |f| f.write(ignore.strip.gsub(/^#{ignore[/\A\s*/]}/, "")) }
|
105
|
-
system "find . -type d -empty | xargs -I {} touch {}/.gitignore"
|
106
|
-
system "git add ."
|
107
|
-
system "git commit -a -m 'Touched .gitignore to emtpy folders, ignored log files, tmp, sqlite3 db'"
|
108
|
-
end
|
109
|
-
|
110
|
-
desc 'Tag deployment in git repository'
|
111
|
-
task :tag_deploy do
|
112
|
-
transaction do
|
113
|
-
tag_name = ['deployed', fetch(:stage,nil), release_name].compact.join('-')
|
114
|
-
`git tag #{tag_name} && git push --tags`
|
115
|
-
on_rollback do
|
116
|
-
`git tag -d #{tag_name} && git push #{git_remote} :#{tag_name}`
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
task :confirm do
|
122
|
-
message = "You are deploying to PRODUCTION. continue(y/n):"
|
123
|
-
answer = Capistrano::CLI.ui.ask(message)
|
124
|
-
abort "deployment to production was stopped" unless answer == 'y'
|
125
|
-
|
126
|
-
chrisrec.gitosis.tag_deploy # tag the production release
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
-
namespace :chrisrec do
|
3
|
-
namespace :jekyll do
|
4
|
-
|
5
|
-
set :local_template_dir, "#{File.dirname(__FILE__)}/../../template"
|
6
|
-
|
7
|
-
desc "Install jekyll"
|
8
|
-
task :install, :roles => :app do
|
9
|
-
gem2.install('jekyll')
|
10
|
-
top.deprec.rails.setup_user_perms
|
11
|
-
top.deprec.rails.create_app_user_and_group
|
12
|
-
top.deprec.rails.setup_paths
|
13
|
-
top.deprec.rails.setup_shared_dirs
|
14
|
-
|
15
|
-
top.chrisrec.jekyll.deploy.setup
|
16
|
-
end
|
17
|
-
|
18
|
-
PROJECT_CONFIG_FILES[:jekyll] = [
|
19
|
-
|
20
|
-
{:template => "httpd-vhost-jekyll.conf.erb",
|
21
|
-
:path => 'conf/httpd-vhost-jekyll.conf',
|
22
|
-
:mode => 0755,
|
23
|
-
:owner => 'root:root'}
|
24
|
-
]
|
25
|
-
|
26
|
-
|
27
|
-
desc "Generate configuration file(s) for jekyll from template(s)"
|
28
|
-
task :config_gen do
|
29
|
-
PROJECT_CONFIG_FILES[:jekyll].each do |file|
|
30
|
-
deprec2.render_template(:jekyll, file)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
desc 'Deploy configuration files(s) for jekyll'
|
35
|
-
task :config, :roles => :web do
|
36
|
-
deprec2.push_configs(:jekyll, PROJECT_CONFIG_FILES[:jekyll])
|
37
|
-
symlink_apache_vhost
|
38
|
-
|
39
|
-
top.deprec.apache.restart
|
40
|
-
end
|
41
|
-
|
42
|
-
task :symlink_apache_vhost, :roles => :web do
|
43
|
-
sudo "ln -sf #{deploy_to}/jekyll/conf/httpd-vhost-jekyll.conf /etc/apache2/sites-available/jekyll"
|
44
|
-
sudo "ln -sf #{deploy_to}/jekyll/conf/httpd-vhost-jekyll.conf /etc/apache2/sites-enabled/jekyll"
|
45
|
-
end
|
46
|
-
|
47
|
-
namespace :deploy do
|
48
|
-
desc 'deploy'
|
49
|
-
task :default do
|
50
|
-
strategy.deploy!
|
51
|
-
|
52
|
-
if ruby_vm_type.to_s == 'ree'
|
53
|
-
run "cd #{latest_release} && env PATH=#{ree_install_dir}/bin:$PATH #{ree_install_dir}/bin/jekyll #{latest_release}/_site"
|
54
|
-
else
|
55
|
-
run "cd #{latest_release} && jekyll #{latest_release}/_site"
|
56
|
-
end
|
57
|
-
|
58
|
-
run "rm -f #{current_path} && ln -s #{latest_release}/_site #{current_path}"
|
59
|
-
|
60
|
-
top.deprec.apache.restart
|
61
|
-
end
|
62
|
-
|
63
|
-
desc 'setup'
|
64
|
-
task :setup do
|
65
|
-
dirs = [deploy_to, releases_path]
|
66
|
-
sudo "mkdir -p #{dirs.join(' ')}"
|
67
|
-
sudo "chgrp -R #{group} #{dirs.join(' ')}"
|
68
|
-
sudo "chmod g+w #{dirs.join(' ')}"
|
69
|
-
end
|
70
|
-
|
71
|
-
desc 'rollback'
|
72
|
-
task :rollback do
|
73
|
-
if previous_release
|
74
|
-
run "rm #{current_path}; ln -s #{previous_release} #{current_path}"
|
75
|
-
else
|
76
|
-
abort "could not rollback the code because there is no prior release"
|
77
|
-
end
|
78
|
-
|
79
|
-
run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
|
80
|
-
|
81
|
-
top.deprec.apache.restart
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|