redmine-installer 1.0.7 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.travis.yml +7 -0
  4. data/Gemfile +3 -15
  5. data/README.md +49 -177
  6. data/bin/redmine +4 -5
  7. data/lib/redmine-installer/backup.rb +13 -40
  8. data/lib/redmine-installer/cli.rb +92 -61
  9. data/lib/redmine-installer/command.rb +63 -117
  10. data/lib/redmine-installer/configuration.rb +148 -0
  11. data/lib/redmine-installer/database.rb +204 -0
  12. data/lib/redmine-installer/environment.rb +21 -0
  13. data/lib/redmine-installer/errors.rb +7 -0
  14. data/lib/redmine-installer/install.rb +37 -42
  15. data/lib/redmine-installer/logger.rb +83 -0
  16. data/lib/redmine-installer/package.rb +180 -0
  17. data/lib/redmine-installer/patches/ruby.rb +35 -0
  18. data/lib/redmine-installer/patches/tty.rb +16 -0
  19. data/lib/redmine-installer/profile.rb +24 -55
  20. data/lib/redmine-installer/redmine.rb +551 -0
  21. data/lib/redmine-installer/spec/spec.rb +81 -0
  22. data/lib/redmine-installer/task.rb +18 -77
  23. data/lib/redmine-installer/task_module.rb +12 -0
  24. data/lib/redmine-installer/upgrade.rb +51 -59
  25. data/lib/redmine-installer/utils.rb +46 -233
  26. data/lib/redmine-installer/version.rb +2 -4
  27. data/lib/redmine-installer.rb +69 -56
  28. data/redmine-installer.gemspec +20 -19
  29. data/spec/custom_matchers.rb +21 -0
  30. data/spec/installer_helper.rb +107 -0
  31. data/spec/installer_process.rb +82 -0
  32. data/spec/lib/backup_restore_spec.rb +81 -0
  33. data/spec/lib/install_spec.rb +125 -36
  34. data/spec/lib/upgrade_spec.rb +73 -52
  35. data/spec/packages/redmine-3.1.0.zip +0 -0
  36. data/spec/packages/redmine-3.2.0.zip +0 -0
  37. data/spec/packages/redmine-3.3.0-bad-migration.zip +0 -0
  38. data/spec/packages/redmine-3.3.0.zip +0 -0
  39. data/spec/packages/something-else.zip +0 -0
  40. data/spec/packages_helper.rb +19 -0
  41. data/spec/shared_contexts.rb +13 -0
  42. data/spec/spec_helper.rb +34 -18
  43. metadata +62 -63
  44. data/lib/redmine-installer/config_param.rb +0 -100
  45. data/lib/redmine-installer/error.rb +0 -5
  46. data/lib/redmine-installer/exec.rb +0 -158
  47. data/lib/redmine-installer/ext/module.rb +0 -7
  48. data/lib/redmine-installer/ext/string.rb +0 -15
  49. data/lib/redmine-installer/git.rb +0 -51
  50. data/lib/redmine-installer/helper.rb +0 -5
  51. data/lib/redmine-installer/helpers/generate_config.rb +0 -29
  52. data/lib/redmine-installer/locales/cs.yml +0 -147
  53. data/lib/redmine-installer/locales/en.yml +0 -154
  54. data/lib/redmine-installer/plugin.rb +0 -9
  55. data/lib/redmine-installer/plugins/base.rb +0 -24
  56. data/lib/redmine-installer/plugins/database.rb +0 -180
  57. data/lib/redmine-installer/plugins/email_sending.rb +0 -82
  58. data/lib/redmine-installer/plugins/redmine_plugin.rb +0 -82
  59. data/lib/redmine-installer/plugins/web_server.rb +0 -26
  60. data/lib/redmine-installer/step.rb +0 -16
  61. data/lib/redmine-installer/steps/backup.rb +0 -125
  62. data/lib/redmine-installer/steps/base.rb +0 -79
  63. data/lib/redmine-installer/steps/database_config.rb +0 -15
  64. data/lib/redmine-installer/steps/email_config.rb +0 -11
  65. data/lib/redmine-installer/steps/env_check.rb +0 -20
  66. data/lib/redmine-installer/steps/install.rb +0 -23
  67. data/lib/redmine-installer/steps/load_package.rb +0 -226
  68. data/lib/redmine-installer/steps/move_redmine.rb +0 -22
  69. data/lib/redmine-installer/steps/redmine_root.rb +0 -52
  70. data/lib/redmine-installer/steps/upgrade.rb +0 -57
  71. data/lib/redmine-installer/steps/validation.rb +0 -38
  72. data/lib/redmine-installer/steps/webserver_config.rb +0 -22
  73. data/spec/load_redmine.rb +0 -24
@@ -1,100 +0,0 @@
1
- ##
2
- # Class for easyier handle configuration parameters
3
- #
4
- # == Examples:
5
- #
6
- # params = Redmine::Installer::ConfigParams.new
7
- # params.add('database')
8
- # params.add('host').note('this is a host').default('localhost')
9
- #
10
- module Redmine::Installer
11
- class ConfigParams
12
- def initialize
13
- @params = []
14
- end
15
-
16
- def [](key)
17
- @params.detect{|p| p.name == key}
18
- end
19
-
20
- def for_asking
21
- @for_asking ||= @params.select{|p| p.ask}
22
- end
23
-
24
- def add(name)
25
- param = ConfigParam.new(name)
26
- @params << param
27
- param
28
- end
29
-
30
- def each(&block)
31
- @params.each(&block)
32
- end
33
-
34
- def map(&block)
35
- @params.map(&block)
36
- end
37
- end
38
-
39
- class ConfigParam
40
-
41
- @@attributes = []
42
-
43
- def self.attribute(name, default=nil)
44
- eval <<-EVAL
45
- def #{name}(value=nil)
46
- return @#{name} if value.nil?
47
- self.#{name} = value
48
- end
49
-
50
- def #{name}=(value)
51
- @#{name} = value
52
- end
53
- EVAL
54
-
55
- @@attributes << [name, default]
56
- end
57
-
58
- attribute :name
59
- attribute :note
60
- attribute :default
61
- attribute :value
62
- attribute :ask, true
63
- attribute :hide, false
64
-
65
- def initialize(name)
66
- # Default
67
- @@attributes.each{|(k,v)| set(k,v)}
68
-
69
- set(:name, name)
70
- end
71
-
72
- # Return string for print
73
- def title
74
- out = name.capitalize
75
- out << " (#{note})" if note
76
- out
77
- end
78
-
79
- def set(key, value)
80
- self.send("#{key}=", value)
81
- self
82
- end
83
-
84
- def default(value=nil)
85
- return @default if value.nil?
86
-
87
- self.default = value
88
- self.value = value if self.value.nil?
89
- self
90
- end
91
-
92
- def hide(value=nil)
93
- return @hide if value.nil?
94
-
95
- self.hide = value
96
- self
97
- end
98
-
99
- end
100
- end
@@ -1,5 +0,0 @@
1
- module Redmine::Installer
2
- # Package does not exist
3
- class Error < StandardError
4
- end
5
- end
@@ -1,158 +0,0 @@
1
- require 'open3'
2
-
3
- ##
4
- # Executions commands with timer and error handling
5
- #
6
- module Redmine::Installer
7
- class Exec
8
-
9
- include Redmine::Installer::Utils
10
-
11
- REFRESH_TIMER = 1 # in s
12
-
13
- attr_reader :stdout, :stderr
14
-
15
- def initialize(command, title=nil, timer=true)
16
- @command = command
17
-
18
- with_title(title)
19
- with_timer(timer)
20
- end
21
-
22
- def with_title(title)
23
- if title.is_a?(Symbol)
24
- title = I18n.translate(title)
25
- end
26
-
27
- @title = title
28
- self
29
- end
30
-
31
- def with_timer(yes_no)
32
- if $stdout.tty?
33
- @with_timer = yes_no
34
- else
35
- @with_timer = false
36
- end
37
- self
38
- end
39
-
40
- def run(repeatable=false)
41
- show_title
42
-
43
- Open3.popen3(@command) do |stdin, stdout, stderr, wait_thr|
44
- # log = StringIO.new
45
- # redirect_stream(stdout, log)
46
- # redirect_stream(stderr, log)
47
-
48
- # For example: rake db:create can ask for root login
49
- # if current setting does not work
50
- # stdin.closes
51
-
52
- exit_status = wait_thr.value
53
- @stdout = stdout.read
54
- @stderr = stderr.read
55
-
56
- stop_timer
57
- if exit_status.success?
58
- print_result(true)
59
- @return_value = true
60
- else
61
- print_result(false)
62
- @return_value = false
63
- # raise Redmine::Installer::Error, stderr.read
64
- end
65
- end
66
-
67
- unless success
68
- # print_error
69
- if repeatable && repeat?
70
- return run(repeatable)
71
- end
72
- end
73
-
74
- return success
75
- ensure
76
- # stop_timer
77
- end
78
-
79
- private
80
-
81
- def print_error
82
- message = '<red>'
83
- message << '--------------------------------------------------------------'
84
- message << "\n"
85
- message << stderr
86
- message << '--------------------------------------------------------------'
87
- message << '</red>'
88
- colorize(message)
89
-
90
- $stderr.puts(message)
91
- $stderr.flush
92
- end
93
-
94
- def repeat?
95
- confirm(:do_you_want_repeat_command, false)
96
- end
97
-
98
- def show_title
99
- if @with_timer
100
- @timer = start_timer
101
- else
102
- $stdout.print(@title)
103
- end
104
- end
105
-
106
- def start_timer
107
- Thread.new do
108
- counter = 0
109
-
110
- loop {
111
- hours, seconds = counter.divmod(3600)
112
- minutes, seconds = seconds.divmod(60)
113
-
114
- printf "[%02d:%02d:%02d] %s\r", hours, minutes, seconds, @title
115
- counter += REFRESH_TIMER
116
- sleep(REFRESH_TIMER)
117
- }
118
- end
119
- end
120
-
121
- def stop_timer
122
- if @timer
123
- @timer.kill
124
-
125
- # Clean line
126
- print ' ' * 100
127
- print "\r"
128
- end
129
- end
130
-
131
- def print_result(ok=true)
132
- if ok
133
- out = $stdout
134
- message = '... OK'
135
- else
136
- out = $stderr
137
- message = '... FAIL'
138
- end
139
-
140
- if @with_timer
141
- out.puts("#{@title} #{message}")
142
- else
143
- out.print(message)
144
- end
145
-
146
- out.flush
147
- end
148
-
149
- def redirect_stream(stream, out)
150
- Thread.new do
151
- while (line = stream.gets)
152
- out.puts(line)
153
- end
154
- end
155
- end
156
-
157
- end
158
- end
@@ -1,7 +0,0 @@
1
- class Module
2
- unless method_defined?(:camelize)
3
- def class_name
4
- name.split('::').last
5
- end
6
- end
7
- end
@@ -1,15 +0,0 @@
1
- class String
2
- unless method_defined?(:camelize)
3
- # Base on ActiveSupport method
4
- def camelize
5
- self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
6
- end
7
- end
8
-
9
- unless method_defined?(:underscore)
10
- def underscore
11
- self.gsub(/\A([A-Z])/){$1.downcase}
12
- .gsub(/([A-Z])/){'_'+$1.downcase}
13
- end
14
- end
15
- end
@@ -1,51 +0,0 @@
1
- module Redmine::Installer
2
- class Git
3
-
4
- # Simple git clone. Create a shallow clone with 1 revision.
5
- #
6
- # - download specific branch
7
- # - single branch
8
- # - store repository to target
9
- #
10
- def self.clone(remote, target, branch='master')
11
- success = Kernel.system("git clone --branch #{branch} --single-branch --depth 1 #{remote} #{target}")
12
-
13
- unless success
14
- error :git_repository_cannot_be_clonned
15
- end
16
- end
17
-
18
- # Git repository is locally clonned to target. On copied git is
19
- # executed `git fetch` (for preserve changes)
20
- #
21
- def self.copy_and_fetch(repository, target)
22
- url = ''
23
- # Store original remote url because copied repository will
24
- # have remote set to local repo
25
- Dir.chdir(repository) do
26
- url = `git config --get remote.origin.url`.strip
27
- end
28
-
29
- success = Kernel.system("git clone --depth 1 --no-local #{repository} #{target}")
30
-
31
- unless success
32
- error :git_repository_cannot_be_localy_clonned
33
- end
34
-
35
- # Change remote to origin and run fetch
36
- Dir.chdir(target) do
37
- Kernel.system("git remote set-url origin #{url}")
38
- success = Kernel.system('git fetch')
39
- end
40
-
41
- unless success
42
- error :git_repository_cannot_be_fetched
43
- end
44
- end
45
-
46
- def self.error(message)
47
- raise Redmine::Installer::Error, I18n.translate(message)
48
- end
49
-
50
- end
51
- end
@@ -1,5 +0,0 @@
1
- module Redmine::Installer
2
- module Helper
3
- autoload :GenerateConfig, 'redmine-installer/helpers/generate_config'
4
- end
5
- end
@@ -1,29 +0,0 @@
1
- module Redmine::Installer::Helper
2
- module GenerateConfig
3
-
4
- def create_for(type)
5
- choices = {}
6
- type.all.each do |m|
7
- choices[m] = m.title
8
- end
9
- choices[nil] = t(:skip)
10
-
11
- # answer = choose(:"what_#{type.class_name.downcase}_do_you_want", choices, default: nil)
12
- answer = choose(nil, choices, default: nil)
13
-
14
- # Skip
15
- return false if answer.nil?
16
-
17
- instance = answer.new
18
-
19
- say("(#{instance.class.title})", 2)
20
- instance.params.for_asking.each do |p|
21
- p.value = ask(p.title, default: p.default, hide: p.hide)
22
- end
23
-
24
- instance.make_config(base.tmp_redmine_root)
25
- return true
26
- end
27
-
28
- end
29
- end
@@ -1,147 +0,0 @@
1
- cs:
2
- redmine_installer_summary: 'Snadný způsob instalace/upgradu redmine.'
3
- backup: 'Záloha'
4
- backup_is_stored_at: 'Záloha je uložena <bright>%{dir}</bright>'
5
- cli_install_desc: 'Instalace'
6
- cli_show_verbose_output: 'Zobrazení debug výstupu'
7
- cli_upgrade_desc: 'Aktualizace redmine'
8
- cli_backup_desc: 'Záloha'
9
- cli_flag_source: 'Jaký typ je balíček'
10
- cli_flag_branch: 'Jiná větev gitu'
11
- cli_flag_environment: 'Prostředí redminu'
12
- command_exit_with_error: 'Příkaz skončil s chybou: <bright>%{command}</bright>'
13
- dir_not_exist_and_cannot_be_created: 'Složka %{dir} neexistuje a nemůže být vytvořena'
14
- dir_is_not_writeable: 'Složka <bright>%{dir}</bright> není zapisovatelná'
15
- do_you_want_repeat_command: 'Chcete opakovat příkaz?'
16
- do_you_want_full_backup: 'Chcete plnou zálohu?'
17
- do_you_want_backup_redmine: 'Chcete zálohovat redmine?'
18
- do_you_want_save_step_for_further_use: 'Chcete uložit kroky pro využití v budoucnu'
19
- error_redmine_not_contains_all: 'Redmine root neobsahuje tyto záznamy: <bright>%{records}</bright>'
20
- error_plugins_should_be_on_plugins: 'Plugin by měl být v plugins složce'
21
- error_argument_package_is_missing: 'Chybý argument: redmine package'
22
- error_unsupported_source: 'Nepodporovaný zdroj: %{source}'
23
- exit: 'exit'
24
- file_not_exist: 'Soubor <bright>%{file}</bright> neexistuje'
25
- file_must_have_format: 'Soubor <bright>%{file}</bright> musí mít formát: %{formats}'
26
- full_backup: 'Plná záloha'
27
- git_repository_cannot_be_clonned: 'Repozitář nemůže být klonován'
28
- git_repository_cannot_be_localy_clonned: 'Repozitář nemůže být lokálně klonován'
29
- git_repository_cannot_be_fetched: 'Repozitář nemůže stáhnout poslední verzi'
30
- no_t: 'ne'
31
- only_database: 'Pouze databáze'
32
- path_for_redmine_root: 'Cesta pro redmine_root'
33
- powered_by: 'Powered by EasyRedmine'
34
- restoring_database: '... Obnova database'
35
- skip: 'Přeskočit'
36
- try_again: 'zkusit znova'
37
- what_dir_for_backups: 'Jaká složka pro zálohu?'
38
- what_database_do_you_want: 'Jakou databázi chcete?'
39
- what_web_server_do_you_want: 'Jaký web-server chcete?'
40
- yes_t: 'ano'
41
- your_profile_can_be_used_as: 'Váš profil je uložen jako #%{id} a může být použit s <bright>--profile %{id}</bright>'
42
-
43
- step:
44
- load_package:
45
- title: 'Zpracování balíku'
46
- database_config:
47
- title: 'Konfigurace databáze'
48
- email_config:
49
- title: 'Konfigurace emailového nastavení'
50
- install:
51
- title: 'Installace'
52
- move_redmine:
53
- title: 'Přesun redmine'
54
- webserver_config:
55
- title: 'Webserver konfigurace'
56
- validation:
57
- title: 'Validace'
58
- backup:
59
- title: 'Záloha'
60
- upgrade:
61
- title: 'Aktualizace'
62
- save_profile:
63
- title: 'Uložení profilu'
64
- redmine_root:
65
- title: 'Redmine root'
66
-
67
- plugin:
68
- database:
69
- mysql:
70
- title: 'MySQL'
71
- postgresql:
72
- title: 'PostgreSQL'
73
- emailsending:
74
- gmail:
75
- title: 'Gmail'
76
- sendmail:
77
- title: 'Sendmail'
78
- smtpfromscratch:
79
- title: 'SMTP od základu'
80
- webserver:
81
- webrick:
82
- title: 'Webrick'
83
- configuration: |
84
- Webrick je výchozí webserver.
85
- Server je připravený pro start.
86
- thin:
87
- title: 'Thin'
88
- configuration: |
89
- Přidejte:
90
- <bright>gem 'thin'</bright>
91
-
92
- do <bright>Gemfile.local</bright>
93
-
94
- a spusťtě: <bright>bundle install</bright>
95
-
96
- (Více informací na http://code.macournoyer.com/thin)
97
- apachepassenger:
98
- title: 'Passenger (apache)'
99
- configuration: |
100
- Přidejte toto do konfiguračního souboru.
101
-
102
- <bright><VirtualHost *:80>
103
- ServerName www.yourhost.com
104
- DocumentRoot %{redmine_root}/public
105
- <Directory %{redmine_root}/public>
106
- # This relaxes Apache security settings.
107
- AllowOverride all
108
- # MultiViews must be turned off.
109
- Options -MultiViews
110
- # Uncomment this if you're on Apache >= 2.4:
111
- #Require all granted
112
- </Directory>
113
- </VirtualHost></bright>
114
-
115
- Více informací na https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html
116
- nginxpassenger:
117
- title: 'Passenger (nginx)'
118
- configuration: |
119
- Přidejte toto do konfiguračního souboru.
120
-
121
- <bright>server {
122
- listen 80;
123
- server_name www.yourhost.com;
124
- root %{redmine_root}/public; # <--- be sure to point to 'public'!
125
- passenger_enabled on;
126
- }</bright>
127
-
128
- Více informací na https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html
129
- puma:
130
- title: 'Puma'
131
- configuration: |
132
- Přidejte:
133
- <bright>gem 'puma'</bright>
134
-
135
- do <bright>Gemfile.local</bright>
136
-
137
- Více informací na http://puma.io
138
- redmine_plugin:
139
- easyproject:
140
- install: 'Easyproject instalace'
141
-
142
- command:
143
- bundle_install: 'Bundle install'
144
- rake_db_create: 'DB creating'
145
- rake_db_migrate: 'DB migrating'
146
- rake_redmine_plugin_migrate: 'Plugin migrating'
147
- rake_generate_secret_token: 'Generate secret token'