Subversion Repositories sysadmin_scripts

Rev

Rev 65 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#! /usr/bin/env perl

use warnings;
use strict;

BEGIN {
   use FindBin;
   use File::Spec;
}

# see https://metacpan.org/pod/release/JPEACOCK/version-0.97/lib/version.pod
use version; our $VERSION = version->declare("v1.0.0");
use Data::Dumper;

my $sourceDir = File::Spec->catdir($FindBin::Bin);

use Cwd;
use File::Copy;

my $dir = getcwd; # remember where we downloaded this to

my $os = qx/uname -a/;
if ( $os =~ m/linux/i ) {
   $os = 'linux';
} elsif ( $os =~m/freebsd/i ) {
   $os = 'freebsd';
}

my $installDir = shift;
$installDir = ($os eq 'freebsd' ? '/usr/local/opt' : '/opt' ) . '/sendEmail' unless $installDir;

print "Installation Directory = [$installDir]\n";

# Add sendEmail to server
`mkdir -p $installDir`;
foreach my $file ( qw/sendEmail.pl sendmail2sendEmail.pl SYSTEM_VERSION/ ) {
   copy( "$sourceDir/$file", "$installDir/$file" );
}

`ln -f -s $installDir/sendEmail.pl $installDir/sendEmail`;
if ( $os eq 'linux' ) {
   `chown -fRv root:root $installDir`;
} elsif ( $os eq 'freebsd' ) {
   `chown -fRv root:wheel $installDir`;
}
`chmod 755 $installDir/*`;

print `$installDir/SYSTEM_VERSION`;
1;