push bak update with --install
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 18 Feb 2010 12:45:40 +0000 (13:45 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 18 Feb 2010 12:45:40 +0000 (13:45 +0100)
server.pl

index 13da6cf..c7b842a 100755 (executable)
--- a/server.pl
+++ b/server.pl
@@ -24,6 +24,12 @@ use strict;
 use autodie;
 use IO::Socket::INET;
 use File::Path;
+use Getopt::Long;
+
+my $install = 0;
+GetOptions(
+       'install!' => \$install,
+) || die "$!\n";
 
 my ( $dir, $server_ip ) = @ARGV;
 die "usage: $0 /backup/directory\n" unless $dir;
@@ -37,6 +43,17 @@ __SHELL_CLIENT__
 chdir $dir;
 system 'git init' unless -e '.git';
 
+if ( $install ) {
+       open(my $fh, '>', '/tmp/bak');
+       print $fh $shell_client;
+       close($fh);
+
+       foreach my $hostname ( glob '*' ) {
+               warn "install on $hostname\n";
+               system "scp /tmp/bak root\@$hostname:/usr/local/bin/";
+       }
+}
+
 my $server = IO::Socket::INET->new(
        Proto     => 'tcp',
        LocalAddr => $server_ip,