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.
@@ -0,0 +1,31 @@
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
23
+ VERSION = '0.2.0'.freeze
24
+
25
+ module Version # :nodoc: all
26
+ MAJOR, MINOR, BUILD, *OTHER = Colonize::VERSION.split '.'
27
+
28
+ NUMBERS = [MAJOR, MINOR, BUILD, *OTHER]
29
+ end
30
+
31
+ end
@@ -0,0 +1,34 @@
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::AptGet
23
+
24
+ private
25
+
26
+ def apt_get(cmd, *opts)
27
+ sudo 'DEBIAN_FRONTEND=noninteractive', 'apt-get', cmd, *opts, '--assume-yes'
28
+ end
29
+
30
+ def debconf(cmd, *opts)
31
+ sudo :debconf, '--frontend=noninteractive', cmd, *opts
32
+ end
33
+
34
+ end
@@ -0,0 +1,65 @@
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/log'
23
+
24
+ require 'quickl'
25
+
26
+ class Colonize::CLI::Settle < Quickl::Command(__FILE__, __LINE__)
27
+
28
+ include Colonize::Log
29
+
30
+ def execute(_)
31
+ handle_exception do
32
+ load_colonyfile
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def load_colonyfile
39
+ handle_exception do
40
+ here = Dir.pwd
41
+
42
+ until File.exists? 'Colonyfile'
43
+ Dir.chdir '..'
44
+ fail 'Colonyfile not found' if here == Dir.pwd
45
+ here = Dir.pwd
46
+ end
47
+
48
+ info "(in #{Dir.pwd})"
49
+
50
+ handle_exception do
51
+ load './Colonyfile'
52
+ end
53
+ end
54
+ end
55
+
56
+ def handle_exception
57
+ yield
58
+ rescue SystemExit
59
+ raise
60
+ rescue Exception => _
61
+ error ex
62
+ #raise
63
+ end
64
+
65
+ end
@@ -0,0 +1,48 @@
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 'quickl'
23
+
24
+ class Colonize::CLI < Quickl::Delegator(__FILE__, __LINE__)
25
+
26
+ # Single command version
27
+ VERSION = Colonize::VERSION
28
+
29
+ # Install options
30
+ options do |opt|
31
+
32
+ # Show the help and exit
33
+ opt.on_tail('--help', 'Show help') do
34
+ raise Quickl::Help
35
+ end
36
+
37
+ # Show version and exit
38
+ opt.on_tail('--version', 'Show version') do
39
+ raise Quickl::Exit, "#{Quickl.program_name} #{VERSION} (c) 2014, Jan Oetjen <oetjenj@gmail.com>"
40
+ end
41
+
42
+ end
43
+
44
+ def execute(args)
45
+ Colonize::CLI::Settle.run(args)
46
+ end
47
+
48
+ end
@@ -0,0 +1,36 @@
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/machine'
23
+
24
+ class Colonize::Config
25
+
26
+ def initialize(version)
27
+ @version = version
28
+ end
29
+
30
+ def machine(name, host: nil, port: 2222)
31
+ m = Colonize::Machine.new name, host: host, port: port
32
+ yield m if block_given?
33
+ m
34
+ end
35
+
36
+ end
@@ -0,0 +1,118 @@
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/log'
23
+
24
+ class Colonize::Connection
25
+
26
+ include Colonize::Log
27
+
28
+ def initialize(host, port: 2222, user: 'vagrant', password: 'vagrant')
29
+ @host = host
30
+ @port = port
31
+ @user = user
32
+ @pass = password
33
+ @ssh = nil
34
+
35
+ ObjectSpace.define_finalizer(self, proc { finalize })
36
+ end
37
+
38
+ def user=(user)
39
+ @user = user
40
+ end
41
+
42
+ def password=(password)
43
+ @pass = password
44
+ end
45
+
46
+ def ssh
47
+ open unless open?
48
+ yield self
49
+ end
50
+
51
+ def exec(cmd, *opts)
52
+ x = "#{cmd.to_s} #{opts.join(' ')}"
53
+
54
+ #info x
55
+
56
+ open unless open?
57
+
58
+ out = ''
59
+ err = ''
60
+
61
+ @ssh.exec!(x) do |_, stream, data|
62
+ out << data if stream == :stdout
63
+ err << data if stream == :stderr
64
+
65
+ out = log(out) do |msg|
66
+ info msg
67
+ end
68
+
69
+ err = log(err) do |msg|
70
+ error msg
71
+ end
72
+ end
73
+
74
+ info out unless out.empty?
75
+ error err unless err.empty?
76
+ end
77
+
78
+ def sudo(cmd, *opts)
79
+ exec :sudo, cmd, *opts
80
+ end
81
+
82
+ private
83
+
84
+ def finalize
85
+ close if open?
86
+ end
87
+
88
+ def open?
89
+ return true if @ssh
90
+ false
91
+ end
92
+
93
+ def open
94
+ @ssh = Net::SSH.start @host, @user, password: @pass, port: @port unless open?
95
+ end
96
+
97
+ def closed?
98
+ return @ssh.closed? if open?
99
+ true
100
+ end
101
+
102
+ def close
103
+ @ssh.close unless @ssh.closed?
104
+ @ssh = nil
105
+ end
106
+
107
+ def log(buffer)
108
+ x = buffer.split(?\n, 2)
109
+
110
+ if x.length == 2
111
+ yield x[0]
112
+ return x[1]
113
+ end
114
+
115
+ buffer
116
+ end
117
+
118
+ end
@@ -0,0 +1,42 @@
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/logable'
23
+
24
+ module Colonize::Log
25
+
26
+ def debug(*msg)
27
+ Colonize::Logable.debug *msg
28
+ end
29
+
30
+ def info(*msg)
31
+ Colonize::Logable.info *msg
32
+ end
33
+
34
+ def error(*msg)
35
+ Colonize::Logable.error *msg
36
+ end
37
+
38
+ def fatal(*msg)
39
+ Colonize::Logable.fatal *msg
40
+ end
41
+
42
+ end
@@ -0,0 +1,90 @@
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 'logger'
23
+
24
+ class Colonize::Logable
25
+
26
+ def initialize
27
+ @out = Logger.new(STDOUT)
28
+ @err = Logger.new(STDERR)
29
+
30
+ f = proc do |_, _, _, msg|
31
+ "%s\n" % [msg.chomp]
32
+ end
33
+
34
+ @out.formatter = f
35
+ @err.formatter = f
36
+
37
+ @name = nil
38
+ end
39
+
40
+ def debug(*msg)
41
+ log @out, Logger::DEBUG, *msg if @out.debug?
42
+ end
43
+
44
+ def info(*msg)
45
+ log @out, Logger::INFO, *msg if @out.debug?
46
+ end
47
+
48
+ def error(*msg)
49
+ log @err, Logger::ERROR, *msg if @err.debug?
50
+ end
51
+
52
+ def fatal(*msg)
53
+ log @err, Logger::FATAL, *msg if @err.debug?
54
+ end
55
+
56
+ private
57
+
58
+ def log(logger, sev, *msg)
59
+ msg.join(' ').each_line do |line|
60
+ logger.log sev, line.chomp
61
+ end
62
+ end
63
+
64
+ class << self
65
+
66
+ def debug(*msg)
67
+ instance.debug *msg
68
+ end
69
+
70
+ def info(*msg)
71
+ instance.info *msg
72
+ end
73
+
74
+ def error(*msg)
75
+ instance.error *msg
76
+ end
77
+
78
+ def fatal(*msg)
79
+ instance.fatal *msg
80
+ end
81
+
82
+ private
83
+
84
+ def instance
85
+ @logable ||= Colonize::Logable.new
86
+ end
87
+
88
+ end
89
+
90
+ end
@@ -0,0 +1,109 @@
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/service'
23
+ require 'colonize/connection'
24
+ require 'colonize/apt_get'
25
+ require 'colonize/log'
26
+ require 'colonize/tools'
27
+
28
+ require 'net/ssh'
29
+
30
+ class Colonize::Machine
31
+
32
+ include Colonize::AptGet
33
+ include Colonize::Log
34
+ include Colonize::Tools
35
+
36
+ def initialize(name, host: 'localhost', port: 2222)
37
+ @name = name.to_s
38
+ @conn = Colonize::Connection.new host, port: port
39
+ @update = false
40
+ @upgrade = false
41
+
42
+ ObjectSpace.define_finalizer(self, proc { finalize })
43
+
44
+ info "Colonizeing '#{@name}'..."
45
+ end
46
+
47
+ def service(name)
48
+ k = name.downcase.to_sym
49
+ d = Colonize::Service.descendants
50
+
51
+ if d.has_key?(k)
52
+ s = d[k].new(name, self)
53
+ else
54
+ s = Colonize::Service.new(name, self)
55
+ end
56
+ yield s if block_given?
57
+ s
58
+ end
59
+
60
+ def user=(user)
61
+ @conn.user = user
62
+ end
63
+
64
+ def password=(password)
65
+ @conn.password = password
66
+ end
67
+
68
+ def exec(cmd, *opts)
69
+ @conn.exec cmd, *opts
70
+ end
71
+
72
+ def sudo(cmd, *opts)
73
+ @conn.sudo cmd, *opts
74
+ end
75
+
76
+ def update
77
+ return if @update
78
+
79
+ apt_get :update, '--assume-yes'
80
+
81
+ @update = true
82
+ end
83
+
84
+ def upgrade
85
+ return if @upgrade
86
+
87
+ update
88
+ apt_get :upgrade, '--assume-yes'
89
+
90
+ @upgrade = true
91
+ end
92
+
93
+ def mount_temp
94
+ replace_or_append '/etc/fstab',
95
+ '^tmpfs /tmp tmpfs noatime,nosuid,nodev 0 0',
96
+ 'tmpfs /tmp tmpfs noatime,nosuid,nodev 0 0'
97
+ sudo :mount, '-a'
98
+ end
99
+
100
+ private
101
+
102
+ def finalize
103
+ apt_get :autoremove, '--purge', '--assume-yes'
104
+ apt_get :clean, '--assume-yes'
105
+
106
+ @conn = nil
107
+ end
108
+
109
+ end
@@ -0,0 +1,53 @@
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/service'
23
+
24
+ class Colonize::Service::Apache2 < Colonize::Service
25
+
26
+ def initialize(name, machine)
27
+ super name, machine
28
+ end
29
+
30
+ def user=(user)
31
+ stop
32
+ envvar 'export APACHE_RUN_USER=', user
33
+ start
34
+ end
35
+
36
+ def group=(group)
37
+ stop
38
+ envvar 'export APACHE_RUN_GROUP=', group
39
+ start
40
+ end
41
+
42
+ def stop
43
+ super
44
+ rm '/var/lock/apache2'
45
+ end
46
+
47
+ private
48
+
49
+ def envvar(line, replace)
50
+ replace '/etc/apache2/envvars', "^#{line}.*$", "#{line}#{replace}"
51
+ end
52
+
53
+ end
@@ -0,0 +1,36 @@
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/service'
23
+
24
+ class Colonize::Service::Mysql < Colonize::Service
25
+
26
+ def initialize(name, machine)
27
+ super name, machine
28
+ end
29
+
30
+ protected
31
+
32
+ def apt_get_do(cmd, *opts)
33
+ apt_get cmd.to_s, 'mysql-server', 'mysql-client', *opts
34
+ end
35
+
36
+ end
@@ -0,0 +1,30 @@
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/service'
23
+
24
+ class Colonize::Service::Nginx < Colonize::Service
25
+
26
+ def initialize(name, machine)
27
+ super name, machine
28
+ end
29
+
30
+ end