itrigga-cap_deploy 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/itrigga/cap_deploy.rb +2 -0
- data/lib/itrigga/cap_deploy/cap_tasks.rb +101 -0
- data/lib/itrigga/cap_deploy/filesystem_utils.rb +25 -0
- data/lib/itrigga/cap_deploy/hooks.rb +7 -0
- metadata +9 -3
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
@@ -0,0 +1,101 @@
|
|
1
|
+
|
2
|
+
task :symlink_init_d_script do
|
3
|
+
puts "ensuring init_d script is symlinked"
|
4
|
+
run "test -L /etc/init.d/#{application_stub} || #{sudo} ln -s #{script_path}/init_d /etc/init.d/#{application_stub}"
|
5
|
+
end
|
6
|
+
|
7
|
+
task :symlink_log_dirs do
|
8
|
+
puts "ensuring #{std_log_dir} exists"
|
9
|
+
mkdir_unless_exists( std_log_dir )
|
10
|
+
puts "setting ownership on #{std_log_dir} & files to #{user}"
|
11
|
+
run "#{sudo} chown -R #{user} #{std_log_dir}"
|
12
|
+
|
13
|
+
shared_log_dir = "#{shared_dir}/log"
|
14
|
+
puts "ensuring #{shared_log_dir} exists"
|
15
|
+
mkdir_unless_exists( shared_log_dir )
|
16
|
+
|
17
|
+
puts "ensuring log dir #{shared_log_dir} is symlinked to #{std_log_dir}"
|
18
|
+
symlink_dir( std_log_dir, shared_log_dir )
|
19
|
+
puts "setting ownership on #{shared_log_dir} & files to #{user}"
|
20
|
+
run "#{sudo} chown -R #{user} #{shared_log_dir}"
|
21
|
+
|
22
|
+
puts "ensuring log dir #{web_dir}/log is symlinked to #{std_log_dir}"
|
23
|
+
symlink_dir( std_log_dir, "#{web_dir}/log" )
|
24
|
+
|
25
|
+
puts "setting ownership on log dir & files to #{user}"
|
26
|
+
run "#{sudo} chown -R #{user} #{web_dir}/log"
|
27
|
+
|
28
|
+
puts "removing default #{current_path}/log symlink"
|
29
|
+
run "#{sudo} rm #{current_path}/log"
|
30
|
+
end
|
31
|
+
|
32
|
+
task :symlink_pid_dirs do
|
33
|
+
std_pid_dir = "#{web_dir}/tmp/pids"
|
34
|
+
shared_pid_dir = "#{shared_dir}/pids"
|
35
|
+
|
36
|
+
puts "ensuring #{shared_pid_dir} exists"
|
37
|
+
mkdir_unless_exists( shared_pid_dir )
|
38
|
+
|
39
|
+
puts "ensuring #{std_pid_dir} exists"
|
40
|
+
mkdir_unless_exists( std_pid_dir )
|
41
|
+
|
42
|
+
puts "ensuring pid dir #{std_pid_dir} is symlinked to #{shared_pid_dir}"
|
43
|
+
symlink_dir( shared_pid_dir, std_pid_dir )
|
44
|
+
|
45
|
+
puts "setting ownership on #{web_dir}/tmp & files to #{user}"
|
46
|
+
run "#{sudo} chown -R #{user} #{web_dir}/tmp"
|
47
|
+
|
48
|
+
puts "setting ownership on #{shared_pid_dir} & files to #{user}"
|
49
|
+
run "#{sudo} chown -R #{user} #{shared_pid_dir}"
|
50
|
+
end
|
51
|
+
|
52
|
+
task :symlink_site_cache_dir do
|
53
|
+
puts "Removing existing symlink from /tmp/cache/sites"
|
54
|
+
run "(test -d #{web_dir}/tmp/cache && #{sudo} rm -rf #{web_dir}/tmp/cache) || echo 'no existing /tmp/cache dir'"
|
55
|
+
|
56
|
+
puts "Creating /shared/cache/sites dir if needed"
|
57
|
+
run "mkdir -p #{shared_dir}/cache/sites && #{sudo} chown -R #{user} #{shared_dir}/cache"
|
58
|
+
|
59
|
+
puts "Symlinking /shared/cache into /tmp/"
|
60
|
+
symlink_dir("#{shared_dir}/cache","#{web_dir}/tmp/cache")
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
task :regenerate_monit do
|
65
|
+
puts "regenerating monit config file"
|
66
|
+
run "(test -d #{web_dir}/config/monit && #{sudo} rm -rf #{web_dir}/config/monit/*) || mkdir -p #{web_dir}/config/monit"
|
67
|
+
run "cd #{web_dir} && ruby script/generate monit"
|
68
|
+
puts "setting permissions & ownership on monit config files"
|
69
|
+
run "#{sudo} chmod 0700 #{web_dir}/config/monit/* && #{sudo} chown root #{web_dir}/config/monit/*"
|
70
|
+
end
|
71
|
+
|
72
|
+
task :resymlink_monit do
|
73
|
+
std_monit_file = "/etc/monit/conf.d/#{application_stub}"
|
74
|
+
puts "re-symlinking monit config"
|
75
|
+
run "(test -L #{std_monit_file} && #{sudo} rm #{std_monit_file}) || echo 'no existing link'"
|
76
|
+
run "#{sudo} ln -s #{web_dir}/config/monit/monit.`readlink /etc/trigga_config_file | xargs basename`.config #{std_monit_file} "
|
77
|
+
end
|
78
|
+
|
79
|
+
task :reload_monit do
|
80
|
+
run "#{sudo} monit reload"
|
81
|
+
end
|
82
|
+
|
83
|
+
task :regenerate_logrotate do
|
84
|
+
puts "regenerating logrotate config file"
|
85
|
+
run "#{sudo} rm #{web_dir}/config/log_rotate/* && cd #{web_dir} && ruby script/generate logrotate"
|
86
|
+
puts "setting permissions & ownership on logrotate config files"
|
87
|
+
run "#{sudo} chmod 0700 #{web_dir}/config/log_rotate/* && #{sudo} chown root #{web_dir}/config/log_rotate/*"
|
88
|
+
end
|
89
|
+
|
90
|
+
task :resymlink_logrotate do
|
91
|
+
logrotate_config_file = "#{web_dir}/config/log_rotate/log_rotate.#{File.basename(trigga_config_file)}.config"
|
92
|
+
std_logrotate_file = "/etc/logrotate.d/#{application_stub}"
|
93
|
+
puts "re-symlinking logrotate config"
|
94
|
+
run "(test -L #{std_logrotate_file} && #{sudo} rm #{std_logrotate_file}) || echo nothing to remove"
|
95
|
+
run "#{sudo} ln -s #{web_dir}/config/log_rotate/log_rotate.`readlink /etc/trigga_config_file | xargs basename`.config #{std_logrotate_file} "
|
96
|
+
end
|
97
|
+
|
98
|
+
task :chown_entire_project_dir do
|
99
|
+
puts "chowning entire #{application_stub} dir to #{user}"
|
100
|
+
run "#{sudo} chown -R #{user} #{deploy_to}"
|
101
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
def symlink_dir(from, to)
|
2
|
+
run "test -L #{to} || ( #{sudo} find #{to} -mindepth 1 -print | xargs -i mv {} #{from} && #{sudo} rm -rf #{to} && #{sudo} ln -s #{from} #{to} )"
|
3
|
+
end
|
4
|
+
|
5
|
+
def delete_files_from_dir1_which_exist_in_dir2(delete_from_dir, exist_in_dir)
|
6
|
+
run "find #{exist_in_dir} -type f | xargs -n1 basename | xargs -I{} bash -c 'test -f #{delete_from_dir}/{} && rm -v #{delete_from_dir}/{} || echo no file #{delete_from_dir}/{} to delete'"
|
7
|
+
end
|
8
|
+
|
9
|
+
def symlink_files_in_dir(from_dir,to_dir)
|
10
|
+
delete_files_from_dir1_which_exist_in_dir2(to_dir, from_dir)
|
11
|
+
|
12
|
+
run "(#{sudo} test -d #{from_dir} && ( find #{from_dir}/ -mindepth 1 -print | xargs --verbose #{sudo} ln -s -f -t #{to_dir} ) ) || echo 'nothing to link'"
|
13
|
+
end
|
14
|
+
|
15
|
+
def mkdir_unless_exists( dir )
|
16
|
+
run "test -d #{dir} || #{sudo} mkdir -p #{dir}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def symlink_dir(from, to)
|
20
|
+
run "test -L #{to} || ( #{sudo} find #{to} -mindepth 1 -print | xargs -i mv {} #{from} && #{sudo} rm -rf #{to} && #{sudo} ln -s #{from} #{to} )"
|
21
|
+
end
|
22
|
+
|
23
|
+
def mkdir_unless_exists( dir )
|
24
|
+
run "test -d #{dir} || #{sudo} mkdir -p #{dir}"
|
25
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
after "deploy:setup", :chown_entire_project_dir
|
2
|
+
after "deploy:symlink", :symlink_init_d_script
|
3
|
+
after "deploy:symlink", :symlink_log_dirs
|
4
|
+
after "deploy:symlink", :symlink_pid_dirs
|
5
|
+
after "deploy:symlink", :symlink_site_cache_dir
|
6
|
+
# only keep the last 5 releases (otherwise diskspace balloons)
|
7
|
+
after "deploy:update", "deploy:cleanup"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itrigga-cap_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Al Davidson
|
@@ -138,6 +138,10 @@ files:
|
|
138
138
|
- README.rdoc
|
139
139
|
- Rakefile
|
140
140
|
- VERSION
|
141
|
+
- lib/itrigga/cap_deploy.rb
|
142
|
+
- lib/itrigga/cap_deploy/cap_tasks.rb
|
143
|
+
- lib/itrigga/cap_deploy/filesystem_utils.rb
|
144
|
+
- lib/itrigga/cap_deploy/hooks.rb
|
141
145
|
- placeholder.txt
|
142
146
|
- test/helper.rb
|
143
147
|
- test/test_itrigga-cap_deploy.rb
|
@@ -150,6 +154,8 @@ rdoc_options: []
|
|
150
154
|
|
151
155
|
require_paths:
|
152
156
|
- lib
|
157
|
+
- lib/itrigga
|
158
|
+
- lib/itrigga
|
153
159
|
required_ruby_version: !ruby/object:Gem::Requirement
|
154
160
|
none: false
|
155
161
|
requirements:
|