Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unison > option to map uid from host #21

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/docker_sync/sync_strategy/unison.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ def sync_options
args.push(@options['src'])
args.push('-auto')
args.push('-batch')
args.push('-owner') if @options['sync_userid'] == 'from_host'
args.push('-group') if @options['sync_groupid'] == 'from_host'
args.push('-numericids') if @options['sync_userid'] == 'from_host' || @options['sync_groupid'] == 'from_host'
args.push(@options['sync_args']) if @options.key?('sync_args')
args.push("socket://#{@options['sync_host_ip']}:#{@options['sync_host_port']}/")
args.push('-debug verbose') if @options['verbose']
if @options.key?('sync_user') || @options.key?('sync_group') || @options.key?('sync_groupid') || @options.key?('sync_userid')
if @options.key?('sync_user') || @options.key?('sync_group') || @options.key?('sync_groupid') && @options['sync_groupid'] != 'from_host' || @options.key?('sync_userid') && @options['sync_userid'] != 'from_host'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that looks pretty good. Still ,you need to add this option to example/docker-sync.yml and document it. We should then either offer the same for rsync or state that this is unison only and catch this in rsync as a exception the same way i did this for excludes / users in unison before

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will improve this, as soon as I finish the testing of my unison docker image with fsevents built in it.

raise('Unison does not support sync_user, sync_group, sync_groupid or sync_userid - please use rsync if you need that')
end
return args
Expand All @@ -82,6 +85,7 @@ def start_container
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_VERSION=#{UNISON_VERSION} -e UNISON_WORKING_DIR=#{@options['dest']} --name #{container_name} -d #{UNISON_IMAGE}"
cmd = cmd + " && docker exec #{container_name} chown #{Process.uid} #{@options['dest']}" if @options['sync_userid'] == 'from_host'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not happen here, otherwise its on container start only

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't understand why do we need it elsewhere than docker start ? unison manage uid/gid syncing for other folders, those that will be updated.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when the dest folder on the unison container has uid 10 and you start the container, sync and then run the chown, the files are properly owned.

When you now create a file on the host FS, a new one, which then triggers fswatch, which triggers docker-sync sync - this will just run unison on the host, without the docker exec. This means, the files have the wrong permissions on the host - or are they handled "magical" stickiness?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You maybe didn't have remarked that the chown is not recursive. The only permission issue that we need to manage manually is the 'base' folder. unison handles the permission of all files / directories created inside the 'base' folder with the use of user, group and numericids options.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, those are very intersting points - i simply was not aware of this, thank you!

else
say_status 'ok', "starting #{container_name} container", :white if @options['verbose']
cmd = "docker start #{container_name}"
Expand Down