colonize 0.2.0
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.ruby-gemset +1 -0
- data/Colonyfile +50 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/Vagrantfile +58 -0
- data/bin/colonize +33 -0
- data/bin/colonize-settle +33 -0
- data/colonize/apache2/apache2.conf +238 -0
- data/colonize.gemspec +46 -0
- data/colonize.iml +30 -0
- data/colonize.sublime-project +17 -0
- data/lib/colonize/__module.rb +42 -0
- data/lib/colonize/__version.rb +31 -0
- data/lib/colonize/apt_get.rb +34 -0
- data/lib/colonize/cli/settle.rb +65 -0
- data/lib/colonize/cli.rb +48 -0
- data/lib/colonize/config.rb +36 -0
- data/lib/colonize/connection.rb +118 -0
- data/lib/colonize/log.rb +42 -0
- data/lib/colonize/logable.rb +90 -0
- data/lib/colonize/machine.rb +109 -0
- data/lib/colonize/service/apache2.rb +53 -0
- data/lib/colonize/service/mysql.rb +36 -0
- data/lib/colonize/service/nginx.rb +30 -0
- data/lib/colonize/service.rb +99 -0
- data/lib/colonize/tools.rb +79 -0
- data/lib/colonize.rb +43 -0
- metadata +118 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
# Copyright (c) 2014 Jan Oetjen <oetjenj@gmail.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'colonize/apt_get'
|
23
|
+
require 'colonize/log'
|
24
|
+
require 'colonize/tools'
|
25
|
+
|
26
|
+
require 'net/ssh'
|
27
|
+
|
28
|
+
class Colonize::Service
|
29
|
+
|
30
|
+
include Colonize::AptGet
|
31
|
+
include Colonize::Log
|
32
|
+
include Colonize::Tools
|
33
|
+
|
34
|
+
def initialize(name, machine)
|
35
|
+
@name = name.to_s
|
36
|
+
@machine = machine
|
37
|
+
end
|
38
|
+
|
39
|
+
def exec(cmd, *opts)
|
40
|
+
@machine.exec cmd, *opts
|
41
|
+
end
|
42
|
+
|
43
|
+
def sudo(cmd, *opts)
|
44
|
+
@machine.sudo cmd, *opts
|
45
|
+
end
|
46
|
+
|
47
|
+
def install
|
48
|
+
apt_install '--no-install-recommends'
|
49
|
+
end
|
50
|
+
|
51
|
+
def start
|
52
|
+
service :start
|
53
|
+
end
|
54
|
+
|
55
|
+
def stop
|
56
|
+
service :stop
|
57
|
+
end
|
58
|
+
|
59
|
+
def restart
|
60
|
+
service :restart
|
61
|
+
end
|
62
|
+
|
63
|
+
def status
|
64
|
+
service :status
|
65
|
+
end
|
66
|
+
|
67
|
+
protected
|
68
|
+
|
69
|
+
def apt_get_do(cmd, *opts)
|
70
|
+
apt_get cmd.to_s, @name, *opts
|
71
|
+
end
|
72
|
+
|
73
|
+
def apt_install(*opts)
|
74
|
+
apt_get_do :install, *opts
|
75
|
+
end
|
76
|
+
|
77
|
+
def apt_purge(*opts)
|
78
|
+
apt_get_do :purge, *opts
|
79
|
+
end
|
80
|
+
|
81
|
+
def service(*opts)
|
82
|
+
sudo :service, @name, *opts
|
83
|
+
end
|
84
|
+
|
85
|
+
class << self
|
86
|
+
|
87
|
+
def descendants
|
88
|
+
desc = {}
|
89
|
+
|
90
|
+
ObjectSpace.each_object(Class) do |klass|
|
91
|
+
desc[klass.name.downcase.split('::')[-1].to_sym] = klass if klass < self
|
92
|
+
end
|
93
|
+
|
94
|
+
desc
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Copyright (c) 2014 Jan Oetjen <oetjenj@gmail.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
module Colonize::Tools
|
23
|
+
|
24
|
+
def cp(from, to)
|
25
|
+
sudo :cp, '-fR', from, to
|
26
|
+
end
|
27
|
+
|
28
|
+
def mv(from, to)
|
29
|
+
sudo :mv, from, to
|
30
|
+
end
|
31
|
+
|
32
|
+
def rm(file)
|
33
|
+
sudo :rm, '-fR', file
|
34
|
+
end
|
35
|
+
|
36
|
+
def ln(from, to)
|
37
|
+
sudo :ln, '-s', from, to
|
38
|
+
end
|
39
|
+
|
40
|
+
def template(tmpl, dest, opts = {})
|
41
|
+
f = "#{dest}/#{File.basename(tmpl)}"
|
42
|
+
|
43
|
+
cp "/vagrant/colonize/#{tmpl}", f
|
44
|
+
|
45
|
+
opts.each do |k, v|
|
46
|
+
info "Replacing ${{#{k}}} with '#{v}' in #{f} (#{tmpl})"
|
47
|
+
replace f, "\\$\\{\\{#{k}\\}\\}", v
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
protected
|
52
|
+
|
53
|
+
def replace(file, search, replace)
|
54
|
+
s = prep_search(search)
|
55
|
+
r = prep_replace(replace)
|
56
|
+
|
57
|
+
sudo :sed, '-i', '-E', "'s/#{s}/#{r}/g'", file
|
58
|
+
end
|
59
|
+
|
60
|
+
def replace_or_append(file, search, replace)
|
61
|
+
s = prep_search(search)
|
62
|
+
r = prep_replace(replace)
|
63
|
+
|
64
|
+
exec :sudo, :grep, '-q', '-E', "'#{s}'", file, '&&',
|
65
|
+
:sudo, :sed, '-i', '-E', "'s/#{s}/#{r}/'", file, '||',
|
66
|
+
:sudo, :sed, '-i', '-E', "'$ a\\#{r}'", file
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def prep_search(str)
|
72
|
+
prep_replace(str).gsub(/\s+/, '\s+')
|
73
|
+
end
|
74
|
+
|
75
|
+
def prep_replace(str)
|
76
|
+
str.gsub(/\//, '\\/')
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
data/lib/colonize.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Copyright (c) 2014 Jan Oetjen <oetjenj@gmail.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'colonize/__version'
|
23
|
+
|
24
|
+
#:stopdoc:
|
25
|
+
ColonizeVERSION = Colonize::VERSION
|
26
|
+
#:startdoc:
|
27
|
+
|
28
|
+
require 'colonize/__module'
|
29
|
+
require 'colonize/config'
|
30
|
+
require 'colonize/machine'
|
31
|
+
require 'colonize/service'
|
32
|
+
require 'colonize/connection'
|
33
|
+
require 'colonize/apt_get'
|
34
|
+
require 'colonize/logable'
|
35
|
+
require 'colonize/log'
|
36
|
+
require 'colonize/tools'
|
37
|
+
|
38
|
+
require 'colonize/service/apache2'
|
39
|
+
require 'colonize/service/nginx'
|
40
|
+
require 'colonize/service/mysql'
|
41
|
+
|
42
|
+
require 'colonize/cli'
|
43
|
+
require 'colonize/cli/settle'
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: colonize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Oetjen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: net-ssh
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: quickl
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Optional.
|
56
|
+
email:
|
57
|
+
- oetjenj@gmail.com
|
58
|
+
executables:
|
59
|
+
- colonize
|
60
|
+
- colonize-settle
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- .ruby-gemset
|
66
|
+
- Colonyfile
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- Vagrantfile
|
72
|
+
- bin/colonize
|
73
|
+
- bin/colonize-settle
|
74
|
+
- colonize.gemspec
|
75
|
+
- colonize.iml
|
76
|
+
- colonize.sublime-project
|
77
|
+
- colonize/apache2/apache2.conf
|
78
|
+
- lib/colonize.rb
|
79
|
+
- lib/colonize/__module.rb
|
80
|
+
- lib/colonize/__version.rb
|
81
|
+
- lib/colonize/apt_get.rb
|
82
|
+
- lib/colonize/cli.rb
|
83
|
+
- lib/colonize/cli/settle.rb
|
84
|
+
- lib/colonize/config.rb
|
85
|
+
- lib/colonize/connection.rb
|
86
|
+
- lib/colonize/log.rb
|
87
|
+
- lib/colonize/logable.rb
|
88
|
+
- lib/colonize/machine.rb
|
89
|
+
- lib/colonize/service.rb
|
90
|
+
- lib/colonize/service/apache2.rb
|
91
|
+
- lib/colonize/service/mysql.rb
|
92
|
+
- lib/colonize/service/nginx.rb
|
93
|
+
- lib/colonize/tools.rb
|
94
|
+
homepage: ''
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.1.11
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: A simple provisioning system for Vagrant.
|
118
|
+
test_files: []
|