Skip to content

Commit

Permalink
Merge pull request EugenMayer#129 from rogamoore/master
Browse files Browse the repository at this point in the history
fix container detection
  • Loading branch information
EugenMayer authored Aug 30, 2016
2 parents 591959f + caa6c54 commit 9e89dcc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/docker-sync/sync_strategy/rsync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def start_container
say_status 'ok', 'Starting rsync', :white
container_name = get_container_name
volume_name = get_volume_name
running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' --format "{{.Names}}" | grep '^#{container_name}$'`
if running == '' # container is yet not running
say_status 'ok', "#{container_name} container not running", :white if @options['verbose']
exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" --format "{{.Names}}" | grep '^#{container_name}$'`
if exists == '' # container has yet not been created
say_status 'ok', "creating #{container_name} container", :white if @options['verbose']

Expand Down
4 changes: 2 additions & 2 deletions lib/docker-sync/sync_strategy/unison-onesided.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def start_container
say_status 'ok', 'Starting unison', :white
container_name = get_container_name
volume_name = get_volume_name
running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' --format "{{.Names}}" | grep '^#{container_name}$'`
if running == ''
say_status 'ok', "#{container_name} container not running", :white if @options['verbose']
exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" --format "{{.Names}}" | grep '^#{container_name}$'`
if exists == ''
say_status 'ok', "creating #{container_name} container", :white if @options['verbose']
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}"
Expand Down
4 changes: 2 additions & 2 deletions lib/docker-sync/sync_strategy/unison.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ def start_container
end

additional_docker_env = env.map{ |key,value| "-e #{key}=\"#{value}\"" }.join(' ')
running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
running = `docker ps --filter 'status=running' --filter 'name=#{container_name}' --format "{{.Names}}" | grep '^#{container_name}$'`
if running == ''
say_status 'ok', "#{container_name} container not running", :white if @options['verbose']
exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" | sed -E -n 's/.*\\s(.*)$/\\1/p' | grep '^#{container_name}$'`
exists = `docker ps --filter "status=exited" --filter "name=#{container_name}" --format "{{.Names}}" | grep '^#{container_name}$'`
if exists == ''
say_status 'ok', "creating #{container_name} container", :white if @options['verbose']
run_privileged = '--privileged' if @options.key?('max_inotify_watches') #TODO: replace by the minimum capabilities required
Expand Down

0 comments on commit 9e89dcc

Please sign in to comment.