deprec-core 3.1.10 → 3.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -1
- data/lib/deprec-core.rb +0 -1
- data/lib/deprec-core/capistrano_extensions.rb +34 -16
- data/lib/deprec-core/defaults.rb +3 -3
- data/lib/deprec-core/version.rb +1 -1
- metadata +2 -3
- data/lib/deprec-core/canonical.rb +0 -108
data/CHANGELOG
CHANGED
data/lib/deprec-core.rb
CHANGED
@@ -4,6 +4,22 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
module Deprec2
|
6
6
|
|
7
|
+
# Pretty coloured output in terminal
|
8
|
+
#
|
9
|
+
# Embed in a String to clear all previous ANSI sequences.
|
10
|
+
CLEAR = "\e[0m"
|
11
|
+
BOLD = "\e[1m"
|
12
|
+
#
|
13
|
+
# # Colors
|
14
|
+
BLACK = "\e[30m"
|
15
|
+
RED = "\e[31m"
|
16
|
+
GREEN = "\e[32m"
|
17
|
+
YELLOW = "\e[33m"
|
18
|
+
BLUE = "\e[34m"
|
19
|
+
MAGENTA = "\e[35m"
|
20
|
+
CYAN = "\e[36m"
|
21
|
+
WHITE = "\e[37m"
|
22
|
+
|
7
23
|
# Run rake task on remote server(s)
|
8
24
|
def rake_remote(task_name)
|
9
25
|
run "cd #{current_path} && RAILS_ENV=#{rails_env} #{rake} #{task_name}"
|
@@ -70,7 +86,7 @@ module Deprec2
|
|
70
86
|
end
|
71
87
|
end
|
72
88
|
rendered_template = template.result(binding)
|
73
|
-
puts "Using #{template_path}"
|
89
|
+
# puts "Using #{template_path}" # work out which template is being used
|
74
90
|
|
75
91
|
if remote
|
76
92
|
# render to remote machine
|
@@ -85,20 +101,18 @@ module Deprec2
|
|
85
101
|
path_dir = File.dirname(File.expand_path(full_path))
|
86
102
|
if File.exists?(full_path)
|
87
103
|
if IO.read(full_path) == rendered_template
|
88
|
-
puts "
|
104
|
+
puts "#{BLUE} identical#{CLEAR} #{full_path}"
|
89
105
|
return false
|
90
106
|
elsif overwrite?(full_path, rendered_template)
|
91
107
|
File.delete(full_path)
|
92
108
|
else
|
93
|
-
puts "
|
109
|
+
puts "#{YELLOW} skip#{CLEAR} #{full_path}"
|
94
110
|
return false
|
95
111
|
end
|
96
112
|
end
|
97
113
|
FileUtils.mkdir_p "#{path_dir}" if ! File.directory?(path_dir)
|
98
|
-
# added line above to make windows compatible
|
99
|
-
# system "mkdir -p #{path_dir}" if ! File.directory?(path_dir)
|
100
114
|
File.open(File.expand_path(full_path), 'w'){|f| f.write rendered_template }
|
101
|
-
puts "
|
115
|
+
puts "#{GREEN} create#{CLEAR} #{full_path}"
|
102
116
|
else
|
103
117
|
# render to string
|
104
118
|
return rendered_template
|
@@ -114,11 +128,9 @@ module Deprec2
|
|
114
128
|
end
|
115
129
|
end
|
116
130
|
|
117
|
-
# XXX add :always and :never later - not sure how to set persistent value from here
|
118
|
-
# response = Capistrano::CLI.ui.ask "File exists. Overwrite? ([y]es, [n]o, [a]lways, n[e]ver)" do |q|
|
119
131
|
puts
|
120
|
-
response = Capistrano::CLI.ui.ask "
|
121
|
-
|
132
|
+
response = Capistrano::CLI.ui.ask "#{RED} conflict#{CLEAR} #{full_path}
|
133
|
+
Overwrite? ([y]es, [n]o, [d]iff)" do |q|
|
122
134
|
q.default = 'n'
|
123
135
|
end
|
124
136
|
|
@@ -225,14 +237,20 @@ module Deprec2
|
|
225
237
|
|
226
238
|
# create directory if it doesn't already exist
|
227
239
|
# set permissions and ownership
|
228
|
-
# XXX move mode, path and
|
229
240
|
def mkdir(path, options={})
|
230
241
|
run "test -d #{path} || #{sudo} mkdir -p #{path}"
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
242
|
+
if options[:mode]
|
243
|
+
run "#{sudo} chmod #{sprintf("%3o",options[:mode]||0755)} #{path}"
|
244
|
+
end
|
245
|
+
if options[:owner]
|
246
|
+
run "#{sudo} chown -R #{options[:owner]} #{path}"
|
247
|
+
end
|
248
|
+
if options[:group]
|
249
|
+
groupadd(options[:group])
|
250
|
+
end
|
251
|
+
if options[:group]
|
252
|
+
run "#{sudo} chgrp -R #{options[:group]} #{path}"
|
253
|
+
end
|
236
254
|
end
|
237
255
|
|
238
256
|
def create_src_dir
|
data/lib/deprec-core/defaults.rb
CHANGED
@@ -35,7 +35,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
35
35
|
# ssh_options[:forward_agent] = true
|
36
36
|
|
37
37
|
# SCM
|
38
|
-
|
38
|
+
set :scm, "git" # This is set to :svn by Capistrano deploy recipes
|
39
39
|
_cset :user, "deploy"
|
40
40
|
_cset :deploy_via, :remote_cache
|
41
41
|
_cset :branch, "master"
|
@@ -57,7 +57,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
57
57
|
# even when USER is set to someone else. Sorry windows!
|
58
58
|
_cset :current_user, `whoami`.chomp
|
59
59
|
|
60
|
-
#
|
61
|
-
_cset :run_method,
|
60
|
+
# Used by vmbuilder_plugins and Capistrano's deploy tasks
|
61
|
+
_cset :run_method, :sudo
|
62
62
|
|
63
63
|
end
|
data/lib/deprec-core/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: deprec-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 3.1.
|
5
|
+
version: 3.1.12
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mike Bailey
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- Rakefile
|
63
63
|
- deprec-core.gemspec
|
64
64
|
- lib/deprec-core.rb
|
65
|
-
- lib/deprec-core/canonical.rb
|
66
65
|
- lib/deprec-core/capistrano_extensions.rb
|
67
66
|
- lib/deprec-core/defaults.rb
|
68
67
|
- lib/deprec-core/deprec.rb
|
@@ -95,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
94
|
requirements: []
|
96
95
|
|
97
96
|
rubyforge_project: deprec-core
|
98
|
-
rubygems_version: 1.8.
|
97
|
+
rubygems_version: 1.8.6
|
99
98
|
signing_key:
|
100
99
|
specification_version: 3
|
101
100
|
summary: deprec-core provides extensions to Capistrano
|
@@ -1,108 +0,0 @@
|
|
1
|
-
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
-
# canonical.rb
|
3
|
-
#
|
4
|
-
# Running deprec:web:stop will be the same as running deprec:apache:stop or
|
5
|
-
# deprec:nginx:stop depending what you have chosen.
|
6
|
-
#
|
7
|
-
# generic namespaces are linked up to chosen applications at runtime but these
|
8
|
-
# stubs are so they'll be included in the output of "cap -T"
|
9
|
-
#
|
10
|
-
Capistrano::Configuration.instance(:must_exist).load do
|
11
|
-
|
12
|
-
# deprec defines some generic recipes for common services
|
13
|
-
# including ruby interpreter, web, app and database servers
|
14
|
-
#
|
15
|
-
# They default to my current favourites which you can over ride
|
16
|
-
#
|
17
|
-
# Service options
|
18
|
-
CHOICES_RUBY_VM = [:mri, :ree]
|
19
|
-
CHOICES_WEBSERVER = [:apache, :none] # :nginx not recipes out of date
|
20
|
-
CHOICES_APPSERVER = [:passenger, :none] # any colour you like guys
|
21
|
-
CHOICES_DATABASE = [:mysql, :postgresql, :sqlite, :none]
|
22
|
-
#
|
23
|
-
# Service defaults
|
24
|
-
_cset :ruby_vm_type, :mri
|
25
|
-
_cset :web_server_type, :apache
|
26
|
-
_cset :app_server_type, :passenger
|
27
|
-
_cset :db_server_type, :mysql
|
28
|
-
|
29
|
-
# Connect deprec:db to deprec:mysql, deprec:web to deprec:apache, etc
|
30
|
-
on :load, 'deprec:connect_canonical_tasks'
|
31
|
-
|
32
|
-
namespace :deprec do
|
33
|
-
task :connect_canonical_tasks do
|
34
|
-
# link application specific recipes into canonical task names
|
35
|
-
# e.g. deprec:web:restart => deprec:nginx:restart
|
36
|
-
|
37
|
-
|
38
|
-
namespaces_to_connect = { :web => :web_server_type,
|
39
|
-
:app => :app_server_type,
|
40
|
-
:db => :db_server_type,
|
41
|
-
:ruby => :ruby_vm_type
|
42
|
-
}
|
43
|
-
namespaces_to_connect.each do |server, choice|
|
44
|
-
server_type = send(choice).to_sym
|
45
|
-
if server_type != :none && deprec.respond_to?(server_type)
|
46
|
-
namespaces[server] = deprec.send(server_type)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
%w(ruby).each do |package|
|
53
|
-
namespace "deprec:#{package}" do
|
54
|
-
|
55
|
-
desc "Install #{package.capitalize}"
|
56
|
-
task :install do
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
%w(web app db).each do |server|
|
63
|
-
namespace "deprec:#{server}" do
|
64
|
-
|
65
|
-
desc "Install #{server.capitalize} server"
|
66
|
-
task :install, :roles => server do
|
67
|
-
end
|
68
|
-
|
69
|
-
desc "Generate config file(s) for #{server} server from template(s)"
|
70
|
-
task :config_gen do
|
71
|
-
end
|
72
|
-
|
73
|
-
desc "Deploy configuration files(s) for #{server} server"
|
74
|
-
task :config, :roles => server do
|
75
|
-
end
|
76
|
-
|
77
|
-
desc "Start #{server} server"
|
78
|
-
task :start, :roles => server do
|
79
|
-
end
|
80
|
-
|
81
|
-
desc "Stop #{server} server"
|
82
|
-
task :stop, :roles => server do
|
83
|
-
end
|
84
|
-
|
85
|
-
desc "Stop #{server} server"
|
86
|
-
task :restart, :roles => server do
|
87
|
-
end
|
88
|
-
|
89
|
-
desc "Enable startup script for #{server} server"
|
90
|
-
task :activate, :roles => server do
|
91
|
-
end
|
92
|
-
|
93
|
-
desc "Disable startup script for #{server} server"
|
94
|
-
task :deactivate, :roles => server do
|
95
|
-
end
|
96
|
-
|
97
|
-
desc "Backup data for #{server} server"
|
98
|
-
task :backup, :roles => server do
|
99
|
-
end
|
100
|
-
|
101
|
-
desc "Restore data for #{server} server from backup"
|
102
|
-
task :restore, :roles => server do
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|