#! /usr/bin/env perl

use warnings;
use strict;

our $VERSION = '1.0';

# get files from server
my $saveDir = `pwd`;
chomp $saveDir;
chdir( '/tmp');

`wget -q --no-check-certificate https://clara.dailydata.net:22081/uploadFiles299q/sendEmail/sendEmail.tgz`;  

# Add sendEmail to server   
if ( -d '/opt/sendEmail' ) {
   warn "/opt/sendEmail exists, moving it to /opt/sendEmail.old\n";
   `mv /opt/sendEmail /opt/sendEmail.old`;
}
chdir('/opt');
`tar -xzvf /tmp/sendEmail.tgz`;
`chown -fRv root:root /opt/sendEmail`;
`chmod 755 /opt/sendEmail/*`;
`rm /tmp/sendEmail.tgz`;
`ln -s /opt/sendEmail/sendEmail.pl /opt/sendEmail/sendEmail` unless -x '/opt/sendEmail/sendEmail';

chdir( $saveDir );
print '/opt/sendEmail/sendEmail';
1;
