run-redmine 1.0.1 → 1.0.2
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 +4 -4
- data/docker/Dockerfile +1 -1
- data/lib/redmine/cli/arguments.rb +1 -1
- data/lib/redmine/cli/command_factory.rb +15 -0
- data/lib/redmine/cli/parser.rb +31 -10
- data/lib/redmine/commands/docker/create.rb +11 -3
- data/lib/redmine/commands/help.rb +25 -0
- data/lib/redmine/commands/list.rb +4 -3
- data/lib/redmine/commands/logs.rb +23 -0
- data/lib/redmine/commands/shell.rb +16 -2
- data/lib/redmine/commands/show.rb +22 -0
- data/lib/redmine/commands/start.rb +9 -8
- data/lib/redmine/commands/stop.rb +24 -0
- data/lib/redmine/utils/plugin_installer.rb +5 -3
- data/lib/redmine/utils/system.rb +13 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5e72f3968d4effd9930cc745514d9146d1a9f3cabad2743d5a72dcaccc5f256
|
4
|
+
data.tar.gz: 59f802a957d7b642fa53a888d1902486d60caf02c0c0996f2b4f8dfa9ef2e411
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd5047bfb32ab58b68aa265f6e2a3cfe31a53c750812c075aa5d604edc80093241b86cb03a708f963d6c8acefcced91ba8652dfeb23a8a7d3bc407b183d50961
|
7
|
+
data.tar.gz: 9c1c25b70a01a6d04e0b6926e49caa81c6357b9888af7ce2020335705998321b603a0fe35a3f0ceeffae5687765678d2eb99183a0c17362cb1efc4b7e386caa4
|
data/docker/Dockerfile
CHANGED
@@ -69,7 +69,7 @@ RUN mkdir /root/.ssh
|
|
69
69
|
ADD ./sshconfig /root/.ssh/config
|
70
70
|
RUN chmod -R 600 /root/.ssh
|
71
71
|
|
72
|
-
RUN gem install run-redmine --no-ri --no-rdoc && rbenv rehash
|
72
|
+
RUN gem install run-redmine -v 1.0.1 --no-ri --no-rdoc && rbenv rehash
|
73
73
|
|
74
74
|
ARG port=3000
|
75
75
|
ENV PORT=$port
|
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
require_relative '../commands/start'
|
4
4
|
require_relative '../commands/pull_plugins'
|
5
|
+
require_relative '../commands/stop'
|
6
|
+
require_relative '../commands/show'
|
7
|
+
require_relative '../commands/shell'
|
8
|
+
require_relative '../commands/help'
|
9
|
+
require_relative '../commands/logs'
|
5
10
|
|
6
11
|
module Redmine
|
7
12
|
module CLI
|
@@ -19,6 +24,16 @@ module Redmine
|
|
19
24
|
Redmine::Commands::List.new
|
20
25
|
when Redmine::CLI::Parser::COMMAND_INSTALL_PLUGINS
|
21
26
|
Redmine::Commands::PullPlugins.new(@arguments)
|
27
|
+
when Redmine::CLI::Parser::COMMAND_STOP
|
28
|
+
Redmine::Commands::Stop.new(@arguments)
|
29
|
+
when Redmine::CLI::Parser::COMMAND_SHOW
|
30
|
+
Redmine::Commands::Show.new(@arguments)
|
31
|
+
when Redmine::CLI::Parser::COMMAND_SHELL
|
32
|
+
Redmine::Commands::Shell.new(@arguments)
|
33
|
+
when Redmine::CLI::Parser::COMMAND_HELP
|
34
|
+
Redmine::Commands::Help.new
|
35
|
+
when Redmine::CLI::Parser::COMMAND_LOGS
|
36
|
+
Redmine::Commands::Logs.new(@arguments)
|
22
37
|
else
|
23
38
|
raise Redmine::CLI::UnclearCommand, @arguments.command
|
24
39
|
end
|
data/lib/redmine/cli/parser.rb
CHANGED
@@ -13,11 +13,13 @@ module Redmine
|
|
13
13
|
class Parser
|
14
14
|
COMMANDS = [
|
15
15
|
COMMAND_START = 'start',
|
16
|
+
COMMAND_STOP = 'stop',
|
16
17
|
COMMAND_LIST = 'list',
|
17
18
|
COMMAND_SHOW = 'show',
|
18
19
|
COMMAND_SHELL = 'shell',
|
19
|
-
|
20
|
-
|
20
|
+
COMMAND_INSTALL_PLUGINS = 'install-plugins',
|
21
|
+
COMMAND_HELP = 'help',
|
22
|
+
COMMAND_LOGS = 'logs',
|
21
23
|
].freeze
|
22
24
|
|
23
25
|
attr_reader :arguments
|
@@ -30,12 +32,18 @@ module Redmine
|
|
30
32
|
|
31
33
|
def parse(args)
|
32
34
|
@arguments = ::Redmine::CLI::Arguments.new
|
33
|
-
# options = OpenStruct.new
|
34
35
|
opt_parser = OptionParser.new do |opts|
|
36
|
+
opts.on('-p', '--privileged', 'Run in privileged mode') do |p|
|
37
|
+
@arguments.privileged = p
|
38
|
+
end
|
35
39
|
end
|
36
40
|
|
37
41
|
opt_parser.parse!(args)
|
38
|
-
|
42
|
+
if (args.size > 0)
|
43
|
+
parse_remainings(args)
|
44
|
+
else
|
45
|
+
print_help
|
46
|
+
end
|
39
47
|
end
|
40
48
|
|
41
49
|
def parse_remainings(args)
|
@@ -43,14 +51,18 @@ module Redmine
|
|
43
51
|
case command
|
44
52
|
when COMMAND_START
|
45
53
|
@arguments.command = COMMAND_START
|
54
|
+
when COMMAND_STOP
|
55
|
+
process_stop_command(args)
|
46
56
|
when COMMAND_LIST
|
47
57
|
@arguments.command = COMMAND_LIST
|
48
58
|
when COMMAND_SHOW
|
49
59
|
process_show_command(args)
|
50
60
|
when COMMAND_SHELL
|
51
61
|
process_shell_command(args)
|
52
|
-
when
|
53
|
-
|
62
|
+
when COMMAND_HELP
|
63
|
+
print_help
|
64
|
+
when COMMAND_LOGS
|
65
|
+
process_logs_command(args)
|
54
66
|
when COMMAND_INSTALL_PLUGINS
|
55
67
|
process_install_plugins_command(args)
|
56
68
|
else
|
@@ -59,18 +71,23 @@ module Redmine
|
|
59
71
|
end
|
60
72
|
end
|
61
73
|
|
74
|
+
def process_stop_command(args)
|
75
|
+
@arguments.command = COMMAND_STOP
|
76
|
+
@arguments.instance_name = args.shift
|
77
|
+
end
|
78
|
+
|
62
79
|
def process_show_command(args)
|
63
80
|
@arguments.command = COMMAND_SHOW
|
64
81
|
@arguments.instance_name = args.shift
|
65
82
|
end
|
66
83
|
|
67
|
-
def
|
68
|
-
@arguments.command =
|
84
|
+
def process_logs_command(args)
|
85
|
+
@arguments.command = COMMAND_LOGS
|
69
86
|
@arguments.instance_name = args.shift
|
70
87
|
end
|
71
88
|
|
72
|
-
def
|
73
|
-
@arguments.command =
|
89
|
+
def process_shell_command(args)
|
90
|
+
@arguments.command = COMMAND_SHELL
|
74
91
|
@arguments.instance_name = args.shift
|
75
92
|
end
|
76
93
|
|
@@ -79,6 +96,10 @@ module Redmine
|
|
79
96
|
@arguments.config_path = args.shift
|
80
97
|
@arguments.plugins_path = args.shift
|
81
98
|
end
|
99
|
+
|
100
|
+
def print_help
|
101
|
+
@arguments.command = COMMAND_HELP
|
102
|
+
end
|
82
103
|
end
|
83
104
|
end
|
84
105
|
end
|
@@ -4,12 +4,20 @@ module Redmine
|
|
4
4
|
module Commands
|
5
5
|
module Docker
|
6
6
|
class Create
|
7
|
-
def initialize(config)
|
8
|
-
@config
|
7
|
+
def initialize(config, arguments)
|
8
|
+
@config = config
|
9
|
+
@arguments = arguments
|
9
10
|
end
|
10
11
|
|
11
12
|
def command_line
|
12
|
-
"docker create --name=#{@config.name} --mount type=bind,source=#{File.expand_path(@config.key)},target=/root/.ssh/id_rsa --mount type=bind,source=#{File.expand_path(@config.key)}.pub,target=/root/.ssh/id_rsa.pub -e PORT=#{@config.port} -p #{@config.port}:#{@config.port} --mount source=redmine-pg,target=/var/lib/postgresql/9.5/main redmineup/demo-base"
|
13
|
+
"docker create --name=#{@config.name} #{privileged_mode} --mount type=bind,source=#{File.expand_path(@config.key)},target=/root/.ssh/id_rsa --mount type=bind,source=#{File.expand_path(@config.key)}.pub,target=/root/.ssh/id_rsa.pub -e PORT=#{@config.port} -p #{@config.port}:#{@config.port} --mount source=redmine-pg,target=/var/lib/postgresql/9.5/main redmineup/demo-base"
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def privileged_mode
|
19
|
+
return '' unless @arguments.privileged
|
20
|
+
'--privileged'
|
13
21
|
end
|
14
22
|
end
|
15
23
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Redmine
|
4
|
+
module Commands
|
5
|
+
class Help
|
6
|
+
def execute
|
7
|
+
puts <<~HELP
|
8
|
+
Usage:
|
9
|
+
redmine [options] <command>
|
10
|
+
|
11
|
+
Where OPTIONS:
|
12
|
+
-p --privileged - Run in privileged mode (required for occupying ports below 1024)
|
13
|
+
|
14
|
+
Where COMMANDS:
|
15
|
+
start - run redmine
|
16
|
+
list - inspect list of running instances
|
17
|
+
show - print information about specific instance
|
18
|
+
shell - get shell into specific instance
|
19
|
+
install_plugins <config> <destination folder> - for internal use
|
20
|
+
logs - start tailing logs
|
21
|
+
HELP
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -2,18 +2,19 @@
|
|
2
2
|
|
3
3
|
require 'ostruct'
|
4
4
|
|
5
|
-
require_relative '
|
5
|
+
require_relative '../utils/system'
|
6
|
+
require_relative './list_printer'
|
6
7
|
|
7
8
|
module Redmine
|
8
9
|
module Commands
|
9
10
|
DOCKER_LIST_COMMAND = 'docker ps'
|
10
11
|
class List
|
11
12
|
def results
|
12
|
-
parse(
|
13
|
+
parse(Redmine::Utils::System.new.execute_and_return('docker ps'))
|
13
14
|
end
|
14
15
|
|
15
16
|
def execute
|
16
|
-
Redmine::Commands::ListPrinter.new.
|
17
|
+
Redmine::Commands::ListPrinter.new.print(results)
|
17
18
|
end
|
18
19
|
|
19
20
|
private
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Redmine
|
4
|
+
module Commands
|
5
|
+
class Logs
|
6
|
+
def initialize(args)
|
7
|
+
@args = args
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute
|
11
|
+
shell.execute(
|
12
|
+
"docker exec -it redmine-run__#{@args.instance_name} /usr/bin/tail -f /var/www/redmine/log/development.log"
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def shell
|
19
|
+
@shell ||= Redmine::Utils::System.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,8 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Redmine
|
2
4
|
module Commands
|
3
5
|
class Shell
|
4
|
-
def
|
5
|
-
|
6
|
+
def initialize(args)
|
7
|
+
@args = args
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute
|
11
|
+
shell.execute(
|
12
|
+
"docker exec -it redmine-run__#{@args.instance_name} /bin/bash"
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def shell
|
19
|
+
@shell ||= Redmine::Utils::System.new
|
6
20
|
end
|
7
21
|
end
|
8
22
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Redmine
|
2
|
+
module Commands
|
3
|
+
class Show
|
4
|
+
def initialize(args)
|
5
|
+
@args = args
|
6
|
+
end
|
7
|
+
|
8
|
+
def execute
|
9
|
+
shell.execute(
|
10
|
+
"docker exec -it redmine-run__#{@args.instance_name} cat /config.yml"
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def shell
|
17
|
+
@shell ||= Redmine::Utils::System.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -21,7 +21,7 @@ module Redmine
|
|
21
21
|
def execute
|
22
22
|
run_command Redmine::Commands::Docker::Build.new(config).command_line
|
23
23
|
run_command Redmine::Commands::Docker::CreateVolume.new(config).command_line
|
24
|
-
run_command Redmine::Commands::Docker::Create.new(config).command_line
|
24
|
+
run_command Redmine::Commands::Docker::Create.new(config, arguments).command_line
|
25
25
|
run_command Redmine::Commands::Docker::CopyConfig.new(config).command_line
|
26
26
|
run_command Redmine::Commands::Docker::Start.new(config).command_line
|
27
27
|
end
|
@@ -39,11 +39,9 @@ module Redmine
|
|
39
39
|
end
|
40
40
|
}
|
41
41
|
|
42
|
-
t_err = Thread.new
|
43
|
-
until error.eof?
|
44
|
-
|
45
|
-
end
|
46
|
-
}
|
42
|
+
t_err = Thread.new do
|
43
|
+
putc error.readchar until error.eof?
|
44
|
+
end
|
47
45
|
|
48
46
|
t_out = Thread.new {
|
49
47
|
until output.eof?
|
@@ -51,8 +49,11 @@ module Redmine
|
|
51
49
|
end
|
52
50
|
}
|
53
51
|
|
54
|
-
|
55
|
-
|
52
|
+
begin
|
53
|
+
Process.waitpid(process_thread.pid)
|
54
|
+
rescue StandardError
|
55
|
+
nil
|
56
|
+
end
|
56
57
|
|
57
58
|
t_err.join
|
58
59
|
t_out.join
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Redmine
|
2
|
+
module Commands
|
3
|
+
class Stop
|
4
|
+
def initialize(args)
|
5
|
+
@args = args
|
6
|
+
end
|
7
|
+
|
8
|
+
def execute
|
9
|
+
shell.execute(
|
10
|
+
"docker stop redmine-run__#{@args.instance_name}"
|
11
|
+
)
|
12
|
+
shell.execute(
|
13
|
+
"docker rm redmine-run__#{@args.instance_name}"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def shell
|
20
|
+
@shell ||= Redmine::Utils::System.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './system'
|
4
|
+
|
1
5
|
module Redmine
|
2
6
|
module Utils
|
3
7
|
class PluginInstaller
|
@@ -27,7 +31,7 @@ module Redmine
|
|
27
31
|
end
|
28
32
|
|
29
33
|
def shell
|
30
|
-
@shell ||= Redmine::
|
34
|
+
@shell ||= Redmine::Utils::System.new
|
31
35
|
end
|
32
36
|
|
33
37
|
def clone_plugin
|
@@ -48,14 +52,12 @@ module Redmine
|
|
48
52
|
end
|
49
53
|
|
50
54
|
def bundle
|
51
|
-
puts "bundling"
|
52
55
|
shell.execute(
|
53
56
|
"cd #{dest_dir}; cd ..; bundle"
|
54
57
|
)
|
55
58
|
end
|
56
59
|
|
57
60
|
def migrate
|
58
|
-
puts "migrating"
|
59
61
|
shell.execute(
|
60
62
|
"cd #{dest_dir}; cd ..; bundle exec rake redmine:plugins"
|
61
63
|
)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: run-redmine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Malyshev
|
@@ -34,13 +34,18 @@ files:
|
|
34
34
|
- lib/redmine/commands/docker/create.rb
|
35
35
|
- lib/redmine/commands/docker/create_volume.rb
|
36
36
|
- lib/redmine/commands/docker/start.rb
|
37
|
+
- lib/redmine/commands/help.rb
|
37
38
|
- lib/redmine/commands/list.rb
|
38
39
|
- lib/redmine/commands/list_printer.rb
|
40
|
+
- lib/redmine/commands/logs.rb
|
39
41
|
- lib/redmine/commands/pull_plugins.rb
|
40
42
|
- lib/redmine/commands/shell.rb
|
43
|
+
- lib/redmine/commands/show.rb
|
41
44
|
- lib/redmine/commands/start.rb
|
45
|
+
- lib/redmine/commands/stop.rb
|
42
46
|
- lib/redmine/config.rb
|
43
47
|
- lib/redmine/utils/plugin_installer.rb
|
48
|
+
- lib/redmine/utils/system.rb
|
44
49
|
homepage: https://redmineup.com
|
45
50
|
licenses:
|
46
51
|
- MIT
|