itrigga-cap_deploy 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -64,7 +64,7 @@ configuration.load do
64
64
 
65
65
  task :symlink_site_cache_dir do
66
66
  puts "Removing existing symlink from /tmp/cache/sites"
67
- run "(test -d #{web_dir}/tmp/cache && #{sudo} rm -rf #{web_dir}/tmp/cache) || echo 'no existing /tmp/cache dir'"
67
+ remove_dir_if_exists( "#{web_dir}/tmp/cache" )
68
68
 
69
69
  puts "Creating /shared/cache/sites dir if needed"
70
70
  run "mkdir -p #{shared_dir}/cache/sites && #{sudo} chown -R #{user} #{shared_dir}/cache"
@@ -75,11 +75,12 @@ configuration.load do
75
75
  end
76
76
 
77
77
  task :regenerate_monit do
78
- puts "regenerating monit config file"
79
- run "(test -d #{web_dir}/config/monit && #{sudo} rm -rf #{web_dir}/config/monit/*) || mkdir -p #{web_dir}/config/monit"
78
+ puts "regenerating monit config file(s)"
79
+ remove_dir_if_exists("#{web_dir}/config/monit")
80
+ run "mkdir -p #{web_dir}/config/monit"
80
81
  run "cd #{web_dir} && ruby script/generate monit"
81
82
  puts "setting permissions & ownership on monit config files"
82
- run "#{sudo} chmod 0700 #{web_dir}/config/monit/* && #{sudo} chown root #{web_dir}/config/monit/*"
83
+ set_permissions_on_files_in_dir( :dir=>"#{web_dir}/config/monit", :ownership=>"root", :permissions=>"0700")
83
84
  end
84
85
 
85
86
  task :resymlink_monit do
@@ -95,10 +96,10 @@ configuration.load do
95
96
 
96
97
  task :regenerate_logrotate do
97
98
  puts "regenerating logrotate config file"
98
- run "(test -d #{web_dir}/config/log_rotate && #{sudo} rm #{web_dir}/config/log_rotate/* ) || echo 'no existing config to remove'"
99
+ remove_dir_if_exists( "#{web_dir}/config/log_rotate" )
99
100
  run "cd #{web_dir} && ruby script/generate logrotate"
100
101
  puts "setting permissions & ownership on logrotate config files"
101
- run "#{sudo} chmod 0700 #{web_dir}/config/log_rotate/* && #{sudo} chown root #{web_dir}/config/log_rotate/*"
102
+ set_permissions_on_files_in_dir( :dir=>"#{web_dir}/config/log_rotate", :ownership=>"root", :permissions=>"0700" )
102
103
  end
103
104
 
104
105
  task :resymlink_logrotate do
@@ -117,17 +118,17 @@ configuration.load do
117
118
  task :regenerate_db_scripts do
118
119
  puts "regenerating db scripts"
119
120
 
120
- run "test -d #{web_dir}/script/db && #{sudo} rm -rf #{web_dir}/script/db/*"
121
+ remove_dir_if_exists( "#{web_dir}/script/db" )
121
122
  run "cd #{web_dir} && ruby script/generate db"
122
123
 
123
124
  puts "setting permissions & ownership on cron and db scripts"
124
- run "#{sudo} chmod 0700 #{web_dir}/script/db/* && #{sudo} chown root #{web_dir}/script/db/*"
125
+ set_permissions_on_files_in_dir( :dir=>"#{web_dir}/script/db", :ownership=>"root", :permissions=>"0700" )
125
126
  end
126
127
 
127
128
  task :regenerate_cron_scripts do
128
129
  puts "regenerating cron scripts"
129
130
 
130
- run "(test -d #{web_dir}/script/cron && #{sudo} rm -rf #{web_dir}/script/cron/*) || echo 'no existing scripts/cron dir'"
131
+ remove_dir_if_exists( "#{web_dir}/script/cron" )
131
132
  run "cd #{web_dir} && ruby script/generate cron"
132
133
 
133
134
  puts "setting permissions & ownership on cron scripts"
@@ -25,3 +25,19 @@
25
25
  run "test -d #{dir} || #{sudo} mkdir -p #{dir}"
26
26
  end
27
27
 
28
+ def remove_file_if_exists( file )
29
+ run "(test -f #{file} && #{sudo} rm #{file}) || echo 'no existing #{file} file to remove'"
30
+ end
31
+
32
+ def remove_dir_if_exists( dir )
33
+ run "(test -d #{dir} && #{sudo} rm -rf #{dir}) || echo 'no existing #{dir} dir to remove'"
34
+ end
35
+
36
+ def set_permissions_on_files_in_dir( opts )
37
+ if opts[:ownership]
38
+ run "(test -d #{opts[:dir]} && #{sudo} chown #{opts[:ownership]} #{opts[:dir]}/* ) || echo couldnt find #{opts[:dir]}"
39
+ end
40
+ if opts[:permissions]
41
+ run "(test -d #{opts[:dir]} && #{sudo} chmod #{opts[:permissions]} #{opts[:dir]}/* ) || echo couldnt find #{opts[:dir]}"
42
+ end
43
+ end
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: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Al Davidson