redmine-installer 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/Gemfile +19 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +273 -0
  6. data/Rakefile +7 -0
  7. data/bin/redmine +8 -0
  8. data/lib/redmine-installer.rb +72 -0
  9. data/lib/redmine-installer/backup.rb +48 -0
  10. data/lib/redmine-installer/cli.rb +90 -0
  11. data/lib/redmine-installer/command.rb +142 -0
  12. data/lib/redmine-installer/config_param.rb +90 -0
  13. data/lib/redmine-installer/error.rb +5 -0
  14. data/lib/redmine-installer/exec.rb +158 -0
  15. data/lib/redmine-installer/ext/module.rb +7 -0
  16. data/lib/redmine-installer/ext/string.rb +15 -0
  17. data/lib/redmine-installer/git.rb +51 -0
  18. data/lib/redmine-installer/helper.rb +5 -0
  19. data/lib/redmine-installer/helpers/generate_config.rb +29 -0
  20. data/lib/redmine-installer/install.rb +56 -0
  21. data/lib/redmine-installer/locales/cs.yml +145 -0
  22. data/lib/redmine-installer/locales/en.yml +146 -0
  23. data/lib/redmine-installer/plugin.rb +9 -0
  24. data/lib/redmine-installer/plugins/base.rb +28 -0
  25. data/lib/redmine-installer/plugins/database.rb +168 -0
  26. data/lib/redmine-installer/plugins/email_sending.rb +82 -0
  27. data/lib/redmine-installer/plugins/redmine_plugin.rb +30 -0
  28. data/lib/redmine-installer/plugins/web_server.rb +26 -0
  29. data/lib/redmine-installer/profile.rb +74 -0
  30. data/lib/redmine-installer/step.rb +15 -0
  31. data/lib/redmine-installer/steps/backup.rb +120 -0
  32. data/lib/redmine-installer/steps/base.rb +60 -0
  33. data/lib/redmine-installer/steps/database_config.rb +15 -0
  34. data/lib/redmine-installer/steps/email_config.rb +11 -0
  35. data/lib/redmine-installer/steps/install.rb +21 -0
  36. data/lib/redmine-installer/steps/load_package.rb +180 -0
  37. data/lib/redmine-installer/steps/move_redmine.rb +22 -0
  38. data/lib/redmine-installer/steps/redmine_root.rb +29 -0
  39. data/lib/redmine-installer/steps/upgrade.rb +55 -0
  40. data/lib/redmine-installer/steps/validation.rb +38 -0
  41. data/lib/redmine-installer/steps/webserver_config.rb +22 -0
  42. data/lib/redmine-installer/task.rb +85 -0
  43. data/lib/redmine-installer/upgrade.rb +68 -0
  44. data/lib/redmine-installer/utils.rb +233 -0
  45. data/lib/redmine-installer/version.rb +5 -0
  46. data/redmine-installer.gemspec +25 -0
  47. data/spec/lib/install_spec.rb +46 -0
  48. data/spec/lib/upgrade_spec.rb +62 -0
  49. data/spec/load_redmine.rb +24 -0
  50. data/spec/spec_helper.rb +30 -0
  51. metadata +130 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 764341505a7ad7b1fba7d8a0d1c7c22e2ac1b0ab
4
+ data.tar.gz: 28432d0c2505c781f50277fd0bb5b1b82fef66a4
5
+ SHA512:
6
+ metadata.gz: 4d3567200830eb0b380b94e3412bedbe60507f337ebe6204f0a33f6b9d5c37fcba8aaa40292115c029648b436bc8809040a08cd6eb4bda8ad212ae117e004e2c
7
+ data.tar.gz: 89c151e10c70dd8b1ceb982cd28a36ed446b174b136b6a583091016be48c8afa8655e953261175c596a59025fa781991a679d296fd02076e4c5a55e6dfd564b4
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ /.gemtags
2
+ /.tags
3
+ *.gem
4
+ *.rbc
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+ *.bundle
21
+ *.so
22
+ *.o
23
+ *.a
24
+ mkmf.log
25
+ test/*
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in redmine-installer.gemspec
4
+ gemspec
5
+
6
+ gem 'gli'
7
+ gem 'i18n'
8
+ gem 'ansi'
9
+ gem 'notifier'
10
+ gem 'ruby-progressbar'
11
+
12
+ group :development do
13
+ gem 'pry'
14
+ gem 'rspec'
15
+ gem 'rspec-mocks'
16
+ gem 'guard'
17
+ gem 'guard-rspec'
18
+ gem 'rest_client'
19
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ondřej Moravčík
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,273 @@
1
+ # Redmine::Installer
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```
8
+ gem 'redmine-installer'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ ```
14
+ $ bundle
15
+ ```
16
+
17
+ Or install it yourself as:
18
+
19
+ ```
20
+ $ gem install redmine-installer
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ redmine GLOBAL_ARGUMENTS ACTION ARGUMENTS
27
+ ```
28
+
29
+ #### Global arguments
30
+
31
+ <table>
32
+ <thead>
33
+ <tr>
34
+ <th>arguments</th>
35
+ <th>default value</th>
36
+ <th>description</th>
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
+ <tr>
41
+ <td>--verbose / -v</td>
42
+ <td>false</td>
43
+ <td>show verbosed output</td>
44
+ </tr>
45
+ <tr>
46
+ <td>--locale / -l</td>
47
+ <td>en</td>
48
+ <td>languages for application</td>
49
+ </tr>
50
+ </tbody>
51
+ </table>
52
+
53
+
54
+ #### Shortcut
55
+
56
+ Some commands have defined shortcut for quicker access. Fox example:
57
+
58
+ ```
59
+ redmine install package
60
+
61
+ # is equal as
62
+
63
+ redmine i package
64
+ ```
65
+
66
+ Commands shortcut.
67
+
68
+ ```
69
+ i -> install
70
+ u -> upgrade
71
+ b -> backup
72
+ ```
73
+
74
+ #### Common arguments
75
+
76
+ <table>
77
+ <thead>
78
+ <tr>
79
+ <th>arguments</th>
80
+ <th>default</th>
81
+ <th>description</th>
82
+ </tr>
83
+ </thead>
84
+ <tbody>
85
+ <tr>
86
+ <td>--environment / --env / -e</td>
87
+ <td>production</td>
88
+ <td>
89
+ environment for redmine
90
+ </td>
91
+ </tr>
92
+ </tbody>
93
+ </table>
94
+
95
+ ### Instalation
96
+
97
+ You can instal redmine package from archive or git.
98
+
99
+ #### Steps:
100
+
101
+ - *1. Redmine root* - where should be new redmine located
102
+ - *2. Load package* - extract package
103
+ - *3. Database configuration* - you can choose type of DB which you want to use
104
+ - *4. Email sending configuration* - email sending configuration
105
+ - *5. Install* - install commands are executed
106
+ - *6. Moving redmine* - redmine is moved from temporarily folder to given redmine_root
107
+ - *7. Webserve configuration* - generating webserver configuration
108
+
109
+ #### From archive
110
+
111
+ Supported archives are **.zip** and **.tar.gz**.
112
+
113
+ ```
114
+ # minimal
115
+ redmine install PATH_TO_PACKAGE
116
+
117
+ # full
118
+ redmine install PATH_TO_PACKAGE --env ENV1,ENV2,ENV3
119
+ ```
120
+
121
+ #### From git
122
+
123
+ ```
124
+ # minimal
125
+ redmine install GIT_REPO --source git
126
+
127
+ # full
128
+ redmine install GIT_REPO --source git --branch GIT_BRANCH --env ENV1,ENV2,ENV3
129
+ ```
130
+
131
+ ##### Arguments
132
+
133
+ <table>
134
+ <thead>
135
+ <tr>
136
+ <th>argumnest</th>
137
+ <th>default</th>
138
+ <th>description</th>
139
+ </tr>
140
+ </thead>
141
+ <tbody>
142
+ <tr>
143
+ <td>--branch / -b</td>
144
+ <td>master</td>
145
+ <td>
146
+ branch of git defined by GIT_REPO
147
+ </td>
148
+ </tr>
149
+ </tbody>
150
+ </table>
151
+
152
+
153
+ ### Upgrade
154
+
155
+ You can upgrade current redmine by archive or currently defined git repository. If your redmine contain plugins which are not part of new package - all these plugins will be kept otherwise are replaced with those from package.
156
+
157
+ Final step will ask you if you want save steps configuration. If you say YES, configuration will be stored as profile so next time you can upgrade redmine faster.
158
+
159
+ ```
160
+ redmine upgrade PACKAGE --profile PROFILE_ID
161
+ ```
162
+
163
+ Profiles are stored on *HOME_FOLDER/.redmine-installer-profiles.yml*.
164
+
165
+ #### Steps:
166
+
167
+ - *1. Redmine root* - where should be new redmine located
168
+ - *2. Load package* - extract package
169
+ - *3. Validation* - current redmine should be valid
170
+ - *4. Backup* - backup current redmine (see backup section)
171
+ - *5. Upgrading* - install commands are executed
172
+ - *6. Moving redmine* - redmine is moved from temporarily folder to given redmine_root
173
+ - *7. Profile saving* - generating profile (see profile section)
174
+
175
+
176
+ #### From archive
177
+
178
+ ```
179
+ # minimal
180
+ redmine upgrade PATH_TO_PACKAGE
181
+
182
+ # full
183
+ redmine upgrade PATH_TO_PACKAGE --env ENV1,ENV2,ENV3
184
+ ```
185
+
186
+ #### From git
187
+
188
+ ```
189
+ # minimal
190
+ redmine upgrade --source git
191
+
192
+ # full
193
+ redmine upgrade --source git --env ENV1,ENV2,ENV3
194
+ ```
195
+
196
+
197
+ ### Backup
198
+
199
+ ```
200
+ redmine backup
201
+ ```
202
+
203
+ #### Steps:
204
+
205
+ - *1. Redmine root* - where should be new redmine located
206
+ - *2. Validation* - current redmine should be valid
207
+ - *3. Backup* - backup current redmine (see backup section)
208
+ - *4. Profile saving* - generating profile (see profile section)
209
+
210
+ You can choose one of 3 types.
211
+
212
+ <table>
213
+ <thead>
214
+ <tr>
215
+ <th>Type</th>
216
+ <th>Description</th>
217
+ </tr>
218
+ </thead>
219
+ <tbody>
220
+ <tr>
221
+ <td><b>Full backup</b></td>
222
+ <td>archive full redmine_root folder with all you databases defined at config/database.yml</td>
223
+ </tr>
224
+ <tr>
225
+ <td><b>Backup</b></td>
226
+ <td>
227
+ archive
228
+ <ul>
229
+ <li>files folder</li>
230
+ <li>config/database.yml, config/configuration.yml</li>
231
+ <li>databases</li>
232
+ </ul>
233
+ </td>
234
+ </tr>
235
+ <tr>
236
+ <td><b>Only database</b></td>
237
+ <td>archive only databases</td>
238
+ </tr>
239
+ </tbody>
240
+ </table>
241
+
242
+ ## Examples
243
+
244
+ Simple install and ugrade
245
+
246
+ ```
247
+ $ wget http://www.redmine.org/releases/redmine-2.3.0.zip
248
+ $ wget http://www.redmine.org/releases/redmine-2.5.0.zip
249
+
250
+ $ redmine install redmine-2.3.0.zip
251
+ $ redmine upgrade redmine-2.5.0.zip
252
+ ```
253
+
254
+ Set languages
255
+
256
+ ```
257
+ $ redmine --locale cs install redmine-2.3.0.zip
258
+ ```
259
+
260
+ Install from git
261
+
262
+ ```
263
+ $ redmine install git@github.com:redmine/redmine.git --source git
264
+ $ redmine upgrade --source git
265
+ ```
266
+
267
+ Install from git with specific branch
268
+
269
+ ```
270
+ $ redmine install git@github.com:redmine/redmine.git --source git --branch 2.3-stable
271
+ $ redmine upgrade --source git
272
+ ```
273
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task default: :spec
7
+ task test: :spec
data/bin/redmine ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ require 'redmine-installer'
7
+
8
+ Redmine::Installer::CLI.start(ARGV)
@@ -0,0 +1,72 @@
1
+ module Redmine
2
+ module Installer
3
+ autoload :CLI, 'redmine-installer/cli'
4
+ autoload :Task, 'redmine-installer/task'
5
+ autoload :Utils, 'redmine-installer/utils'
6
+ autoload :Step, 'redmine-installer/step'
7
+ autoload :ConfigParams, 'redmine-installer/config_param'
8
+ autoload :Plugin, 'redmine-installer/plugin'
9
+ autoload :Helper, 'redmine-installer/helper'
10
+ autoload :Command, 'redmine-installer/command'
11
+ autoload :Exec, 'redmine-installer/exec'
12
+ autoload :Profile, 'redmine-installer/profile'
13
+ autoload :Git, 'redmine-installer/git'
14
+
15
+ # Root of the gem
16
+ def self.root_path
17
+ @root_path ||= File.expand_path('..', File.dirname(__FILE__))
18
+ end
19
+
20
+ # Path to locales dir
21
+ def self.locales_path
22
+ @locales_path ||= File.join(root_path, 'lib', 'redmine-installer', 'locales')
23
+ end
24
+
25
+ # Locales for I18n
26
+ def self.locales
27
+ @locales ||= Dir.glob(File.join(locales_path, '*.yml'))
28
+ end
29
+
30
+ # Default configurations fo I18n gem
31
+ def self.set_i18n
32
+ I18n.enforce_available_locales = false
33
+ I18n.load_path = Redmine::Installer.locales
34
+ I18n.locale = :en
35
+ I18n.default_locale = :en
36
+ end
37
+
38
+ def self.print_logo
39
+ $stdout.puts <<-PRINT
40
+ _ _
41
+ _ __ ___ __| | _ __ ___ (_) _ __ ___
42
+ | '__|/ _ \\ / _` || '_ ` _ \\ | || '_ \\ / _ \\ _____
43
+ | | | __/| (_| || | | | | || || | | || __/|_____|
44
+ |_| \\___| \\__,_||_| |_| |_||_||_| |_| \\___|
45
+ _ _ _ _
46
+ (_) _ __ ___ | |_ __ _ | || | ___ _ __
47
+ | || '_ \\ / __|| __|/ _` || || | / _ \\| '__|
48
+ | || | | |\\__ \\| |_| (_| || || || __/| |
49
+ |_||_| |_||___/ \\__|\\__,_||_||_| \\___||_|
50
+
51
+ #{I18n.translate(:powered_by)}
52
+
53
+ PRINT
54
+ end
55
+
56
+ end
57
+ end
58
+
59
+ # Requirements
60
+ require 'pry'
61
+ require 'i18n'
62
+ require 'redmine-installer/version'
63
+ require 'redmine-installer/error'
64
+ require 'redmine-installer/ext/string'
65
+ require 'redmine-installer/ext/module'
66
+ require 'redmine-installer/install'
67
+ require 'redmine-installer/upgrade'
68
+ require 'redmine-installer/backup'
69
+
70
+ # Default configurations
71
+ Redmine::Installer.set_i18n
72
+ Redmine::Installer.print_logo
@@ -0,0 +1,48 @@
1
+ ##
2
+ # Backup redmine
3
+ #
4
+ # Usage: `redmine backup`
5
+ #
6
+ # == Steps:
7
+ # 1. Redmine root - where should be new redmine located
8
+ # 2. Validation - current redmine should be valid
9
+ # 3. Backup - backup current redmine (see backup section)
10
+ # 4. Profile saving - generating profile (see profile section)
11
+ #
12
+ # == Types:
13
+ #
14
+ # Full backup::
15
+ # archive full redmine_root folder with all you databases defined at config/database.yml
16
+ #
17
+ # Backup archive::
18
+ # - files folder
19
+ # - config/database.yml, config/configuration.yml
20
+ # - databases
21
+ #
22
+ # Only database::
23
+ # archive only databases
24
+ #
25
+ module Redmine::Installer
26
+ class Backup < Task
27
+
28
+ STEPS = [
29
+ step::RedmineRoot,
30
+ step::Validation,
31
+ step::Backup
32
+ ]
33
+
34
+ attr_accessor :redmine_root
35
+
36
+ def initialize(redmine_root, options={})
37
+ self.redmine_root = redmine_root
38
+ super(options)
39
+ end
40
+
41
+ def run
42
+ Redmine::Installer::Profile.load(self, options[:profile])
43
+ super
44
+ Redmine::Installer::Profile.save(self) if options[:profile].nil?
45
+ end
46
+
47
+ end
48
+ end