redmine-installer 2.0.0.rc3 → 2.0.1.rc1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4addf7ace678fae31a3b00bc0a96a26d313e3d1
4
- data.tar.gz: a54231fd4c6b6d42ab9442dbc4dfa719c884269c
3
+ metadata.gz: ed131f6901b7e57bf6f2e01673c82fe2f97ad8e5
4
+ data.tar.gz: e1aa7e6f59b41c27661e0a11601960139d352c6e
5
5
  SHA512:
6
- metadata.gz: 5ed2dd41d4fd2b14c1baf73cb46d136f27d05c08acbf699956983b9e35e7f04aceaa75ebe88edebad07398509c3693ae7dc30420e4ca9ea07505533eed95c0da
7
- data.tar.gz: 5f882361eff038c3e6f5f2cc9b9f0e1b286d6d55c1482f6eb112397a94f6fc0d63b2ef1c2ed58eb7f57c7a538c034c15d787a15a6113642b4e1c9dfb7cb0bcc2
6
+ metadata.gz: 196ba4d02f4600dc06a595ee10371b81f01154c383d25c0d226b816a067987c94df339a60aff60e4959243d2bc573781fb88690f07b017dccaefe73020bc8a50
7
+ data.tar.gz: 5a4366998263ee3baa0505cc4e02173ef3e7f1c5a6a2badf443594ae68e1b00ac945c58d2d65d12616d67091ff4f9cf4db673a65cad1549c226493d443a5297b
data/README.md CHANGED
@@ -59,7 +59,7 @@ Examples:
59
59
  Install Redmine. Installer will ask for every required parameters.
60
60
  - `redmine install`
61
61
 
62
- Install Redmine from internet
62
+ Install Redmine from internet
63
63
  - `redmine install https://server.tld/REDMINE_PACKAGE.zip /srv/redmine`
64
64
 
65
65
  Install Redmine from redmine.zip package into /srv/redmine folder.
@@ -95,7 +95,7 @@ Examples:
95
95
  Upgrade Redmine located on /srv/redmine with package redmine2.zip
96
96
  - `redmine upgrade redmine2.zip /srv/redmine`
97
97
 
98
- Upgrade Redmine from internet
98
+ Upgrade Redmine from internet
99
99
  - `redmine upgrade https://server.tld/REDMINE_PACKAGE.zip /srv/redmine`
100
100
 
101
101
  Upgrade Redmine and keep directory.
@@ -115,6 +115,19 @@ redmine backup [REDMINE_ROOT]
115
115
 
116
116
  Examples:
117
117
 
118
- Backup project located on /srv/redmine
118
+ Backup project located in /srv/redmine
119
119
  - `redmine upgrade /srv/redmine`
120
120
 
121
+ ### Restoring database
122
+
123
+ Restore database dump to redmine.
124
+
125
+ ```
126
+ redmine help restore-db
127
+ redmine restore-db DATABASE_DUMP [REDMINE_ROOT] [options]
128
+ ```
129
+
130
+ Examples:
131
+
132
+ Restore database db.dump for redmine in /srv/redmine
133
+ - `redmine restore-db db.dump /srv/redmine`
@@ -27,6 +27,7 @@ module RedmineInstaller
27
27
  autoload :Command, 'redmine-installer/command'
28
28
  autoload :Profile, 'redmine-installer/profile'
29
29
  autoload :Backup, 'redmine-installer/backup'
30
+ autoload :RestoreDB, 'redmine-installer/restore_db'
30
31
 
31
32
  # Settings
32
33
  MIN_SUPPORTED_RUBY = '2.1.0'
@@ -66,12 +66,13 @@ module RedmineInstaller
66
66
  'redmine upgrade --keep git_repositories'
67
67
 
68
68
  c.option '--enable-user-root', 'Skip root as root validation'
69
- c.option '--bundle-options', String, 'Add options to bundle command'
69
+ c.option '--bundle-options OPTIONS', String, 'Add options to bundle command'
70
70
  c.option '-p', '--profile PROFILE_ID', Integer, 'Use saved profile'
71
71
  c.option '--keep PATH(s)', Array, 'Keep paths, use multiple options or separate values by comma (paths must be relative)', &method(:parse_keep_options)
72
+ c.option '--copy-files-with-symlink', 'Files will be referenced by symlinks instead of copying files. Only for advance users.'
72
73
 
73
74
  c.action do |args, options|
74
- options.default(enable_user_root: false)
75
+ options.default(enable_user_root: false, copy_files_with_symlink: false)
75
76
 
76
77
  RedmineInstaller::Upgrade.new(args[0], args[1], options.__hash__).run
77
78
  end
@@ -94,7 +95,7 @@ module RedmineInstaller
94
95
 
95
96
 
96
97
  # --- Backup ------------------------------------------------------------
97
- command :'backup' do |c|
98
+ command :backup do |c|
98
99
  c.syntax = 'backup [REDMINE_ROOT]'
99
100
  c.description = 'Backup redmine'
100
101
 
@@ -108,6 +109,24 @@ module RedmineInstaller
108
109
  alias_command :b, :backup
109
110
 
110
111
 
112
+ # --- Restore db --------------------------------------------------------
113
+ command :'restore-db' do |c|
114
+ c.syntax = 'restore-db DATABASE_DUMP [REDMINE_ROOT] [options]'
115
+ c.description = 'Restore database and delete old data'
116
+
117
+ c.example 'Restore DB',
118
+ 'redmine restore-db /srv/redmine.sql'
119
+
120
+ c.option '--enable-user-root', 'Skip root as root validation'
121
+
122
+ c.action do |args, options|
123
+ options.default(enable_user_root: false)
124
+
125
+ RedmineInstaller::RestoreDB.new(args[0], args[1]).run
126
+ end
127
+ end
128
+
129
+
111
130
  run!
112
131
  end
113
132
 
@@ -24,6 +24,8 @@ module RedmineInstaller
24
24
 
25
25
  CHECK_N_INACCESSIBLE_FILES = 10
26
26
 
27
+ FILES_DIR = 'files'
28
+
27
29
  def initialize(task, root=nil)
28
30
  super(task)
29
31
  @root = root.to_s
@@ -42,7 +44,7 @@ module RedmineInstaller
42
44
  end
43
45
 
44
46
  def files_path
45
- File.join(root, 'files')
47
+ File.join(root, FILES_DIR)
46
48
  end
47
49
 
48
50
  def plugins_path
@@ -57,6 +59,10 @@ module RedmineInstaller
57
59
  File.join(root, 'log')
58
60
  end
59
61
 
62
+ def bundle_path
63
+ File.join(root, '.bundle')
64
+ end
65
+
60
66
  def pids_files
61
67
  Dir.glob(File.join(root, 'tmp', 'pids', '*'))
62
68
  end
@@ -210,6 +216,26 @@ module RedmineInstaller
210
216
  end
211
217
  end
212
218
 
219
+ def restore_db
220
+ print_title('Database restoring')
221
+
222
+ @database = Database.init(self)
223
+
224
+ Dir.chdir(root) do
225
+ # Load database dump (if was set via CLI)
226
+ load_database_dump
227
+
228
+ # Migrating
229
+ rake_db_migrate
230
+
231
+ # Plugin migrating
232
+ rake_redmine_plugin_migrate
233
+
234
+ # Install easyproject
235
+ rake_easyproject_install if easyproject?
236
+ end
237
+ end
238
+
213
239
  # # => ['.', '..']
214
240
  # def empty_root?
215
241
  # Dir.entries(root).size <= 2
@@ -219,6 +245,8 @@ module RedmineInstaller
219
245
  Dir.chdir(root) do
220
246
  Dir.entries('.').each do |entry|
221
247
  next if entry == '.' || entry == '..'
248
+ next if entry == FILES_DIR && task.options.copy_files_with_symlink
249
+
222
250
  FileUtils.remove_entry_secure(entry)
223
251
  end
224
252
  end
@@ -230,7 +258,12 @@ module RedmineInstaller
230
258
  Dir.chdir(other_redmine.root) do
231
259
  Dir.entries('.').each do |entry|
232
260
  next if entry == '.' || entry == '..'
233
- FileUtils.mv(entry, root)
261
+
262
+ if entry == FILES_DIR && task.options.copy_files_with_symlink
263
+ FileUtils.rm(entry)
264
+ else
265
+ FileUtils.mv(entry, root)
266
+ end
234
267
  end
235
268
  end
236
269
 
@@ -250,13 +283,24 @@ module RedmineInstaller
250
283
  end
251
284
 
252
285
  # Copy files
253
- FileUtils.cp_r(other_redmine.files_path, root)
286
+ if task.options.copy_files_with_symlink
287
+ FileUtils.rm_rf(files_path)
288
+ FileUtils.ln_s(other_redmine.files_path, root)
289
+ else
290
+ FileUtils.cp_r(other_redmine.files_path, root)
291
+ end
254
292
 
255
293
  # Copy old logs
256
294
  FileUtils.mkdir_p(log_path)
257
295
  Dir.glob(File.join(other_redmine.log_path, 'redmine_installer_*')).each do |log|
258
296
  FileUtils.cp(log, log_path)
259
297
  end
298
+
299
+ # Copy bundle config
300
+ if Dir.exist?(other_redmine.bundle_path)
301
+ FileUtils.mkdir_p(bundle_path)
302
+ FileUtils.cp_r(other_redmine.bundle_path, root)
303
+ end
260
304
  end
261
305
 
262
306
  # Copy 'keep' files (base on options)
@@ -403,7 +447,7 @@ module RedmineInstaller
403
447
  end
404
448
 
405
449
  def valid_options
406
- if @database_dump_to_load && !File.exist?(@database_dump_to_load)
450
+ if @database_dump_to_load && !(File.exist?(@database_dump_to_load) && File.file?(@database_dump_to_load))
407
451
  error "Database dump #{@database_dump_to_load} does not exist (path is expanded)."
408
452
  end
409
453
  end
@@ -0,0 +1,26 @@
1
+ module RedmineInstaller
2
+ class RestoreDB < Task
3
+
4
+ def initialize(database_dump, redmine_root)
5
+ super(database_dump: database_dump.to_s)
6
+
7
+ @environment = Environment.new(self)
8
+ @redmine = Redmine.new(self, redmine_root)
9
+ end
10
+
11
+ def up
12
+ @environment.check
13
+
14
+ @redmine.valid_options
15
+ @redmine.ensure_and_valid_root
16
+ @redmine.validate
17
+ @redmine.check_running_state
18
+ @redmine.restore_db
19
+
20
+ puts
21
+ puts pastel.bold('Database was restored')
22
+ logger.info('Database was restored')
23
+ end
24
+
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module RedmineInstaller
2
- VERSION = '2.0.0.rc3'
2
+ VERSION = '2.0.1.rc1'
3
3
  end
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_runtime_dependency 'tty-progressbar', '~> 0.10.1'
31
31
  spec.add_runtime_dependency 'rubyzip'
32
32
  spec.add_runtime_dependency 'pastel'
33
+ spec.add_runtime_dependency 'bundler', '~> 1.11'
33
34
 
34
- spec.add_development_dependency 'bundler', '~> 1.11'
35
35
  spec.add_development_dependency 'rake'
36
36
  end
@@ -11,7 +11,13 @@ class InstallerProcess
11
11
  tempfile_out.sync = true
12
12
  tempfile_err.sync = true
13
13
 
14
- @process = ChildProcess.build('bin/redmine', command, *args.flatten.compact)
14
+ args = args.flatten.compact
15
+
16
+ if ['install', 'upgrade'].include?(command)
17
+ args << '--bundle-options' << '--without rmagick'
18
+ end
19
+
20
+ @process = ChildProcess.build('bin/redmine', command, *args)
15
21
  @process.io.stdout = tempfile_out
16
22
  @process.io.stderr = tempfile_err
17
23
  @process.environment['REDMINE_INSTALLER_SPEC'] = '1'
@@ -73,7 +73,7 @@ RSpec.describe RedmineInstaller::Install, command: 'install' do
73
73
  expected_output('Redmine installing')
74
74
  expected_output_in('--> Bundle install', 50)
75
75
 
76
- expected_output('Gemfile not found')
76
+ expected_output("Gemfile.lock wasn't created")
77
77
  expected_output('‣ Try again')
78
78
 
79
79
  go_down
@@ -80,4 +80,33 @@ RSpec.describe RedmineInstaller::Upgrade, :install_first, command: 'upgrade' do
80
80
  expect(File.exist?(test_test_file)).to be_truthy
81
81
  end
82
82
 
83
+ it 'copy files with symlink ', args: ['--copy-files-with-symlink'] do
84
+ files_dir = File.join(@redmine_root, 'files')
85
+ files = (0..10).map {|i| File.join(files_dir, "file_#{i}.txt") }
86
+ FileUtils.touch(files)
87
+
88
+ wait_for_stdin_buffer
89
+ write(@redmine_root)
90
+
91
+ wait_for_stdin_buffer
92
+ write(package_v320)
93
+
94
+ wait_for_stdin_buffer
95
+
96
+ go_down
97
+ go_down
98
+ expected_output('‣ Nothing')
99
+ select_choice
100
+
101
+ expected_output('Are you sure you dont want backup?')
102
+ write('y')
103
+
104
+ expected_successful_upgrade
105
+
106
+ expected_redmine_version('3.2.0')
107
+
108
+ # Not bullet-prof but at least check if files are still there
109
+ expect(Dir.glob(File.join(files_dir, '*.txt')).sort).to eq(files.sort)
110
+ end
111
+
83
112
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redmine-installer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc3
4
+ version: 2.0.1.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Moravčík
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-22 00:00:00.000000000 Z
11
+ date: 2017-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -101,7 +101,7 @@ dependencies:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.11'
104
- type: :development
104
+ type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
@@ -152,6 +152,7 @@ files:
152
152
  - lib/redmine-installer/patches/tty.rb
153
153
  - lib/redmine-installer/profile.rb
154
154
  - lib/redmine-installer/redmine.rb
155
+ - lib/redmine-installer/restore_db.rb
155
156
  - lib/redmine-installer/spec/spec.rb
156
157
  - lib/redmine-installer/task.rb
157
158
  - lib/redmine-installer/task_module.rb