capistrano-platform-recognizer 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +1 -0
- data/capistrano-platform-recognizer.gemspec +19 -0
- data/lib/capistrano-platform-recognizer.rb +54 -0
- data/lib/capistrano-platform-recognizer/version.rb +7 -0
- metadata +54 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Takeshi KOMIYA
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Capistrano::Platform::Recognizer
|
|
2
|
+
|
|
3
|
+
Capistrano task to recognize platform of target hosts
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'capistrano-platform-recognizer'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install capistrano-platform-recognizer
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
load capistrano-rails-dbinit in your config/deploy.rb:
|
|
22
|
+
|
|
23
|
+
require 'capistrano-rails-dbinit'
|
|
24
|
+
|
|
25
|
+
And then, capistrano-platform-recognizer runs automatically and
|
|
26
|
+
set platform informations to each hosts.
|
|
27
|
+
|
|
28
|
+
- :osname (:linux, :darwin, etc)
|
|
29
|
+
- :distro (:centos5, :rhel5, :amazon, etc)
|
|
30
|
+
- :cpu (:i386 or :x86_64)
|
|
31
|
+
|
|
32
|
+
You can filter with platform infomation using :only filter:
|
|
33
|
+
|
|
34
|
+
task(:setup_apps, :only => {:distro => :centos5}) do
|
|
35
|
+
# ...
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
## Contributing
|
|
39
|
+
|
|
40
|
+
1. Fork it
|
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'capistrano-platform-recognizer/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
gem.name = "capistrano-platform-recognizer"
|
|
8
|
+
gem.version = Capistrano::Platform::Recognizer::VERSION
|
|
9
|
+
gem.authors = ["Takeshi KOMIYA"]
|
|
10
|
+
gem.email = ["i.tkomiya@gmail.com"]
|
|
11
|
+
gem.description = %q{Capistrano task to recognize platform of target hosts}
|
|
12
|
+
gem.summary = %q{Capistrano task to recognize platform of target hosts}
|
|
13
|
+
gem.homepage = "https://github.com/tk0miya/capistrano-platform-recognizer"
|
|
14
|
+
|
|
15
|
+
gem.files = `git ls-files`.split($/)
|
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
gem.require_paths = ["lib"]
|
|
19
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require "capistrano-platform-recognizer/version"
|
|
2
|
+
|
|
3
|
+
Capistrano::Configuration.instance.load do
|
|
4
|
+
namespace :distro do
|
|
5
|
+
def guess_distro(issue)
|
|
6
|
+
case issue
|
|
7
|
+
when %r{CentOS.*? 5}
|
|
8
|
+
:centos5
|
|
9
|
+
when %r{CentOS.*? 6}
|
|
10
|
+
:centos6
|
|
11
|
+
when %r{Amazon Linux}
|
|
12
|
+
:amazon
|
|
13
|
+
when %r{Red Hat Enterprise.*? 5}
|
|
14
|
+
:rhel5
|
|
15
|
+
when %r{Red Hat Enterprise.*? 6}
|
|
16
|
+
:rhel6
|
|
17
|
+
else
|
|
18
|
+
nil
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def guess_cpu(machine_info)
|
|
23
|
+
case machine_info
|
|
24
|
+
when "x86_64", "amd64"
|
|
25
|
+
:x86_64
|
|
26
|
+
else
|
|
27
|
+
:i386
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
task :detect do
|
|
32
|
+
find_servers_for_task(current_task).each do |server|
|
|
33
|
+
osname = capture("uname -s", :hosts => server).chomp
|
|
34
|
+
server.options[:osname] = osname.downcase.to_sym
|
|
35
|
+
|
|
36
|
+
if server.options[:osname] == :linux
|
|
37
|
+
issue = capture("cat /etc/issue || lsb_release -d -s", :hosts => server).chomp
|
|
38
|
+
server.options[:distro] = guess_distro(issue)
|
|
39
|
+
|
|
40
|
+
machine_info = capture("uname -m", :hosts => server).chomp
|
|
41
|
+
server.options[:cpu] = guess_cpu(machine_info)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
on :start do
|
|
47
|
+
if top.namespaces.key?(:multistage)
|
|
48
|
+
after "multistage:ensure", "distro:detect"
|
|
49
|
+
else
|
|
50
|
+
detect
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: capistrano-platform-recognizer
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Takeshi KOMIYA
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: Capistrano task to recognize platform of target hosts
|
|
15
|
+
email:
|
|
16
|
+
- i.tkomiya@gmail.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- .gitignore
|
|
22
|
+
- Gemfile
|
|
23
|
+
- LICENSE.txt
|
|
24
|
+
- README.md
|
|
25
|
+
- Rakefile
|
|
26
|
+
- capistrano-platform-recognizer.gemspec
|
|
27
|
+
- lib/capistrano-platform-recognizer.rb
|
|
28
|
+
- lib/capistrano-platform-recognizer/version.rb
|
|
29
|
+
homepage: https://github.com/tk0miya/capistrano-platform-recognizer
|
|
30
|
+
licenses: []
|
|
31
|
+
post_install_message:
|
|
32
|
+
rdoc_options: []
|
|
33
|
+
require_paths:
|
|
34
|
+
- lib
|
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
|
+
none: false
|
|
37
|
+
requirements:
|
|
38
|
+
- - ! '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
|
+
none: false
|
|
43
|
+
requirements:
|
|
44
|
+
- - ! '>='
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
requirements: []
|
|
48
|
+
rubyforge_project:
|
|
49
|
+
rubygems_version: 1.8.24
|
|
50
|
+
signing_key:
|
|
51
|
+
specification_version: 3
|
|
52
|
+
summary: Capistrano task to recognize platform of target hosts
|
|
53
|
+
test_files: []
|
|
54
|
+
has_rdoc:
|