Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using Unison to synchronize my home across several computers, and I've addressed everything but this.

The Dropbox configuration is partially skipped, and as a result Dropbox thinks there is no configuration and goes through the configuration wizard again.

Here's the output from Unison related to dropbox:

Reconciling changes                                                     
         <-?-- dir        .dropbox  
         <---- dir        .dropbox-dist  
         <---- dir        .dropbox-dist-new  
[BGN] Copying .dropbox from /home/.nfs/jorge.suarez/linux-home to /home/remoto/jorge.suarez
[END] Copying .dropbox
[BGN] Copying .dropbox-dist from /home/.nfs/jorge.suarez/linux-home to /home/remoto/jorge.suarez
[END] Copying .dropbox-dist
[BGN] Copying .dropbox-dist-new from /home/.nfs/jorge.suarez/linux-home to /home/remoto/jorge.suarez
[END] Copying .dropbox-dist-new
  partially transferred: .dropbox

Here's the original contents of the directory:

$ ls -lah
total 22M
drwx------  3 jorge.suarez users 3,9K 2013-01-25 21:39 .
drwxr-xr-x 43 jorge.suarez users 3,9K 2013-01-25 21:40 ..
srw-------  1 jorge.suarez users    0 2013-01-25 21:39 command_socket
-rw-------  1 jorge.suarez users 3,0K 2013-01-25 21:39 config.db
-rw-------  1 jorge.suarez users  20K 2013-01-25 21:39 config.dbx
-rw-------  1 jorge.suarez users  66K 2013-01-25 21:39 deleted.dbx
-rw-------  1 jorge.suarez users    4 2013-01-25 21:39 dropbox.pid
-rw-------  1 jorge.suarez users 2,0M 2013-01-25 21:39 filecache.dbx
-rw-------  1 jorge.suarez users   89 2013-01-25 21:39 host.db
-rw-------  1 jorge.suarez users  221 2013-01-25 21:39 host.dbx
-rw-------  1 jorge.suarez users   81 2013-01-25 21:39 hostkeys
srw-------  1 jorge.suarez users    0 2013-01-25 21:39 iface_socket
drwx------  2 jorge.suarez users 3,9K 2013-01-25 21:39 l
-rw-------  1 jorge.suarez users  13K 2013-01-25 21:39 photo.dbx
-rw-------  1 jorge.suarez users  20M 2013-01-25 21:39 sigstore.dbx
-rw-------  1 jorge.suarez users  232 2013-01-25 21:39 unlink.db

And the synchronized one, just before Dropbox gets a chance to be launched:

$ ls -lah
total 22M
drwx------  3 jorge.suarez users 4,0K Xan 25 22:09 .
drwx------ 43 jorge.suarez users 4,0K Xan 25 22:10 ..
-rw-------  1 jorge.suarez users 3,0K Xan 25 22:09 config.db
-rw-------  1 jorge.suarez users  20K Xan 25 22:09 config.dbx
-rw-------  1 jorge.suarez users  66K Xan 25 22:09 deleted.dbx
-rw-------  1 jorge.suarez users    4 Xan 25 22:09 dropbox.pid
-rw-------  1 jorge.suarez users 2,0M Xan 25 22:09 filecache.dbx
-rw-------  1 jorge.suarez users   89 Xan 25 22:09 host.db
-rw-------  1 jorge.suarez users  221 Xan 25 22:09 host.dbx
-rw-------  1 jorge.suarez users   81 Xan 25 22:09 hostkeys
drwx------  2 jorge.suarez users 4,0K Xan 25 22:09 l
-rw-------  1 jorge.suarez users  13K Xan 25 22:09 photo.dbx
-rw-------  1 jorge.suarez users  20M Xan 25 22:09 sigstore.dbx
-rw-------  1 jorge.suarez users  232 Xan 25 22:09 unlink.db

It seems iface_socket and command_socket are skipped because they are socket files. Is there anything I can do about this?

As a workaround, I could just parse the Unison output and create the socket files by hand. That should fix this particular issue, but the problem would remain for other socket files since the Unison output doesn't contain the name of the skipped files.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

As of Unison 2.40 (the latest version as I write), Unison doesn't support any file that isn't a regular file, a directory, or a symbolic link. Prior versions aborted the transfer upon encountering special files; since 2.40 these files are ignored. In 2.40.65, you don't get to see the name of ignored files in the first synchronization but it is displayed in subsequent synchronizations. So you could run Unison manually once, then parse its output to detect special files.

The other options are to patch Unison, or to look for special files manually and copy them.

One method to synchronize these files would be to keep a repository of them. For example, make a parallel hierarchy that encodes the special files with normal files, let Unison synchronize that, and decode the parallel hierarchy back after synchronization. Before running unison, on each side:

mkdir -p .pipes .sockets
find . -type p -exec sh -c '
    mkdir -p ".pipes/${0%/*}";
    touch -r "$0" ".pipes/$0"; chmod -r "$0" ".pipes/$0"
  ' {} \;
find . -type s -exec sh -c '
    mkdir -p ".sockets/${0%/*}";
    touch -r "$0" ".sockets/$0"; chmod -r "$0" ".sockets/$0"
' {} \;

After running unison:

(cd .pipes &&
 find -type f -exec sh -c '
    [ -p "../$0" ] && exit;
    mkfifo "../$0";
    touch -r "$0" "../$0"; chmod -r "$0" "../$0"
  ' {} \;)
find -type p -exec '[ -e ".pipes/$0" ] || rm "$0"' {} \;
(cd .sockets &&
 find -type f -exec sh -c '
    [ -S "../$0" ] && exit;
    python -c "import os, sys; os.mknod(sys.argv[1], 0140000)" "../$0";
    touch -r "$0" "../$0"; chmod -r "$0" "../$0"
' {} \;)
find -type s -exec '[ -e ".sockets/$0" ] || rm "$0"' {} \;

(Warning: untested code. Assumes GNU tools (which includes any non-embedded Linux).)

I think this is more complex than warranted. There are very few applications that rely on a named pipe or socket existing: most create them as needed. Dropbox is the first case I've ever heard of. So I think I'd go for an ad hoc approach: skip the sockets when synchronizing, and create them for Dropbox as part of your new account creation procedure (together with the Unison profile creation and whatever else you do).

share|improve this answer
    
Thank you! I think I understand now your approach (took a while), but I still have some doubts about this being a good idea. What happens if the user deletes a fifo on one side? It won't be gone, ever. Maybe I can assume server->client synchronization only at login, and client->server the rest of the time, but I'm unsure about this. Some advice? –  Jorge Suárez de Lis Jan 26 '13 at 22:04
    
Btw, I'm trying to edit the last bash command, because a little mistake. It should be [ -S "../$0" ], not [ -p "../$0" ]. I can't because the edits must be at least 6 characters. –  Jorge Suárez de Lis Jan 26 '13 at 22:05
    
@JorgeSuárezdeLis Fixed, and I added the deletion code that I had meant to include but forgot. I have doubts as well: this looks far too complex for a very small benefits. I'd go for the ad hoc approach of creating the sockets manually. –  Gilles Jan 26 '13 at 22:17
    
Thank you, I think that the ad hoc approach will do it. I'll also document it so users know that fifos and sockets are not supported. (Also, it is -S, not -s!) –  Jorge Suárez de Lis Jan 27 '13 at 10:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.