added cat [host:]/path
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 25 Oct 2010 12:42:07 +0000 (14:42 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 25 Oct 2010 12:42:07 +0000 (14:42 +0200)
README [new file with mode: 0644]
TODO
bak-git-server.pl

diff --git a/README b/README
new file mode 100644 (file)
index 0000000..d533a5c
--- /dev/null
+++ b/README
@@ -0,0 +1,6 @@
+Simple tracking of remote files in central git repository
+with only shell, netcat, rsync and ssh on client
+
+http://blog.rot13.org/bak-git/
+
+
diff --git a/TODO b/TODO
index 8661903..ed3db99 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
 + commit --author support
 + diff/revert from another host:/paths/
 + bak diff without params doesn't return full host diff
 + commit --author support
 + diff/revert from another host:/paths/
 + bak diff without params doesn't return full host diff
++ bak cat host:/path/to/file
 - bak ls
 - daily cron job to create branch with uncommited changes
 - bak ls
 - daily cron job to create branch with uncommited changes
-- bak cat host:/path/to/file
index 4776cc5..1c8efc1 100755 (executable)
@@ -26,6 +26,8 @@ bak command overview:
   bak ch[anges]
   bak revert [host:]/path
 
   bak ch[anges]
   bak revert [host:]/path
 
+  bak cat [host:]/path
+
   bak - push all changed files to server
 
 See L<http://blog.rot13.org/bak-git> for more information
   bak - push all changed files to server
 
 See L<http://blog.rot13.org/bak-git> for more information
@@ -181,6 +183,13 @@ while (my $client = $server->accept()) {
                        print $client git "checkout -- $hostname/$path";
                        system 'rsync', '-avv', "$hostname/$path", "root\@$hostname:$path";
                }
                        print $client git "checkout -- $hostname/$path";
                        system 'rsync', '-avv', "$hostname/$path", "root\@$hostname:$path";
                }
+       } elsif ( $command eq 'cat' ) {
+               my $file_path = ( $on_host ? $on_host : $hostname ) . "/$path";
+               open(my $file, '<', $file_path) || warn "ERROR $file_path: $!";
+               while(<$file>) {
+                       print $client $_;
+               }
+               close($file);
        } else {
                print $client "Unknown command: $command\n";
        }
        } else {
                print $client "Unknown command: $command\n";
        }