#!/usr/bin/perl

use Net::SCP::Expect;

&swarm_files();


sub swarm_files(){

	my %ConfigHash =(
		"1"	=> my $CfG1 = { 
				"HOST"	=> "85.214.66.15",	# fishwarez
				"USER"	=> "root",
				"PASS"	=> "",
				"PATH"	=> "/root/zoozle/updates/"
				},
		#	"2"	=> my $CfG2 = { 
		#			"HOST"	=> "HOSTIP",
		#			"USER"	=> "USERNAME",
		#			"PASS"	=> "PASSWORD",
		#			"PATH"	=> "/root/.mutella"	 # wo soll es gespeichert werden
		#			}, 
	);

	# von A nach B kopieren
	while ( my ($key, $value) = each(%ConfigHash) ) {

		my $RemoteUserName	= $value->{ 'USER' };
		my $RemotePassword	= $value->{ 'PASS' };
		my $RemoteHostname	= $value->{ 'HOST' };
		my $RemoteStorePath	= $value->{ 'PATH' };

		# print "SCP: $RemoteUserName $RemotePassword $RemoteHostname $RemoteStorePath\n";

		my $SCP = Net::SCP::Expect->new(
			host		=> "$RemoteHostname",
			user		=> "$RemoteUserName",
			password	=> "$RemotePassword" );

		$SCP->auto_yes(1);
		$SCP->scp("/root/zoozle/bots/emule_news.txt","$RemoteUserName\@$RemoteHostname:$RemoteStorePath");
		$SCP->scp("/root/zoozle/bots/torrent_news.txt","$RemoteUserName\@$RemoteHostname:$RemoteStorePath");
		undef $SCP;

	}; # while (my ($key, $value) = each(%ConfigHash) ) {}
	
	$now_string = localtime;
	print "$now_string: I swarmed the files to slaves\n";

}; # sub swarm_files(){
