docker-sync 0.2.0.beta5 → 0.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 94abd2200815b1114719e58149b90ecf713ff5ee
4
- data.tar.gz: f3e8d3f36eaf2046aa0f664670659aba57265e19
3
+ metadata.gz: 06142b9ee0f12f549b75f3671aaab289c2cb43ea
4
+ data.tar.gz: 1257430a3b878a2d94970480ee02114f3c6606ba
5
5
  SHA512:
6
- metadata.gz: dc26e58c0a5641cd7aadb5fd6af54a07cfb7b6e3760d0f71782aae7d83273ceadfd4cbc6b8f58e396aaeda64d53f8d951c30c02a172d610fb1a9178425b3aabc
7
- data.tar.gz: bad573788249515c63475299b2058b38240589ae27fce69e1ce9396729d22a6db5ea4da957dbee6932a08aae2c22b2572af088e464fb09538be8b479a7f1ec51
6
+ metadata.gz: e96b8b6cb06680f069f75deec3e76be6ff8aa0c46b9e50308e0817bef903caf4c30c2afa41ca4ba40f48c3d28747963b90a0b21dcd8e9f630faf2b2ea97806b0
7
+ data.tar.gz: 7c93d7cff89803103207818b6c0500948914482d319c9aff5bffa42e19b4911f42c482638ea3513a2c02b2a6415c77d5658b7f9f2f803e84135713d97457a288
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.beta5
1
+ 0.2.0.rc1
@@ -116,26 +116,17 @@ module Docker_Sync
116
116
 
117
117
  def get_user_mapping
118
118
  user_mapping = ''
119
- if @options.key?('sync_user')
120
- user_mapping = "-e OWNER=#{@options['sync_user']}"
121
- if @options.key?('sync_userid')
122
- user_mapping = "#{user_mapping} -e OWNERID=#{@options['sync_userid']}"
123
- end
124
- elsif @options.key?('sync_userid')
125
- raise("#{get_container_name}: You have set a sync_userid but no sync_user - you need to set both")
119
+ if @options.key?('sync_userid')
120
+ user_mapping = "#{user_mapping} -e OWNER_UID=#{@options['sync_userid']}"
126
121
  end
127
122
  return user_mapping
128
123
  end
129
124
 
130
125
  def get_group_mapping
131
126
  group_mapping = ''
132
- if @options.key?('sync_group')
133
- group_mapping = "-e GROUP=#{@options['sync_group']}"
134
- if @options.key?('sync_groupid')
135
- group_mapping = "#{group_mapping} -e GROUPID=#{@options['sync_groupid']}"
136
- end
137
- elsif @options.key?('sync_groupid')
138
- raise("#{get_container_name}: You have set a sync_groupid but no sync_group - you need to set both")
127
+ if @options.key?('sync_groupid')
128
+ raise 'for now, rsync does no longer support groupid, but for nearly all cases sync_userid should be enaugh'
129
+ #group_mapping = "#{group_mapping} -e GROUP_ID=#{@options['sync_groupid']}"
139
130
  end
140
131
  return group_mapping
141
132
  end
@@ -23,11 +23,12 @@ module Docker_Sync
23
23
  if @options.key?('image')
24
24
  @docker_image = @options['image']
25
25
  else
26
- @docker_image = 'eugenmayer/unison:unox'
26
+ @docker_image = 'eugenmayer/unison'
27
27
  end
28
28
  begin
29
29
  Preconditions::unison_available
30
30
  Preconditions::unox_available
31
+ Preconditions::macfsevents_available
31
32
  rescue Exception => e
32
33
  say_status 'error', "#{@sync_name} has been configured to sync with unison, but no unison available", :red
33
34
  say_status 'error', e.message, :red
@@ -121,7 +122,7 @@ module Docker_Sync
121
122
  args.push(@options['src'])
122
123
  args.push('-auto')
123
124
  args.push('-batch')
124
- args.push(sync_prefer) if @options.key?('sync_prefer')
125
+ args.push(sync_prefer)
125
126
  args.push(@options['sync_args']) if @options.key?('sync_args')
126
127
  sync_host_port = get_host_port(get_container_name, UNISON_CONTAINER_PORT)
127
128
  args.push("socket://#{@options['sync_host_ip']}:#{sync_host_port}")
@@ -132,11 +133,17 @@ module Docker_Sync
132
133
  return args
133
134
  end
134
135
 
136
+ # cares about conflict resolution
135
137
  def sync_prefer
138
+ # thats our default, if nothing is set
139
+ unless @options.key?('sync_prefer') || @options['sync_prefer'] == 'default'
140
+ return "-prefer '#{@options['src']}' -copyonconflict"
141
+ end
142
+
136
143
  case @options['sync_prefer']
137
- when 'src' then "-prefer #{@options['src']}"
138
- when 'dest' then "-prefer #{@options['dest']}"
139
- else "-prefer #{@options['sync_prefer']}"
144
+ when 'src' then "-prefer #{@options['src']}"
145
+ when 'dest' then "-prefer #{@options['dest']}"
146
+ else "-prefer #{@options['sync_prefer']}"
140
147
  end
141
148
  end
142
149
 
@@ -145,14 +152,15 @@ module Docker_Sync
145
152
  container_name = get_container_name
146
153
  volume_name = get_volume_name
147
154
  env = {}
155
+ say_status 'ok', 'sync_user is no longer supported, since it ise no needed, use sync_userid only please', :yellow if @options.key?('sync_user')
156
+
148
157
  ignore_strings = expand_ignore_strings
149
158
  env['UNISON_EXCLUDES'] = ignore_strings.join(' ')
150
- env['UNISON_OWNER'] = @options['sync_user'] if @options.key?('sync_user')
151
159
  env['MAX_INOTIFY_WATCHES'] = @options['max_inotify_watches'] if @options.key?('max_inotify_watches')
152
160
  if @options['sync_userid'] == 'from_host'
153
- env['UNISON_OWNER_UID'] = Process.uid
161
+ env['OWNER_UID'] = Process.uid
154
162
  else
155
- env['UNISON_OWNER_UID'] = @options['sync_userid'] if @options.key?('sync_userid')
163
+ env['OWNER_UID'] = @options['sync_userid'] if @options.key?('sync_userid')
156
164
  end
157
165
 
158
166
  additional_docker_env = env.map{ |key,value| "-e #{key}=\"#{value}\"" }.join(' ')
@@ -165,7 +173,7 @@ module Docker_Sync
165
173
  run_privileged = '--privileged' if @options.key?('max_inotify_watches') #TODO: replace by the minimum capabilities required
166
174
  cmd = "docker run -p '#{@options['sync_host_ip']}::#{UNISON_CONTAINER_PORT}' \
167
175
  -v #{volume_name}:#{@options['dest']} \
168
- -e UNISON_DIR=#{@options['dest']} \
176
+ -e VOLUME=#{@options['dest']} \
169
177
  -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} \
170
178
  #{additional_docker_env} \
171
179
  #{run_privileged} \
@@ -200,7 +208,7 @@ module Docker_Sync
200
208
 
201
209
  def get_host_port(container_name, container_port)
202
210
  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
203
- cmd = 'docker inspect --format=" {{ .NetworkSettings.Ports }} " ' + container_name + " | #{sed} " + '-E "s/.*map\[' + container_port + '[^ ]+ ([0-9]*)[^0-9].*/\1/"'
211
+ cmd = 'docker inspect --format=\'{{(index (index .NetworkSettings.Ports "5000/tcp") 0).HostPort}}\' ' + container_name
204
212
  say_status 'command', cmd, :white if @options['verbose']
205
213
  stdout, stderr, exit_status = Open3.capture3(cmd)
206
214
  if not exit_status.success?
@@ -63,7 +63,7 @@ class UpdateChecker
63
63
  def check_unison_image
64
64
  say_status 'ok','Checking if a newer unison image is available'
65
65
 
66
- if system("docker pull eugenmayer/unison:unox | grep 'Downloaded newer image for'")
66
+ if system("docker pull eugenmayer/unison | grep 'Downloaded newer image for'")
67
67
  say_status 'ok', 'Downloaded newer image for unison', :green
68
68
  @newer_image_found = true
69
69
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.beta5
4
+ version: 0.2.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-18 00:00:00.000000000 Z
11
+ date: 2017-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor