3 # install on client with:
4 # echo install | nc 10.60.0.92 9001 > bak ; chmod 755 bak
12 my $dir = '../backup';
15 system 'git init' unless -e '.git';
17 my $server = IO::Socket::INET->new(
24 while (my $client = $server->accept()) {
25 my ($command,$path,$message) = split(/\s+/,<$client>,3);
26 my $ip = $client->peerhost;
28 if ( $command eq 'install' ) {
29 print $client '#!/bin/sh',$/,'echo $* | nc 10.60.0.92 9001',$/;
33 warn "$ip [$command] $path | $message\n";
36 system 'ssh-copy-id', "root\@$ip";
43 mkpath "$ip/$dir" unless -e "$ip/$dir";
45 if ( $command eq 'add' ) {
46 warn 'rsync', "root\@$ip:$path", "$ip/$path";
47 system 'rsync', "root\@$ip:$path", "$ip/$path";
48 system 'git', 'add', "$ip/$path";
50 system 'rsync', "root\@$ip:$path", "$ip/$path";
53 $message ||= "$command $ip $path";
54 system 'git', 'commit', '-m', $message, "$ip/$path";