make source and destination directory for diff
[bak-git.git] / bak-git-server.pl
index 394eec0..5e656a0 100755 (executable)
@@ -55,6 +55,7 @@ $server_ip ||= '127.0.0.1';
 
 my $shell_client = <<__SHELL_CLIENT__;
 #!/bin/sh
+#echo \$USER/\$SUDO_USER $install `pwd` \$* | nc 127.0.0.1 9001
 echo \$USER/\$SUDO_USER `hostname` `pwd` \$* | nc $server_ip 9001
 __SHELL_CLIENT__
 
@@ -167,7 +168,7 @@ while (my $client = $server->accept()) {
                $command = 'log --patch-with-stat' if $command =~ m/^ch/;
                pull_changes( $hostname ) if $command eq 'diff';
                if ( $on_host ) {
-                       mkpath "$hostname/$dir" unless -e "$hostname/$dir";
+                       mkpath $_ foreach grep { ! -e $_ } ( "$hostname/$dir", "$on_host/$dir" );
                        rsync( '-avv', "root\@$hostname:$path", "$hostname/$path" );
                        rsync( '-avv', "root\@$on_host:$path", "$on_host/$path" );
                        open(my $diff, '-|', "diff -Nuw $hostname$path $on_host$path");
@@ -196,6 +197,8 @@ while (my $client = $server->accept()) {
                        print $client $_;
                }
                close($file);
+       } elsif ( $command eq 'ls' ) {
+               print $client `ls $backup_path`;
        } else {
                print $client "Unknown command: $command\n";
        }