docker-sync 0.1.1 → 0.1.2

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: 9986beceeb3f875df932e66562fbd84c8e933df5
4
- data.tar.gz: 1f8ca0857499bc05dadefdec2090a99a2f39ecec
3
+ metadata.gz: 3910d6ffb6de84e75c09c017b98179fc2392c380
4
+ data.tar.gz: ad1c1e5f030116680834323636be0b6337637c45
5
5
  SHA512:
6
- metadata.gz: 8a1a678fba8bb4c6ebe4d977d22476d6266d46872ac4b839ccc8d28b3bb915c073cddff0f96116d195b41bb6561e3bf6d386928ef07d5a2d2515731c3039e9c9
7
- data.tar.gz: 2bb30716832245c895b09d7768fab9a97074163eb143376dbba2d2cd11b5330c51c9fc1adb65de8a67ac274f6aa6b71224bd1227746f37a73e1cd04eb1217d28
6
+ metadata.gz: 790a319c6efb072a0b45d6f1cb80d5fa0354859324786150a16b133df016c10ab1d21507f25d7ec0b374292ffe6acb0d1419e37288243028fb65ba4ae9fc8263
7
+ data.tar.gz: 2b1c23f585760a9f55a33de7181f53a241ebf45d33dfbbe5323827949a145feea66a159762784bd9c810122ed2f655b5f78dc5d9d56ecbde3e8255d79e3d0a98
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -41,9 +41,8 @@ class ComposeManager
41
41
  end
42
42
 
43
43
  def run
44
- say_status 'ok','starting compose',:white
44
+ say_status 'ok','starting compose',:green
45
45
  @compose_session.up
46
- say_status 'success','started compose',:green
47
46
  end
48
47
 
49
48
  def stop
@@ -48,12 +48,18 @@ module Preconditions
48
48
  if (find_executable0 'unison-fsmonitor').nil?
49
49
  cmd1 = 'curl "https://raw.githubusercontent.com/hnsl/unox/master/unox.py" -o "/usr/local/bin/unison-fsmonitor" \
50
50
  && chmod +x /usr/local/bin/unison-fsmonitor'
51
- cmd2 = 'easy_install pip && pip install macfsevents'
51
+ cmd2 = 'sudo easy_install pip && sudo pip install macfsevents'
52
52
  Thor::Shell::Basic.new.say_status 'warning', 'Could not find unison-fsmonitor (for file watching) binary in $PATH. Please install unox before you continue, see https://github.com/hnsl/unox.', :yellow
53
- if Thor::Shell::Basic.new.yes?('Shall I install unison-fsmonitor for you?')
54
- `#{cmd1}`
55
- Thor::Shell::Basic.new.say_status 'ok','install macfsevents using pip', :yellow
56
- `#{cmd2}`
53
+ if Thor::Shell::Basic.new.yes?('Shall I install unison-fsmonitor for you? ')
54
+ system cmd1
55
+ if $?.exitstatus > 0
56
+ raise('Failed to install unison-fsmonitor, please file an issue with the output of the error')
57
+ end
58
+ Thor::Shell::Basic.new.say_status 'ok','install macfsevents using pip (This will ask for sudo, since we use the system python)', :yellow
59
+ system cmd2
60
+ if $?.exitstatus > 0
61
+ raise('Failed to install macfsevents, please file an issue with the output of the error')
62
+ end
57
63
  else
58
64
  raise("Please install it, see https://github.com/hnsl/unox, or simply run :\n #{cmd1} && #{cmd2}")
59
65
  end
@@ -70,7 +70,7 @@ module Docker_Sync
70
70
  end
71
71
 
72
72
  def get_host_ip
73
- return 'localhost'
73
+ return '127.0.0.1'
74
74
  end
75
75
 
76
76
  def run
@@ -87,10 +87,10 @@ module Docker_Sync
87
87
  say_status 'ok', 'Starting rsync', :white
88
88
  container_name = get_container_name
89
89
  volume_name = get_volume_name
90
- running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
90
+ running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' --format "{{.Names}}" | grep '^#{container_name}$'`
91
91
  if running == '' # container is yet not running
92
92
  say_status 'ok', "#{container_name} container not running", :white if @options['verbose']
93
- exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
93
+ exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" --format "{{.Names}}" | grep '^#{container_name}$'`
94
94
  if exists == '' # container has yet not been created
95
95
  say_status 'ok', "creating #{container_name} container", :white if @options['verbose']
96
96
 
@@ -78,10 +78,10 @@ module Docker_Sync
78
78
  say_status 'ok', 'Starting unison', :white
79
79
  container_name = get_container_name
80
80
  volume_name = get_volume_name
81
- running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
81
+ running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' --format "{{.Names}}" | grep '^#{container_name}$'`
82
82
  if running == ''
83
83
  say_status 'ok', "#{container_name} container not running", :white if @options['verbose']
84
- exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
84
+ exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" --format "{{.Names}}" | grep '^#{container_name}$'`
85
85
  if exists == ''
86
86
  say_status 'ok', "creating #{container_name} container", :white if @options['verbose']
87
87
  cmd = "docker run -p '#{@options['sync_host_port']}:#{UNISON_CONTAINER_PORT}' -v #{volume_name}:#{@options['dest']} -e UNISON_DIR=#{@options['dest']} -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} --name #{container_name} -d #{@docker_image}"
@@ -80,6 +80,7 @@ module Docker_Sync
80
80
  stdout, stderr, exit_status = Open3.capture3(cmd)
81
81
  if not exit_status.success?
82
82
  say_status 'error', "Error starting sync, exit code #{$?.exitstatus}", :red
83
+ say_status 'message', stdout
83
84
  say_status 'message', stderr
84
85
  else
85
86
  TerminalNotifier.notify(
@@ -94,9 +95,21 @@ module Docker_Sync
94
95
 
95
96
  def sync_options
96
97
  args = []
98
+ exclude_type = 'Path'
99
+ unless @options['sync_excludes_type'].nil?
100
+ exclude_type = @options['sync_excludes_type']
101
+ end
97
102
 
98
103
  unless @options['sync_excludes'].nil?
99
- args = @options['sync_excludes'].map { |pattern| "-ignore='Path #{pattern}'" } + args
104
+ args = @options['sync_excludes'].map do |pattern|
105
+ if exclude_type == 'none'
106
+ # the ignore type like Name / Path are part of the pattern
107
+ ignore_string = "#{pattern}"
108
+ else
109
+ ignore_string = "#{exclude_type} #{pattern}"
110
+ end
111
+ "-ignore='#{ignore_string}'"
112
+ end + args
100
113
  end
101
114
  args.push(@options['src'])
102
115
  args.push('-auto')
@@ -127,14 +140,14 @@ module Docker_Sync
127
140
  end
128
141
 
129
142
  additional_docker_env = env.map{ |key,value| "-e #{key}=\"#{value}\"" }.join(' ')
130
- running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
143
+ running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' --format "{{.Names}}" | grep '^#{container_name}$'`
131
144
  if running == ''
132
145
  say_status 'ok', "#{container_name} container not running", :white if @options['verbose']
133
- exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
146
+ exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" --format "{{.Names}}" | grep '^#{container_name}$'`
134
147
  if exists == ''
135
148
  say_status 'ok', "creating #{container_name} container", :white if @options['verbose']
136
149
  run_privileged = '--privileged' if @options.key?('max_inotify_watches') #TODO: replace by the minimum capabilities required
137
- cmd = "docker run -p '127.0.0.1::#{UNISON_CONTAINER_PORT}' \
150
+ cmd = "docker run -p '#{@options['sync_host_ip']}::#{UNISON_CONTAINER_PORT}' \
138
151
  -v #{volume_name}:#{@options['dest']} \
139
152
  -e UNISON_DIR=#{@options['dest']} \
140
153
  -e TZ=${TZ-`readlink /etc/localtime | sed -e 's,/usr/share/zoneinfo/,,'`} \
@@ -114,11 +114,4 @@ class Sync < Thor
114
114
  print_table(config) if options['verbose']
115
115
  end
116
116
  end
117
- desc 'start', 'Start all sync configurations in this project'
118
- def upgrade
119
- # do run update check in the start command only
120
- upgrades = UpgradeChecker.new
121
- upgrades.run
122
- end
123
-
124
117
  end
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-09 00:00:00.000000000 Z
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor