Subversion Repositories sysadmin_scripts

Rev

Rev 62 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
62 rodolico 1
#! /usr/bin/env perl
59 rodolico 2
 
62 rodolico 3
use warnings;
4
use strict;
5
 
6
BEGIN {
7
   use FindBin;
8
   use File::Spec;
9
}
10
 
11
# see https://metacpan.org/pod/release/JPEACOCK/version-0.97/lib/version.pod
12
use version; our $VERSION = version->declare("v1.0.0");
13
use Data::Dumper;
14
 
15
my $sourceDir = File::Spec->catdir($FindBin::Bin);
16
 
59 rodolico 17
use Cwd;
60 rodolico 18
use File::Copy;
59 rodolico 19
 
20
my $dir = getcwd; # remember where we downloaded this to
21
 
62 rodolico 22
my $os = qx/uname -a/;
23
if ( $os =~ m/linux/i ) {
24
   $os = 'linux';
25
} elsif ( $os =~m/freebsd/i ) {
26
   $os = 'freebsd';
27
}
28
 
60 rodolico 29
my $installDir = shift;
62 rodolico 30
$installDir = ($os eq 'freebsd' ? '/usr/local/opt' : '/opt' ) . '/sendEmail' unless $installDir;
59 rodolico 31
 
62 rodolico 32
print "Installation Directory = [$installDir]\n";
60 rodolico 33
 
59 rodolico 34
# Add sendEmail to server
60 rodolico 35
`mkdir -p $installDir`;
65 rodolico 36
foreach my $file ( qw/sendEmail.pl sendmail2sendEmail.pl SYSTEM_VERSION/ ) {
37
   copy( "$sourceDir/$file", "$installDir/$file" );
38
}
39
 
40
`ln -f -s $installDir/sendEmail.pl $installDir/sendEmail`;
62 rodolico 41
if ( $os eq 'linux' ) {
42
   `chown -fRv root:root $installDir`;
65 rodolico 43
} elsif ( $os eq 'freebsd' ) {
62 rodolico 44
   `chown -fRv root:wheel $installDir`;
45
}
60 rodolico 46
`chmod 755 $installDir/*`;
59 rodolico 47
 
65 rodolico 48
print `$installDir/SYSTEM_VERSION`;
60 rodolico 49
1;