docker-sync 0.4.6 → 0.5.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/console +6 -0
  4. data/lib/docker-sync.rb +2 -1
  5. data/lib/docker-sync/config/project_config.rb +13 -12
  6. data/lib/docker-sync/dependencies.rb +39 -0
  7. data/lib/docker-sync/dependencies/docker.rb +23 -0
  8. data/lib/docker-sync/dependencies/docker_driver.rb +20 -0
  9. data/lib/docker-sync/dependencies/fswatch.rb +14 -0
  10. data/lib/docker-sync/dependencies/package_manager.rb +24 -0
  11. data/lib/docker-sync/dependencies/package_managers/apt.rb +24 -0
  12. data/lib/docker-sync/dependencies/package_managers/base.rb +47 -0
  13. data/lib/docker-sync/dependencies/package_managers/brew.rb +24 -0
  14. data/lib/docker-sync/dependencies/package_managers/none.rb +23 -0
  15. data/lib/docker-sync/dependencies/package_managers/pkg.rb +24 -0
  16. data/lib/docker-sync/dependencies/package_managers/yum.rb +24 -0
  17. data/lib/docker-sync/dependencies/rsync.rb +14 -0
  18. data/lib/docker-sync/dependencies/unison.rb +15 -0
  19. data/lib/docker-sync/dependencies/unox.rb +40 -0
  20. data/lib/docker-sync/environment.rb +19 -0
  21. data/lib/docker-sync/execution.rb +11 -35
  22. data/lib/docker-sync/sync_manager.rb +10 -3
  23. data/lib/docker-sync/sync_process.rb +16 -18
  24. data/lib/docker-sync/sync_strategy/native.rb +3 -4
  25. data/lib/docker-sync/sync_strategy/native_osx.rb +11 -11
  26. data/lib/docker-sync/sync_strategy/rsync.rb +15 -7
  27. data/lib/docker-sync/sync_strategy/unison.rb +13 -12
  28. data/lib/docker-sync/update_check.rb +5 -0
  29. data/lib/docker-sync/upgrade_check.rb +2 -1
  30. data/lib/docker-sync/watch_strategy/dummy.rb +1 -1
  31. data/lib/docker-sync/watch_strategy/fswatch.rb +4 -5
  32. data/lib/docker-sync/watch_strategy/remotelogs.rb +3 -3
  33. data/lib/docker-sync/watch_strategy/unison.rb +2 -2
  34. data/tasks/daemon/daemon.thor +0 -1
  35. data/tasks/stack/stack.thor +8 -9
  36. data/tasks/sync/sync.thor +16 -19
  37. metadata +21 -9
  38. data/lib/docker-sync/preconditions/preconditions_linux.rb +0 -51
  39. data/lib/docker-sync/preconditions/preconditions_osx.rb +0 -174
  40. data/lib/docker-sync/preconditions/strategy.rb +0 -65
@@ -0,0 +1,19 @@
1
+ require 'os'
2
+
3
+ module DockerSync
4
+ module Environment
5
+ def self.linux?
6
+ return @linux if defined? @linux
7
+ @linux = OS.linux?
8
+ end
9
+
10
+ def self.mac?
11
+ return @mac if defined? @mac
12
+ @mac = OS.mac?
13
+ end
14
+
15
+ def self.freebsd?
16
+ @freebsd ||= OS.freebsd?
17
+ end
18
+ end
19
+ end
@@ -2,55 +2,31 @@ require 'open3'
2
2
  require 'thor/shell'
3
3
 
4
4
  module Execution
5
-
6
5
  Thread.abort_on_exception = true
7
6
 
8
- def threadexec(command, prefix = nil, color = nil)
9
-
10
- if prefix.nil?
11
- # TODO: probably pick the command name without args
12
- prefix = 'unknown'
13
- end
14
-
15
- if color.nil?
16
- color = :cyan
17
- end
18
-
19
- Thread.new {
7
+ def thread_exec(command, prefix = 'unknown', color = :cyan)
8
+ Thread.new do
20
9
  Open3.popen3(command) do |_, stdout, stderr, _|
21
-
22
10
  # noinspection RubyAssignmentExpressionInConditionalInspection
23
11
  while line_out = stdout.gets
24
- say_status prefix, line_out, color
12
+ say_status with_time(prefix), line_out, color
25
13
  end
26
14
 
27
15
  # noinspection RubyAssignmentExpressionInConditionalInspection
28
16
  while line_err = stderr.gets
29
- say_status prefix, line_err, :red
17
+ say_status with_time(prefix), line_err, :red
30
18
  end
31
-
32
19
  end
33
- }
34
-
20
+ end
35
21
  end
36
22
 
37
23
  # unison doesn't work when ran in a new thread
38
24
  # this functions creates a full new process instead
39
- def forkexec(command, prefix = nil, color = nil)
40
-
41
- if prefix.nil?
42
- # TODO: probably pick the command name without args
43
- prefix = 'unknown'
44
- end
45
-
46
- if color.nil?
47
- color = :cyan
48
- end
49
-
50
- Process.fork {
51
- `#{command}` || raise(command + ' failed')
52
- }
53
-
25
+ def fork_exec(command, _prefix = 'unknown', _color = :cyan)
26
+ Process.fork { `#{command}` || raise(command + ' failed') }
54
27
  end
55
28
 
56
- end
29
+ def with_time(prefix)
30
+ "[#{Time.now}] #{prefix}"
31
+ end
32
+ end
@@ -4,7 +4,7 @@ require 'docker-sync/sync_process'
4
4
  # noinspection RubyResolve
5
5
  require 'docker-sync/execution'
6
6
 
7
- module Docker_sync
7
+ module DockerSync
8
8
  class SyncManager
9
9
  include Thor::Shell
10
10
 
@@ -40,6 +40,13 @@ module Docker_sync
40
40
  end
41
41
  end
42
42
 
43
+ # set the global max_attempt setting, if the sync-endpoint does not define a own one
44
+ unless config.key?('max_attempt')
45
+ if @config_global.key?('max_attempt')
46
+ @config_syncs[name]['max_attempt'] = @config_global['max_attempt']
47
+ end
48
+ end
49
+
43
50
  if @config_syncs[name].key?('dest')
44
51
  puts 'Please do no longer use "dest" in your docker-sync.yml configuration - also see https://github.com/EugenMayer/docker-sync/wiki/1.2-Upgrade-Guide#dest-has-been-removed!'
45
52
  exit 1
@@ -118,14 +125,14 @@ module Docker_sync
118
125
  sync_process.stop
119
126
  end
120
127
 
121
- rescue Exception => e
128
+ rescue StandardError => e
122
129
  puts "EXCEPTION: #{e.inspect}"
123
130
  puts "MESSAGE: #{e.message}"
124
131
  end
125
132
  end
126
133
 
127
134
  def create_sync(sync_name, sync_configuration)
128
- sync_process = Docker_Sync::SyncProcess.new(sync_name, sync_configuration)
135
+ sync_process = DockerSync::SyncProcess.new(sync_name, sync_configuration)
129
136
  return sync_process
130
137
  end
131
138
 
@@ -11,7 +11,7 @@ require 'docker-sync/watch_strategy/dummy'
11
11
  require 'docker-sync/watch_strategy/unison'
12
12
  require 'docker-sync/watch_strategy/remotelogs'
13
13
 
14
- module Docker_Sync
14
+ module DockerSync
15
15
  class SyncProcess
16
16
  include Thor::Shell
17
17
  @options
@@ -43,13 +43,13 @@ module Docker_Sync
43
43
  def set_sync_strategy
44
44
  case @options['sync_strategy']
45
45
  when 'rsync'
46
- @sync_strategy = Docker_Sync::SyncStrategy::Rsync.new(@sync_name, @options)
46
+ @sync_strategy = DockerSync::SyncStrategy::Rsync.new(@sync_name, @options)
47
47
  when 'unison'
48
- @sync_strategy = Docker_Sync::SyncStrategy::Unison.new(@sync_name, @options)
48
+ @sync_strategy = DockerSync::SyncStrategy::Unison.new(@sync_name, @options)
49
49
  when 'native'
50
- @sync_strategy = Docker_Sync::SyncStrategy::Native.new(@sync_name, @options)
50
+ @sync_strategy = DockerSync::SyncStrategy::Native.new(@sync_name, @options)
51
51
  when 'native_osx'
52
- @sync_strategy = Docker_Sync::SyncStrategy::NativeOsx.new(@sync_name, @options)
52
+ @sync_strategy = DockerSync::SyncStrategy::NativeOsx.new(@sync_name, @options)
53
53
  else
54
54
  raise "Unknown sync_strategy #{@options['sync_strategy']}"
55
55
  end
@@ -58,29 +58,27 @@ module Docker_Sync
58
58
  def set_watch_strategy
59
59
  case @options['watch_strategy']
60
60
  when 'fswatch'
61
- @watch_strategy = Docker_Sync::WatchStrategy::Fswatch.new(@sync_name, @options)
61
+ @watch_strategy = DockerSync::WatchStrategy::Fswatch.new(@sync_name, @options)
62
62
  when 'dummy'
63
- @watch_strategy = Docker_Sync::WatchStrategy::Dummy.new(@sync_name, @options)
63
+ @watch_strategy = DockerSync::WatchStrategy::Dummy.new(@sync_name, @options)
64
64
  when 'unison'
65
- @watch_strategy = Docker_Sync::WatchStrategy::Unison.new(@sync_name, @options)
65
+ @watch_strategy = DockerSync::WatchStrategy::Unison.new(@sync_name, @options)
66
66
  when 'remotelogs'
67
- @watch_strategy = Docker_Sync::WatchStrategy::Remote_logs.new(@sync_name, @options)
67
+ @watch_strategy = DockerSync::WatchStrategy::Remote_logs.new(@sync_name, @options)
68
68
  else
69
69
  raise "Unknown watch_strategy #{@options['watch_strategy']}"
70
70
  end
71
71
  end
72
72
 
73
73
  def get_host_ip_default
74
- return '127.0.0.1' if DockerSync::Preconditions::Strategy.instance.is_driver_docker_for_mac?
75
-
76
- if DockerSync::Preconditions::Strategy.instance.is_driver_docker_toolbox?
77
- cmd = 'docker-machine ip $(docker-machine active)'
78
- stdout, stderr, exit_status = Open3.capture3(cmd)
79
- unless exit_status.success?
80
- raise "Error getting sync_host_ip automatically, exit code #{$?.exitstatus} ... #{stderr}"
81
- end
82
- return stdout.gsub("\n",'')
74
+ return '127.0.0.1' unless Dependencies::Docker::Driver.docker_toolbox?
75
+
76
+ cmd = 'docker-machine ip $(docker-machine active)'
77
+ stdout, stderr, exit_status = Open3.capture3(cmd)
78
+ unless exit_status.success?
79
+ raise "Error getting sync_host_ip automatically, exit code #{$?.exitstatus} ... #{stderr}"
83
80
  end
81
+ stdout.gsub("\n",'')
84
82
  end
85
83
 
86
84
  def run
@@ -1,7 +1,6 @@
1
1
  require 'thor/shell'
2
- require 'docker-sync/preconditions/strategy'
3
2
 
4
- module Docker_Sync
3
+ module DockerSync
5
4
  module SyncStrategy
6
5
  class Native
7
6
  include Thor::Shell
@@ -14,8 +13,8 @@ module Docker_Sync
14
13
  @options = options
15
14
 
16
15
  begin
17
- DockerSync::Preconditions::Strategy.instance.docker_available
18
- rescue Exception => e
16
+ Dependencies::Docker.ensure!
17
+ rescue StandardError => e
19
18
  say_status 'error', "#{@sync_name} has been configured to sync with native docker volume, but docker is not found", :red
20
19
  say_status 'error', e.message, :red
21
20
  exit 1
@@ -1,12 +1,11 @@
1
1
  require 'thor/shell'
2
- require 'docker-sync/preconditions/strategy'
3
2
  require 'docker-sync/execution'
4
3
  require 'docker-sync/update_check'
5
4
  require 'open3'
6
5
  require 'socket'
7
6
  require 'terminal-notifier'
8
7
 
9
- module Docker_Sync
8
+ module DockerSync
10
9
  module SyncStrategy
11
10
  class NativeOsx
12
11
  include Thor::Shell
@@ -32,8 +31,8 @@ module Docker_Sync
32
31
  uc.check_unison_hostsync_image(true)
33
32
 
34
33
  begin
35
- DockerSync::Preconditions::Strategy.instance.docker_available
36
- rescue Exception => e
34
+ Dependencies::Docker.ensure!
35
+ rescue StandardError => e
37
36
  say_status 'error', "#{@sync_name} has been configured to sync with native docker volume, but docker is not found", :red
38
37
  say_status 'error', e.message, :red
39
38
  exit 1
@@ -43,10 +42,10 @@ module Docker_Sync
43
42
  def start_container
44
43
  say_status 'ok', "Starting native_osx for sync #{@sync_name}", :white
45
44
  container_name = get_container_name
46
- host_sync_src = @options['src']
45
+ host_sync_src = File.realpath(@options['src'])
47
46
  volume_app_sync_name = @sync_name
48
47
  env = {}
49
- raise 'sync_user is no longer supported, since it ise no needed, use sync_userid only please', :yellow if @options.key?('sync_user')
48
+ raise 'sync_user is no longer supported, since it is not needed. Use sync_userid only please' if @options.key?('sync_user')
50
49
 
51
50
  ignore_strings = expand_ignore_strings
52
51
  env['UNISON_EXCLUDES'] = ignore_strings.join(' ')
@@ -80,11 +79,12 @@ module Docker_Sync
80
79
  run_privileged = '--privileged' if @options.key?('max_inotify_watches') #TODO: replace by the minimum capabilities required
81
80
  say_status 'ok', 'Starting precopy', :white if @options['verbose']
82
81
  # we just run the precopy script and remove the container
83
- cmd = "docker run --rm -v #{volume_app_sync_name}:/app_sync -v #{host_sync_src}:/host_sync#{host_disk_mount_mode} -e HOST_VOLUME=/host_sync -e APP_VOLUME=/app_sync -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} #{additional_docker_env} #{run_privileged} --name #{container_name} #{@docker_image} /usr/local/bin/precopy_appsync"
84
- `#{cmd}` || raise('Precopy failed')
82
+ cmd = "docker run --rm -v \"#{volume_app_sync_name}:/app_sync\" -v \"#{host_sync_src}:/host_sync#{host_disk_mount_mode}\" -e HOST_VOLUME=/host_sync -e APP_VOLUME=/app_sync -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} #{additional_docker_env} #{run_privileged} --name #{container_name} #{@docker_image} /usr/local/bin/precopy_appsync"
83
+ say_status 'precopy', cmd, :white if @options['verbose']
84
+ system(cmd) || raise('Precopy failed')
85
85
  say_status 'ok', 'Starting container', :white if @options['verbose']
86
86
  # this will be run below and start unison, since we did not manipulate CMD
87
- cmd = "docker run -d -v #{volume_app_sync_name}:/app_sync -v #{host_sync_src}:/host_sync -e HOST_VOLUME=/host_sync -e APP_VOLUME=/app_sync -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} #{additional_docker_env} #{run_privileged} --name #{container_name} #{@docker_image}"
87
+ cmd = "docker run -d -v \"#{volume_app_sync_name}:/app_sync\" -v \"#{host_sync_src}:/host_sync#{host_disk_mount_mode}\" -e HOST_VOLUME=/host_sync -e APP_VOLUME=/app_sync -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} #{additional_docker_env} #{run_privileged} --name #{container_name} #{@docker_image}"
88
88
  else
89
89
  say_status 'ok', "starting #{container_name} container", :white if @options['verbose']
90
90
  cmd = "docker start #{container_name} && docker exec #{container_name} supervisorctl restart unison"
@@ -94,7 +94,7 @@ module Docker_Sync
94
94
  cmd = "docker exec #{container_name} supervisorctl restart unison"
95
95
  end
96
96
  say_status 'command', cmd, :white if @options['verbose']
97
- `#{cmd}` || raise('Start failed')
97
+ system(cmd) || raise('Start failed')
98
98
  say_status 'ok', "starting initial sync of #{container_name}", :white if @options['verbose']
99
99
  # wait until container is started, then sync:
100
100
  say_status 'success', 'Sync container started', :green
@@ -122,7 +122,7 @@ module Docker_Sync
122
122
  say_status 'ok', "Stopping sync container #{get_container_name}"
123
123
  begin
124
124
  stop_container
125
- rescue Exception => e
125
+ rescue StandardError => e
126
126
  say_status 'error', "Stopping failed of #{get_container_name}:", :red
127
127
  puts e.message
128
128
  end
@@ -1,8 +1,7 @@
1
1
  require 'thor/shell'
2
- require 'docker-sync/preconditions/strategy'
3
2
  require 'terminal-notifier'
4
3
 
5
- module Docker_Sync
4
+ module DockerSync
6
5
  module SyncStrategy
7
6
  class Rsync
8
7
  include Thor::Shell
@@ -22,8 +21,8 @@ module Docker_Sync
22
21
  end
23
22
 
24
23
  begin
25
- DockerSync::Preconditions::Strategy.instance.rsync_available
26
- rescue Exception => e
24
+ Dependencies::Rsync.ensure!
25
+ rescue StandardError => e
27
26
  say_status 'error', "#{@sync_name} has been configured to sync with rsync, but no rsync or fswatch binary available", :red
28
27
  say_status 'error', e.message, :red
29
28
  exit 1
@@ -97,8 +96,9 @@ module Docker_Sync
97
96
 
98
97
  user_mapping = get_user_mapping
99
98
  group_mapping = get_group_mapping
99
+ docker_env = get_docker_env
100
100
 
101
- cmd = "docker run -p '#{@options['sync_host_port']}:873' -v #{volume_name}:#{@options['dest']} #{user_mapping} #{group_mapping} -e VOLUME=#{@options['dest']} -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} --name #{container_name} -d #{@docker_image}"
101
+ cmd = "docker run -p '#{@options['sync_host_port']}:873' -v #{volume_name}:#{@options['dest']} #{user_mapping} #{group_mapping} #{docker_env} --name #{container_name} -d #{@docker_image}"
102
102
  else # container already created, just start / reuse it
103
103
  say_status 'ok', "starting #{container_name} container", :white if @options['verbose']
104
104
  cmd = "docker start #{container_name}"
@@ -126,12 +126,20 @@ module Docker_Sync
126
126
  def get_group_mapping
127
127
  group_mapping = ''
128
128
  if @options.key?('sync_groupid')
129
- raise 'for now, rsync does no longer support groupid, but for nearly all cases sync_userid should be enaugh'
129
+ raise 'for now, rsync does no longer support groupid, but for nearly all cases sync_userid should be enough'
130
130
  #group_mapping = "#{group_mapping} -e GROUP_ID=#{@options['sync_groupid']}"
131
131
  end
132
132
  return group_mapping
133
133
  end
134
134
 
135
+ def get_docker_env
136
+ env_mapping = []
137
+ env_mapping << "-e VOLUME=#{@options['dest']}"
138
+ env_mapping << "-e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`}"
139
+ env_mapping << "-e ALLOW=#{@options['sync_host_allow']}" if @options['sync_host_allow']
140
+ env_mapping.join(' ')
141
+ end
142
+
135
143
  def stop_container
136
144
  `docker ps | grep #{get_container_name} && docker stop #{get_container_name}`
137
145
  end
@@ -150,7 +158,7 @@ module Docker_Sync
150
158
  say_status 'ok', "Stopping sync container #{get_container_name}"
151
159
  begin
152
160
  stop_container
153
- rescue Exception => e
161
+ rescue StandardError => e
154
162
  say_status 'error', "Stopping failed of #{get_container_name}:", :red
155
163
  puts e.message
156
164
  end
@@ -1,11 +1,10 @@
1
1
  require 'thor/shell'
2
- require 'docker-sync/preconditions/strategy'
3
2
  require 'docker-sync/execution'
4
3
  require 'open3'
5
4
  require 'socket'
6
5
  require 'terminal-notifier'
7
6
 
8
- module Docker_Sync
7
+ module DockerSync
9
8
  module SyncStrategy
10
9
  class Unison
11
10
  include Thor::Shell
@@ -26,8 +25,8 @@ module Docker_Sync
26
25
  @docker_image = 'eugenmayer/unison'
27
26
  end
28
27
  begin
29
- DockerSync::Preconditions::Strategy.instance.unison_available
30
- rescue Exception => e
28
+ Dependencies::Unison.ensure!
29
+ rescue StandardError => e
31
30
  say_status 'error', "#{@sync_name} has been configured to sync with unison, but no unison available", :red
32
31
  say_status 'error', e.message, :red
33
32
  exit 1
@@ -67,7 +66,7 @@ module Docker_Sync
67
66
  cmd = cmd + 'unison ' + args.join(' ')
68
67
 
69
68
  say_status 'command', cmd, :white if @options['verbose']
70
- forkexec(cmd, "Sync #{@sync_name}", :blue)
69
+ fork_exec(cmd, "Sync #{@sync_name}", :blue)
71
70
  end
72
71
 
73
72
  def sync
@@ -135,9 +134,9 @@ module Docker_Sync
135
134
  def sync_prefer
136
135
  case @options.fetch('sync_prefer', 'default')
137
136
  when 'default' then "-prefer '#{@options['src']}' -copyonconflict" # thats our default, if nothing is set
138
- when 'src' then "-prefer #{@options['src']}"
139
- when 'dest' then "-prefer #{@options['dest']}"
140
- else "-prefer #{@options['sync_prefer']}"
137
+ when 'src' then "-prefer '#{@options['src']}'"
138
+ when 'dest' then "-prefer '#{@options['dest']}'"
139
+ else "-prefer '#{@options['sync_prefer']}'"
141
140
  end
142
141
  end
143
142
 
@@ -165,6 +164,7 @@ module Docker_Sync
165
164
  exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" --format "{{.Names}}" | grep '^#{container_name}$'`
166
165
  if exists == ''
167
166
  say_status 'ok', "creating #{container_name} container", :white if @options['verbose']
167
+ run_privileged = ''
168
168
  run_privileged = '--privileged' if @options.key?('max_inotify_watches') #TODO: replace by the minimum capabilities required
169
169
  cmd = "docker run -p '#{@options['sync_host_ip']}::#{UNISON_CONTAINER_PORT}' -v #{volume_name}:#{@options['dest']} -e VOLUME=#{@options['dest']} -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} #{additional_docker_env} #{run_privileged} --name #{container_name} -d #{@docker_image}"
170
170
  else
@@ -185,22 +185,23 @@ module Docker_Sync
185
185
  attempt = 0
186
186
  max_attempt = @options['max_attempt'] || 5
187
187
  loop do
188
+ # noinspection RubyUnusedLocalVariable
188
189
  stdout, stderr, exit_status = Open3.capture3(cmd)
189
190
  break if exit_status == 0
190
191
  attempt += 1
191
- raise 'Failed to start unison container in time, try to increase max_attempt in your configuration. See https://github.com/EugenMayer/docker-sync/wiki/2.-Configuration for more informations' if attempt > max_attempt
192
+ raise "Failed to start unison container in time, try to increase max_attempt (currently #{max_attempt}) in your configuration. See https://github.com/EugenMayer/docker-sync/wiki/2.-Configuration for more informations" if attempt > max_attempt
192
193
  sleep 1
193
194
  end
194
195
  sync
195
196
  say_status 'success', 'Unison server started', :green
196
197
  end
197
198
 
199
+ # noinspection RubyUnusedLocalVariable
198
200
  def get_host_port(container_name, container_port)
199
- File.exist?('/usr/bin/sed') ? sed = '/usr/bin/sed' : sed = `which sed`.chomp # use macOS native sed in /usr/bin/sed first, fallback to sed in $PATH if it's not there
200
201
  cmd = 'docker inspect --format=\'{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}\' ' + container_name
201
202
  say_status 'command', cmd, :white if @options['verbose']
202
203
  stdout, stderr, exit_status = Open3.capture3(cmd)
203
- if not exit_status.success?
204
+ unless exit_status.success?
204
205
  say_status 'command', cmd
205
206
  say_status 'error', "Error getting mapped port, exit code #{$?.exitstatus}", :red
206
207
  say_status 'message', stderr
@@ -234,7 +235,7 @@ module Docker_Sync
234
235
  say_status 'ok', "Stopping sync container #{get_container_name}"
235
236
  begin
236
237
  stop_container
237
- rescue Exception => e
238
+ rescue StandardError => e
238
239
  say_status 'error', "Stopping failed of #{get_container_name}:", :red
239
240
  puts e.message
240
241
  end
@@ -13,6 +13,7 @@ class UpdateChecker
13
13
  end
14
14
 
15
15
  def run
16
+ return if ENV['DOCKER_SYNC_SKIP_UPDATE']
16
17
  unless @config['update_check']
17
18
  say_status 'hint','Skipping up-to-date check since it has been disabled in your ~/.docker-sync-global.yml configuration',:yellow
18
19
  return
@@ -56,6 +57,7 @@ class UpdateChecker
56
57
  end
57
58
 
58
59
  def check_rsync_image
60
+ return if ENV['DOCKER_SYNC_SKIP_UPDATE']
59
61
  say_status 'ok','Checking if a newer rsync image is available'
60
62
 
61
63
  if system("docker pull eugenmayer/rsync | grep 'Downloaded newer image for'")
@@ -68,6 +70,7 @@ class UpdateChecker
68
70
  end
69
71
 
70
72
  def check_unison_hostsync_image(silent = false)
73
+ return if ENV['DOCKER_SYNC_SKIP_UPDATE']
71
74
  say_status 'ok','Checking if a newer native_osx (unison:hostsync_0.2) image is available' unless silent
72
75
 
73
76
  if system("docker pull eugenmayer/unison:hostsync_0.2 | grep 'Downloaded newer image for'")
@@ -80,6 +83,7 @@ class UpdateChecker
80
83
  end
81
84
 
82
85
  def check_unison_image
86
+ return if ENV['DOCKER_SYNC_SKIP_UPDATE']
83
87
  say_status 'ok','Checking if a newer unison image is available'
84
88
 
85
89
  if system("docker pull eugenmayer/unison | grep 'Downloaded newer image for'")
@@ -104,6 +108,7 @@ class UpdateChecker
104
108
  end
105
109
 
106
110
  def check_and_warn(update_enforced = true)
111
+ return if ENV['DOCKER_SYNC_SKIP_UPDATE']
107
112
  # update the timestamp
108
113
  @config.update! 'update_last_check' => DateTime.now.iso8601(9)
109
114