| 101 | 
           rodolico | 
           1 | 
           #! /usr/bin/env perl
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           use strict;
  | 
        
        
            | 
            | 
           4 | 
           use warnings;
  | 
        
        
            | 
            | 
           5 | 
              | 
        
        
           | 132 | 
           rodolico | 
           6 | 
           # install.pl
  | 
        
        
            | 
            | 
           7 | 
           #
  | 
        
        
            | 
            | 
           8 | 
           # installer for perl script, in this case, sysinfo
  | 
        
        
            | 
            | 
           9 | 
           #
  | 
        
        
            | 
            | 
           10 | 
           # Revision history
  | 
        
        
            | 
            | 
           11 | 
           #
  | 
        
        
            | 
            | 
           12 | 
           # Version 1.1.7 20161010 RWR
  | 
        
        
            | 
            | 
           13 | 
           # Added ability to validate required libraries are installed
  | 
        
        
            | 
            | 
           14 | 
           #
  | 
        
        
            | 
            | 
           15 | 
           # version 1.2 20170327 RWR
  | 
        
        
            | 
            | 
           16 | 
           # did some major modifications to correctly work on BSD systems also
  | 
        
        
            | 
            | 
           17 | 
           #
  | 
        
        
            | 
            | 
           18 | 
           # version 2.0 20190330 RWR
  | 
        
        
            | 
            | 
           19 | 
           # changed it so all configs are YAML
  | 
        
        
            | 
            | 
           20 | 
           #
  | 
        
        
            | 
            | 
           21 | 
           # version 3.0 20191105 RWR
  | 
        
        
            | 
            | 
           22 | 
           # set up so all options are presented on initial screen
  | 
        
        
            | 
            | 
           23 | 
           # user can choose options to edit
  | 
        
        
            | 
            | 
           24 | 
           # rest of install is automatic
  | 
        
        
           | 138 | 
           rodolico | 
           25 | 
           #
  | 
        
        
            | 
            | 
           26 | 
           # version 3.1 20191112 RWR
  | 
        
        
            | 
            | 
           27 | 
           # Added logging. Log file will be written to the install directory with
  | 
        
        
            | 
            | 
           28 | 
           # the application name.log as the name (application name taken from installer_config.pl)
  | 
        
        
           | 144 | 
           rodolico | 
           29 | 
           #
  | 
        
        
            | 
            | 
           30 | 
           # version 3.1.1 20191117 RWR
  | 
        
        
            | 
            | 
           31 | 
           # Added the ability to verify cpan is installed and configured on systems which need it
  | 
        
        
            | 
            | 
           32 | 
           #
  | 
        
        
           | 156 | 
           rodolico | 
           33 | 
           # version 3.1.2 20200215 RWR
  | 
        
        
            | 
            | 
           34 | 
           # Adding version comparisons
  | 
        
        
           | 101 | 
           rodolico | 
           35 | 
              | 
        
        
           | 132 | 
           rodolico | 
           36 | 
           # find our location and use it for searching for libraries
  | 
        
        
            | 
            | 
           37 | 
           BEGIN {
  | 
        
        
            | 
            | 
           38 | 
              use FindBin;
  | 
        
        
            | 
            | 
           39 | 
              use File::Spec;
  | 
        
        
           | 203 | 
           rodolico | 
           40 | 
              # use libraries from the directory this script is in
  | 
        
        
           | 132 | 
           rodolico | 
           41 | 
              use lib File::Spec->catdir($FindBin::Bin);
  | 
        
        
           | 203 | 
           rodolico | 
           42 | 
              # and its parent
  | 
        
        
            | 
            | 
           43 | 
              use lib File::Spec->catdir( $FindBin::Bin . '/../' );
  | 
        
        
           | 132 | 
           rodolico | 
           44 | 
              eval( 'use YAML::Tiny' );
  | 
        
        
            | 
            | 
           45 | 
           }
  | 
        
        
            | 
            | 
           46 | 
              | 
        
        
           | 101 | 
           rodolico | 
           47 | 
           my $sourceDir = File::Spec->catdir($FindBin::Bin);
  | 
        
        
            | 
            | 
           48 | 
              | 
        
        
           | 156 | 
           rodolico | 
           49 | 
           use Digest::MD5 qw(md5_hex);
  | 
        
        
            | 
            | 
           50 | 
              | 
        
        
            | 
            | 
           51 | 
           # define the version number
  | 
        
        
            | 
            | 
           52 | 
           # see https://metacpan.org/pod/release/JPEACOCK/version-0.97/lib/version.pod
  | 
        
        
            | 
            | 
           53 | 
           use version;
  | 
        
        
           | 203 | 
           rodolico | 
           54 | 
           our $VERSION = version->declare("v3.002.001");
  | 
        
        
           | 156 | 
           rodolico | 
           55 | 
              | 
        
        
            | 
            | 
           56 | 
              | 
        
        
           | 132 | 
           rodolico | 
           57 | 
           use Data::Dumper;
  | 
        
        
            | 
            | 
           58 | 
           use File::Basename;
  | 
        
        
            | 
            | 
           59 | 
           use Getopt::Long;
  | 
        
        
           | 101 | 
           rodolico | 
           60 | 
              | 
        
        
           | 132 | 
           rodolico | 
           61 | 
           our %install;
  | 
        
        
            | 
            | 
           62 | 
           our %operatingSystems;
  | 
        
        
            | 
            | 
           63 | 
           our %libraries;
  | 
        
        
            | 
            | 
           64 | 
           our %binaries;
  | 
        
        
           | 206 | 
           rodolico | 
           65 | 
           # load the definitions from installer_config.pl
  | 
        
        
           | 132 | 
           rodolico | 
           66 | 
           do "$sourceDir/installer_config.pl";
  | 
        
        
           | 138 | 
           rodolico | 
           67 | 
           #
  | 
        
        
            | 
            | 
           68 | 
           # set up log file
  | 
        
        
            | 
            | 
           69 | 
           my $logFile = $install{'application name'};
  | 
        
        
            | 
            | 
           70 | 
           $logFile =~ s/ /_/g;
  | 
        
        
            | 
            | 
           71 | 
           $logFile = "$sourceDir/$logFile.log";
  | 
        
        
           | 132 | 
           rodolico | 
           72 | 
              | 
        
        
            | 
            | 
           73 | 
           Getopt::Long::Configure ("bundling"); # allow -vd --os='debian'
  | 
        
        
            | 
            | 
           74 | 
           my $dryRun = 0;
  | 
        
        
            | 
            | 
           75 | 
           my $os;
  | 
        
        
            | 
            | 
           76 | 
           my $help = 0;
  | 
        
        
            | 
            | 
           77 | 
           my $version = 0;
  | 
        
        
           | 206 | 
           rodolico | 
           78 | 
           my $quiet = 0;
  | 
        
        
            | 
            | 
           79 | 
           my $inplace = 0;
  | 
        
        
           | 132 | 
           rodolico | 
           80 | 
              | 
        
        
            | 
            | 
           81 | 
           my @messages; # stores any messages we want to show up at the end
  | 
        
        
            | 
            | 
           82 | 
           my @feedback; # store feedback when we execute command line actions
  | 
        
        
            | 
            | 
           83 | 
              | 
        
        
            | 
            | 
           84 | 
           my %configuration;
  | 
        
        
            | 
            | 
           85 | 
              | 
        
        
            | 
            | 
           86 | 
           # simple display if --help is passed
  | 
        
        
            | 
            | 
           87 | 
           sub help {
  | 
        
        
            | 
            | 
           88 | 
              my $oses = join( ' ', keys %operatingSystems );
  | 
        
        
           | 156 | 
           rodolico | 
           89 | 
              use File::Basename;
  | 
        
        
            | 
            | 
           90 | 
              print basename($0) . " $VERSION\n";
  | 
        
        
           | 132 | 
           rodolico | 
           91 | 
              print <<END
  | 
        
        
           | 156 | 
           rodolico | 
           92 | 
           $0 [options]
  | 
        
        
            | 
            | 
           93 | 
           Options:
  | 
        
        
            | 
            | 
           94 | 
              --os      - osname is one of [$oses]
  | 
        
        
            | 
            | 
           95 | 
              --dryrun  - do not actually do anything, just tell you what I'd do
  | 
        
        
            | 
            | 
           96 | 
              --version - display version and exit
  | 
        
        
           | 206 | 
           rodolico | 
           97 | 
              --quiet   - Do not ask questions, just do stuff
  | 
        
        
            | 
            | 
           98 | 
              --inplace - Do an inplace upgrade
  | 
        
        
            | 
            | 
           99 | 
              | 
        
        
            | 
            | 
           100 | 
           For an inplace upgrade, it is assumed the source code has been
  | 
        
        
            | 
            | 
           101 | 
           downloaded and installed into the correct directories already
  | 
        
        
           | 132 | 
           rodolico | 
           102 | 
           END
  | 
        
        
           | 101 | 
           rodolico | 
           103 | 
           }
  | 
        
        
            | 
            | 
           104 | 
              | 
        
        
           | 138 | 
           rodolico | 
           105 | 
           #######################################################
  | 
        
        
           | 144 | 
           rodolico | 
           106 | 
           #
  | 
        
        
            | 
            | 
           107 | 
           # timeStamp
  | 
        
        
            | 
            | 
           108 | 
           #
  | 
        
        
            | 
            | 
           109 | 
           # return current system date as YYYY-MM-DD HH:MM:SS
  | 
        
        
            | 
            | 
           110 | 
           #
  | 
        
        
            | 
            | 
           111 | 
           #######################################################
  | 
        
        
            | 
            | 
           112 | 
           sub timeStamp {
  | 
        
        
            | 
            | 
           113 | 
              my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
  | 
        
        
            | 
            | 
           114 | 
              return sprintf "%4d-%02d-%02d %02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec;
  | 
        
        
            | 
            | 
           115 | 
           }
  | 
        
        
            | 
            | 
           116 | 
              | 
        
        
            | 
            | 
           117 | 
           sub yesno {
  | 
        
        
            | 
            | 
           118 | 
              my ( $prompt, $default ) = @_;
  | 
        
        
            | 
            | 
           119 | 
              $default = 'yes' unless $default;
  | 
        
        
            | 
            | 
           120 | 
              my $answer = &getAnswer( $prompt, $default eq 'yes' ? ('yes','no' ) : ('no', 'yes') );
  | 
        
        
            | 
            | 
           121 | 
              return lc( substr( $answer, 0, 1 ) ) eq 'y';
  | 
        
        
            | 
            | 
           122 | 
           }
  | 
        
        
            | 
            | 
           123 | 
              | 
        
        
            | 
            | 
           124 | 
           # prompt the user for a response, then allow them to enter it
  | 
        
        
            | 
            | 
           125 | 
           # the first response is considered the default and is printed
  | 
        
        
            | 
            | 
           126 | 
           # in all caps if more than one exists
  | 
        
        
            | 
            | 
           127 | 
           # first answer is used if they simply press the Enter
  | 
        
        
            | 
            | 
           128 | 
           # key. The response is returned all lower case if more than one
  | 
        
        
            | 
            | 
           129 | 
           # exists.
  | 
        
        
            | 
            | 
           130 | 
           # it is assumed 
  | 
        
        
            | 
            | 
           131 | 
           sub getAnswer {
  | 
        
        
            | 
            | 
           132 | 
              my ( $prompt, @answers ) = @_;
  | 
        
        
            | 
            | 
           133 | 
              $answers[0] = '' unless defined( $answers[0] );
  | 
        
        
            | 
            | 
           134 | 
              my $default = $answers[0];
  | 
        
        
            | 
            | 
           135 | 
              my $onlyOneAnswer = scalar( @answers ) == 1;
  | 
        
        
            | 
            | 
           136 | 
              print $prompt . '[ ';
  | 
        
        
            | 
            | 
           137 | 
              $answers[0] = uc $answers[0] unless $onlyOneAnswer;
  | 
        
        
            | 
            | 
           138 | 
              print join( ' | ', @answers ) . ' ]: ';
  | 
        
        
            | 
            | 
           139 | 
              my $thisAnswer = <>;
  | 
        
        
            | 
            | 
           140 | 
              chomp $thisAnswer;
  | 
        
        
            | 
            | 
           141 | 
              $thisAnswer = $default unless $thisAnswer;
  | 
        
        
            | 
            | 
           142 | 
              return $thisAnswer;
  | 
        
        
            | 
            | 
           143 | 
           }
  | 
        
        
            | 
            | 
           144 | 
              | 
        
        
            | 
            | 
           145 | 
              | 
        
        
            | 
            | 
           146 | 
           #######################################################
  | 
        
        
           | 138 | 
           rodolico | 
           147 | 
           # function to simply log things
  | 
        
        
            | 
            | 
           148 | 
           # first parameter is the priority, if <= $logDef->{'log level'} will print
  | 
        
        
            | 
            | 
           149 | 
           # all subsequent parameters assumed to be strings to sent to the log
  | 
        
        
            | 
            | 
           150 | 
           # returns 0 on failure
  | 
        
        
            | 
            | 
           151 | 
           #         1 on success
  | 
        
        
            | 
            | 
           152 | 
           #         2 if priority > log level
  | 
        
        
            | 
            | 
           153 | 
           #        -1 if $logDef is unset
  | 
        
        
            | 
            | 
           154 | 
           # currently, only logs to a file
  | 
        
        
            | 
            | 
           155 | 
           #######################################################
  | 
        
        
            | 
            | 
           156 | 
           sub logIt {
  | 
        
        
           | 140 | 
           rodolico | 
           157 | 
              open LOG, ">>$logFile" or die "Could not append to $logFile: $!\n";
  | 
        
        
           | 138 | 
           rodolico | 
           158 | 
              while ( my $t = shift ) {
  | 
        
        
            | 
            | 
           159 | 
                 print LOG &timeStamp() . "\t$t\n";
  | 
        
        
            | 
            | 
           160 | 
              }
  | 
        
        
            | 
            | 
           161 | 
              close LOG;
  | 
        
        
            | 
            | 
           162 | 
              return 1;
  | 
        
        
            | 
            | 
           163 | 
           }
  | 
        
        
           | 101 | 
           rodolico | 
           164 | 
              | 
        
        
           | 138 | 
           rodolico | 
           165 | 
              | 
        
        
           | 132 | 
           rodolico | 
           166 | 
           # attempt to locate the operating system.
  | 
        
        
            | 
            | 
           167 | 
           # if found, will set some defaults for it.
  | 
        
        
            | 
            | 
           168 | 
           sub setUpOperatingSystemSpecific {
  | 
        
        
            | 
            | 
           169 | 
              my ( $install, $operatingSystems, $os, $installDir ) = @_;
  | 
        
        
           | 138 | 
           rodolico | 
           170 | 
              &logIt( 'Entering setUpOperatingSystemSpecific' );
  | 
        
        
            | 
            | 
           171 | 
              &logIt( "They passed $os in as the \$os" );
  | 
        
        
           | 132 | 
           rodolico | 
           172 | 
              if ( $os ) {
  | 
        
        
            | 
            | 
           173 | 
                 # We found the OS, set up some defaults
  | 
        
        
            | 
            | 
           174 | 
                 $$install{'os'} = $os;
  | 
        
        
           | 138 | 
           rodolico | 
           175 | 
                 &logIt( "Setting keys for operating system" );
  | 
        
        
           | 132 | 
           rodolico | 
           176 | 
                 # merge operatingSystems into install
  | 
        
        
            | 
            | 
           177 | 
                 foreach my $key ( keys %{$operatingSystems->{$os}} ) {
  | 
        
        
            | 
            | 
           178 | 
                    if ( $key eq 'files' ) {
  | 
        
        
            | 
            | 
           179 | 
                       $install->{'files'} = { %{$install->{'files'}}, %{$operatingSystems->{$os}->{'files'}} }
  | 
        
        
            | 
            | 
           180 | 
                    } else {
  | 
        
        
            | 
            | 
           181 | 
                       $install->{$key} = $operatingSystems->{ $os }->{$key};
  | 
        
        
            | 
            | 
           182 | 
                    }
  | 
        
        
            | 
            | 
           183 | 
                 } # if it is a known OS
  | 
        
        
            | 
            | 
           184 | 
              } # if
  | 
        
        
            | 
            | 
           185 | 
              return $os;
  | 
        
        
            | 
            | 
           186 | 
           } # getOperatingSystem
  | 
        
        
            | 
            | 
           187 | 
              | 
        
        
            | 
            | 
           188 | 
           # validates the libraries needed exist
  | 
        
        
            | 
            | 
           189 | 
           # simply eval's each library. If it doesn't exist, creates a list of
  | 
        
        
            | 
            | 
           190 | 
           # commands to be executed to install it, and displays missing libraries
  | 
        
        
            | 
            | 
           191 | 
           # offering to install them if possible.
  | 
        
        
            | 
            | 
           192 | 
           sub validateLibraries {
  | 
        
        
            | 
            | 
           193 | 
              my ( $libraries, $os ) = @_;
  | 
        
        
           | 138 | 
           rodolico | 
           194 | 
              &logIt( 'Entering validateLibraries' );
  | 
        
        
           | 132 | 
           rodolico | 
           195 | 
              my %return;
  | 
        
        
            | 
            | 
           196 | 
              foreach my $lib ( keys %$libraries ) {
  | 
        
        
           | 138 | 
           rodolico | 
           197 | 
                 &logIt( "Checking on library $lib" );
  | 
        
        
           | 132 | 
           rodolico | 
           198 | 
                 eval( "use $lib;" );
  | 
        
        
            | 
            | 
           199 | 
                 if ( $@ ) {
  | 
        
        
            | 
            | 
           200 | 
                    $return{ $lib } = $libraries->{$lib}->{$os} ? $libraries->{$lib}->{$os} : 'UNK';
  | 
        
        
            | 
            | 
           201 | 
                 }
  | 
        
        
            | 
            | 
           202 | 
              }
  | 
        
        
            | 
            | 
           203 | 
              return \%return;
  | 
        
        
            | 
            | 
           204 | 
           } # validateLibraries
  | 
        
        
            | 
            | 
           205 | 
              | 
        
        
            | 
            | 
           206 | 
              | 
        
        
            | 
            | 
           207 | 
           # check for any required binaries
  | 
        
        
            | 
            | 
           208 | 
           sub validateBinaries {
  | 
        
        
            | 
            | 
           209 | 
              my ( $binaries, $os ) = @_;
  | 
        
        
           | 138 | 
           rodolico | 
           210 | 
              &logIt( 'Entering validateBinaries' );
  | 
        
        
           | 132 | 
           rodolico | 
           211 | 
              my %return;
  | 
        
        
            | 
            | 
           212 | 
              foreach my $bin ( keys %$binaries ) {
  | 
        
        
            | 
            | 
           213 | 
                 unless ( `which $bin` ) {
  | 
        
        
            | 
            | 
           214 | 
                    $return{$bin} = $binaries->{$bin}->{$os} ? $binaries->{$bin}->{$os} : 'UNK';
  | 
        
        
            | 
            | 
           215 | 
                 }
  | 
        
        
            | 
            | 
           216 | 
              }
  | 
        
        
            | 
            | 
           217 | 
              return \%return;
  | 
        
        
            | 
            | 
           218 | 
           } # validateBinaries
  | 
        
        
            | 
            | 
           219 | 
              | 
        
        
            | 
            | 
           220 | 
           # get some input from the user and decide how to install/upgrade/remove/whatever
  | 
        
        
            | 
            | 
           221 | 
           sub getInstallActions {
  | 
        
        
            | 
            | 
           222 | 
              my $install = shift;
  | 
        
        
           | 138 | 
           rodolico | 
           223 | 
              &logIt( 'Entering getInstallActions' );
  | 
        
        
           | 132 | 
           rodolico | 
           224 | 
              if ( -d $install->{'confdir'} ) {
  | 
        
        
            | 
            | 
           225 | 
                 $install->{'action'} = "upgrade";
  | 
        
        
            | 
            | 
           226 | 
              } else {
  | 
        
        
            | 
            | 
           227 | 
                 $install->{'action'} = 'install';
  | 
        
        
            | 
            | 
           228 | 
              }
  | 
        
        
            | 
            | 
           229 | 
              $install->{'build config'} = 'Y';
  | 
        
        
            | 
            | 
           230 | 
              $install->{'setup cron'} = 'Y';
  | 
        
        
           | 101 | 
           rodolico | 
           231 | 
           }
  | 
        
        
            | 
            | 
           232 | 
              | 
        
        
           | 132 | 
           rodolico | 
           233 | 
           # locate all items in $hash which have one of the $placeholder elements in it
  | 
        
        
            | 
            | 
           234 | 
           # and replace, ie <binddir> is replaced with the actual binary directory
  | 
        
        
            | 
            | 
           235 | 
           sub doPlaceholderSubstitution {
  | 
        
        
            | 
            | 
           236 | 
              my ($hash, $placeholder) = @_;
  | 
        
        
           | 138 | 
           rodolico | 
           237 | 
              &logIt( 'Entering doPlaceholderSubstitution' );
  | 
        
        
           | 132 | 
           rodolico | 
           238 | 
              return if ref $hash ne 'HASH';
  | 
        
        
            | 
            | 
           239 | 
              foreach my $key ( keys %$hash ) {
  | 
        
        
            | 
            | 
           240 | 
                 if ( ref( $$hash{$key} ) ) {
  | 
        
        
            | 
            | 
           241 | 
                    &doPlaceholderSubstitution( $$hash{$key}, $placeholder );
  | 
        
        
            | 
            | 
           242 | 
                 } else {
  | 
        
        
            | 
            | 
           243 | 
                    foreach my $place ( keys %$placeholder ) {
  | 
        
        
            | 
            | 
           244 | 
                       $$hash{$key} =~ s/$place/$$placeholder{$place}/;
  | 
        
        
            | 
            | 
           245 | 
                    } # foreach
  | 
        
        
            | 
            | 
           246 | 
                 } # if..else
  | 
        
        
            | 
            | 
           247 | 
              } # foreach
  | 
        
        
            | 
            | 
           248 | 
              return;
  | 
        
        
            | 
            | 
           249 | 
           }
  | 
        
        
            | 
            | 
           250 | 
              | 
        
        
            | 
            | 
           251 | 
           # This will go through and first, see if anything is a directory, in
  | 
        
        
            | 
            | 
           252 | 
           # which case, we'll create new entries for all files in there.
  | 
        
        
            | 
            | 
           253 | 
           # then, it will do keyword substitution of <bindir> and <confdir>
  | 
        
        
            | 
            | 
           254 | 
           # to populate the target.
  | 
        
        
            | 
            | 
           255 | 
           # When this is done, each file should have a source and target that is
  | 
        
        
            | 
            | 
           256 | 
           # a fully qualified path and filename
  | 
        
        
            | 
            | 
           257 | 
           sub populateSourceDir {
  | 
        
        
            | 
            | 
           258 | 
              my ( $install, $sourceDir ) = @_;
  | 
        
        
           | 138 | 
           rodolico | 
           259 | 
              &logIt( 'Entering populateSourceDir' );
  | 
        
        
           | 132 | 
           rodolico | 
           260 | 
              my %placeHolders = 
  | 
        
        
            | 
            | 
           261 | 
                 ( 
  | 
        
        
            | 
            | 
           262 | 
                   '<bindir>' => $$install{'bindir'},
  | 
        
        
            | 
            | 
           263 | 
                   '<confdir>' => $$install{'confdir'},
  | 
        
        
            | 
            | 
           264 | 
                   '<default owner>' => $$install{'default owner'},
  | 
        
        
            | 
            | 
           265 | 
                   '<default group>' => $$install{'default group'},
  | 
        
        
            | 
            | 
           266 | 
                   '<default permission>' => $$install{'default permission'},
  | 
        
        
            | 
            | 
           267 | 
                   '<installdir>' => $sourceDir
  | 
        
        
            | 
            | 
           268 | 
                 );
  | 
        
        
           | 101 | 
           rodolico | 
           269 | 
              | 
        
        
           | 132 | 
           rodolico | 
           270 | 
              my $allFiles = $$install{'files'};
  | 
        
        
           | 101 | 
           rodolico | 
           271 | 
              | 
        
        
           | 132 | 
           rodolico | 
           272 | 
              # find all directory entries and load files in that directory into $$install{'files'}
  | 
        
        
            | 
            | 
           273 | 
              foreach my $dir ( keys %$allFiles ) {
  | 
        
        
            | 
            | 
           274 | 
                 if ( defined( $$allFiles{$dir}{'type'} ) && $$allFiles{$dir}{'type'} eq 'directory' ) {
  | 
        
        
           | 138 | 
           rodolico | 
           275 | 
                    &logIt( "Found directory $dir" );
  | 
        
        
           | 132 | 
           rodolico | 
           276 | 
                    if ( opendir( my $dh, "$sourceDir/$dir" ) ) {
  | 
        
        
            | 
            | 
           277 | 
                       my @files = map{ $dir . '/' . $_ } grep { ! /^\./ && -f "$sourceDir/$dir/$_" } readdir( $dh );
  | 
        
        
           | 138 | 
           rodolico | 
           278 | 
                       &logIt( "\tFound files " . join( ' ', @files ) );
  | 
        
        
           | 132 | 
           rodolico | 
           279 | 
                       foreach my $file ( @files ) {
  | 
        
        
            | 
            | 
           280 | 
                          $$allFiles{ $file }{'type'} = 'file';
  | 
        
        
            | 
            | 
           281 | 
                          if ( $dir eq 'modules' ) {
  | 
        
        
            | 
            | 
           282 | 
                             $$allFiles{ $file }{'permission'} = ( $file =~ m/$$install{'modules'}/ ) ? '0700' : '0600';
  | 
        
        
            | 
            | 
           283 | 
                          } else {
  | 
        
        
            | 
            | 
           284 | 
                             $$allFiles{ $file }{'permission'} = $$allFiles{ $dir }{'permission'};
  | 
        
        
            | 
            | 
           285 | 
                          }
  | 
        
        
            | 
            | 
           286 | 
                          $$allFiles{ $file }{'owner'} = $$allFiles{ $dir }{'owner'};
  | 
        
        
            | 
            | 
           287 | 
                          $$allFiles{ $file }{'target'} = $$allFiles{ $dir }{'target'};
  | 
        
        
            | 
            | 
           288 | 
                       } # foreach
  | 
        
        
            | 
            | 
           289 | 
                       closedir $dh;
  | 
        
        
            | 
            | 
           290 | 
                    } # if opendir
  | 
        
        
            | 
            | 
           291 | 
                 } # if it is a directory
  | 
        
        
            | 
            | 
           292 | 
              } # foreach
  | 
        
        
            | 
            | 
           293 | 
              # find all files, and set the source directory, and add the filename to
  | 
        
        
            | 
            | 
           294 | 
              # the target
  | 
        
        
            | 
            | 
           295 | 
              foreach my $file ( keys %$allFiles ) {
  | 
        
        
            | 
            | 
           296 | 
                 $$allFiles{$file}{'source'} = "$sourceDir/$file";
  | 
        
        
            | 
            | 
           297 | 
                 $$allFiles{$file}{'target'} .= "/$file";
  | 
        
        
            | 
            | 
           298 | 
              } # foreach
  | 
        
        
           | 101 | 
           rodolico | 
           299 | 
              | 
        
        
           | 132 | 
           rodolico | 
           300 | 
              # finally, do place holder substitution. This recursively replaces all keys
  | 
        
        
            | 
            | 
           301 | 
              # in  %placeHolders with the values.
  | 
        
        
            | 
            | 
           302 | 
              &doPlaceholderSubstitution( $install, \%placeHolders );
  | 
        
        
           | 101 | 
           rodolico | 
           303 | 
              | 
        
        
           | 144 | 
           rodolico | 
           304 | 
              &logIt( "Exiting populateSourceDir with values\n" . Dumper( $install ) ) ;
  | 
        
        
           | 101 | 
           rodolico | 
           305 | 
              | 
        
        
           | 132 | 
           rodolico | 
           306 | 
              return 1;
  | 
        
        
            | 
            | 
           307 | 
           } # populateSourceDir
  | 
        
        
            | 
            | 
           308 | 
              | 
        
        
            | 
            | 
           309 | 
           sub GetPermission {
  | 
        
        
            | 
            | 
           310 | 
              my $install = shift;
  | 
        
        
           | 138 | 
           rodolico | 
           311 | 
              &logIt( 'Entering GetPermission' );
  | 
        
        
           | 132 | 
           rodolico | 
           312 | 
              print "Ready to install, please verify the following\n";
  | 
        
        
            | 
            | 
           313 | 
              print "A. Operating System:  " . $install->{'os'} . "\n";
  | 
        
        
            | 
            | 
           314 | 
              print "B. Installation Type: " . $install->{'action'} . "\n";
  | 
        
        
            | 
            | 
           315 | 
              print "C. Using Seed file: " . $install->{'configuration seed file'} . "\n" if -e $install->{'configuration seed file'};
  | 
        
        
            | 
            | 
           316 | 
              print "D. Target Binary Directory: " . $install->{'bindir'} . "\n";
  | 
        
        
            | 
            | 
           317 | 
              print "E. Target Configuration Directory: " . $install->{'confdir'} . "\n";
  | 
        
        
            | 
            | 
           318 | 
              print "F. Automatic Running: " . ( $install->{'crontab'} ? $install->{'crontab'} : 'No' ) . "\n";
  | 
        
        
            | 
            | 
           319 | 
              print "G. Install Missing Perl Libraries\n";
  | 
        
        
            | 
            | 
           320 | 
              foreach my $task ( sort keys %{ $install->{'missing libraries'} } ) {
  | 
        
        
           | 144 | 
           rodolico | 
           321 | 
                 print "\t$task -> " . $install->{'missing libraries'}->{$task}->{'command'} . ' ' . $install->{'missing libraries'}->{$task}->{'parameter'} . "\n";
  | 
        
        
           | 101 | 
           rodolico | 
           322 | 
              }
  | 
        
        
           | 132 | 
           rodolico | 
           323 | 
              print "H. Install Missing Binaries\n";
  | 
        
        
            | 
            | 
           324 | 
              foreach my $task ( sort keys %{ $install->{'missing binaries'} } ) {
  | 
        
        
           | 144 | 
           rodolico | 
           325 | 
                 print "\t$task -> " . $install->{'missing binaries'}->{$task}->{'command'} . ' ' . $install->{'missing binaries'}->{$task}->{'parameter'} . "\n";
  | 
        
        
           | 132 | 
           rodolico | 
           326 | 
              }
  | 
        
        
            | 
            | 
           327 | 
              return &yesno( "Do you want to proceed?" );
  | 
        
        
           | 101 | 
           rodolico | 
           328 | 
           }
  | 
        
        
            | 
            | 
           329 | 
              | 
        
        
           | 132 | 
           rodolico | 
           330 | 
           # note, this fails badly if you stick non-numerics in the version number
  | 
        
        
            | 
            | 
           331 | 
           # simply create a "number" from the version which may have an arbitrary
  | 
        
        
            | 
            | 
           332 | 
           # number of digits separated by a period, for example
  | 
        
        
            | 
            | 
           333 | 
           # 1.2.5
  | 
        
        
            | 
            | 
           334 | 
           # while there are digits, divide current calculation by 100, then add the last
  | 
        
        
            | 
            | 
           335 | 
           # digit popped of. So, 1.2.5 would become
  | 
        
        
            | 
            | 
           336 | 
           # 1 + 2/100 + 5/10000, or 1.0205
  | 
        
        
            | 
            | 
           337 | 
           # and 1.25.16 would become 1.2516
  | 
        
        
            | 
            | 
           338 | 
           # 
  | 
        
        
            | 
            | 
           339 | 
           # Will give invalid results if any set of digits is more than 99
  | 
        
        
            | 
            | 
           340 | 
           sub dotVersion2Number {
  | 
        
        
            | 
            | 
           341 | 
              my $dotVersion = shift;
  | 
        
        
            | 
            | 
           342 | 
              | 
        
        
            | 
            | 
           343 | 
              my @t = split( '\.', $dotVersion );
  | 
        
        
            | 
            | 
           344 | 
              #print "\n$dotVersion\n" . join( "\n", @t ) . "\n";
  | 
        
        
            | 
            | 
           345 | 
              my $return = 0;
  | 
        
        
            | 
            | 
           346 | 
              while ( @t ) {
  | 
        
        
            | 
            | 
           347 | 
                 $return /= 100;
  | 
        
        
            | 
            | 
           348 | 
                 $return += pop @t;
  | 
        
        
            | 
            | 
           349 | 
              }
  | 
        
        
            | 
            | 
           350 | 
              #print "$return\n";
  | 
        
        
            | 
            | 
           351 | 
              return $return;
  | 
        
        
            | 
            | 
           352 | 
           }
  | 
        
        
            | 
            | 
           353 | 
              | 
        
        
            | 
            | 
           354 | 
           # there is a file named VERSIONS. We get the values out of the install
  | 
        
        
            | 
            | 
           355 | 
           # directory and (if it exists) the target so we can decide what needs
  | 
        
        
            | 
            | 
           356 | 
           # to be updated.
  | 
        
        
            | 
            | 
           357 | 
           sub getVersions {
  | 
        
        
            | 
            | 
           358 | 
              my $install = shift;
  | 
        
        
           | 138 | 
           rodolico | 
           359 | 
              &logIt( 'Entering getVersions' );
  | 
        
        
           | 132 | 
           rodolico | 
           360 | 
              my $currentVersionFile = $install->{'files'}->{'VERSION'}->{'target'};
  | 
        
        
            | 
            | 
           361 | 
              my $newVersionFile = $install->{'files'}->{'VERSION'}->{'source'};
  | 
        
        
            | 
            | 
           362 | 
              if ( open FILE,"<$currentVersionFile" ) {
  | 
        
        
            | 
            | 
           363 | 
                 while ( my $line = <FILE> ) {
  | 
        
        
            | 
            | 
           364 | 
                    chomp $line;
  | 
        
        
            | 
            | 
           365 | 
                    my ( $filename, $version, $checksum ) = split( "\t", $line );
  | 
        
        
            | 
            | 
           366 | 
                    $install{'files'}->{$filename}->{'installed version'} = $version ? $version : '';
  | 
        
        
           | 156 | 
           rodolico | 
           367 | 
                    $install{'files'}->{$filename}->{'installed checksum'} = $checksum ? $checksum : '';
  | 
        
        
           | 132 | 
           rodolico | 
           368 | 
                 }
  | 
        
        
            | 
            | 
           369 | 
                 close FILE;
  | 
        
        
            | 
            | 
           370 | 
              }
  | 
        
        
            | 
            | 
           371 | 
              if ( open FILE,"<$newVersionFile" ) {
  | 
        
        
            | 
            | 
           372 | 
                 while ( my $line = <FILE> ) {
  | 
        
        
            | 
            | 
           373 | 
                    chomp $line;
  | 
        
        
            | 
            | 
           374 | 
                    my ( $filename, $version, $checksum ) = split( "\t", $line );
  | 
        
        
            | 
            | 
           375 | 
                    $install->{'files'}->{$filename}->{'new version'} = $version ? $version : '';
  | 
        
        
           | 156 | 
           rodolico | 
           376 | 
                    $install->{'files'}->{$filename}->{'new checksum'} = $checksum ? $checksum : '';
  | 
        
        
           | 132 | 
           rodolico | 
           377 | 
                 }
  | 
        
        
            | 
            | 
           378 | 
                 close FILE;
  | 
        
        
            | 
            | 
           379 | 
              }
  | 
        
        
            | 
            | 
           380 | 
              foreach my $file ( keys %{$$install{'files'}} ) {
  | 
        
        
           | 156 | 
           rodolico | 
           381 | 
                 $install{'files'}->{$file}->{'installed version'} = '' unless defined $install->{'files'}->{$file}->{'installed version'};
  | 
        
        
            | 
            | 
           382 | 
                 $install{'files'}->{$file}->{'new version'} = '' unless defined $install->{'files'}->{$file}->{'new version'};
  | 
        
        
           | 132 | 
           rodolico | 
           383 | 
              }
  | 
        
        
            | 
            | 
           384 | 
              return 1;
  | 
        
        
            | 
            | 
           385 | 
           } # getVersions
  | 
        
        
            | 
            | 
           386 | 
              | 
        
        
           | 144 | 
           rodolico | 
           387 | 
           # checks if a directory exists and, if not, creates it
  | 
        
        
            | 
            | 
           388 | 
           my %directories; # holds list of directories already created so no need to do an I/O
  | 
        
        
           | 132 | 
           rodolico | 
           389 | 
              | 
        
        
           | 144 | 
           rodolico | 
           390 | 
           sub checkDirectoryExists {
  | 
        
        
            | 
            | 
           391 | 
              my ( $filename,$mod,$owner ) = @_;
  | 
        
        
            | 
            | 
           392 | 
              $mod = "0700" unless $mod;
  | 
        
        
            | 
            | 
           393 | 
              $owner = "root:root" unless $owner;
  | 
        
        
            | 
            | 
           394 | 
              &logIt( "Checking Directory for $filename with $mod and $owner" );
  | 
        
        
            | 
            | 
           395 | 
              my ($fn, $dirname) = fileparse( $filename );
  | 
        
        
            | 
            | 
           396 | 
              logIt( "\tParsing out $dirname and $filename" );
  | 
        
        
            | 
            | 
           397 | 
              return '' if exists $directories{$dirname};
  | 
        
        
            | 
            | 
           398 | 
              if ( -d $dirname ) {
  | 
        
        
            | 
            | 
           399 | 
                 $directories{$dirname} = 1;
  | 
        
        
            | 
            | 
           400 | 
                 return '';
  | 
        
        
            | 
            | 
           401 | 
              }
  | 
        
        
            | 
            | 
           402 | 
              if ( &runCommand( "mkdir -p $dirname", "chmod $mod $dirname", "chown $owner $dirname" ) ) {
  | 
        
        
            | 
            | 
           403 | 
                 $directories{$dirname} = 1;
  | 
        
        
            | 
            | 
           404 | 
              }
  | 
        
        
            | 
            | 
           405 | 
              return '';   
  | 
        
        
            | 
            | 
           406 | 
           }
  | 
        
        
            | 
            | 
           407 | 
              | 
        
        
            | 
            | 
           408 | 
           # runs a system command. Also, if in testing mode, simply shows what
  | 
        
        
            | 
            | 
           409 | 
           # would have been done.
  | 
        
        
            | 
            | 
           410 | 
           sub runCommand {
  | 
        
        
            | 
            | 
           411 | 
              while ( my $command = shift ) {
  | 
        
        
            | 
            | 
           412 | 
                 if ( $dryRun ) {
  | 
        
        
            | 
            | 
           413 | 
                    print "$command\n";
  | 
        
        
            | 
            | 
           414 | 
                 } else {
  | 
        
        
            | 
            | 
           415 | 
                    `$command`;
  | 
        
        
            | 
            | 
           416 | 
                 }
  | 
        
        
            | 
            | 
           417 | 
              }
  | 
        
        
            | 
            | 
           418 | 
              return 1;
  | 
        
        
            | 
            | 
           419 | 
           } # runCommand
  | 
        
        
            | 
            | 
           420 | 
              | 
        
        
           | 132 | 
           rodolico | 
           421 | 
           # this actually does the installation, except for the configuration
  | 
        
        
            | 
            | 
           422 | 
           sub doInstall {
  | 
        
        
            | 
            | 
           423 | 
              my $install = shift;
  | 
        
        
           | 138 | 
           rodolico | 
           424 | 
              &logIt( 'Entering doInstall' );
  | 
        
        
           | 132 | 
           rodolico | 
           425 | 
              my $fileList = $install->{'files'};
  | 
        
        
            | 
            | 
           426 | 
              | 
        
        
            | 
            | 
           427 | 
              &checkDirectoryExists( $install->{'bindir'} . '/', $install->{'default permission'}, $install->{'default owner'} . ':' . $install->{'default group'} );
  | 
        
        
            | 
            | 
           428 | 
              foreach my $file ( keys %$fileList ) {
  | 
        
        
            | 
            | 
           429 | 
                 next unless ( $fileList->{$file}->{'type'} && $fileList->{$file}->{'type'} eq 'file' );
  | 
        
        
            | 
            | 
           430 | 
              | 
        
        
           | 156 | 
           rodolico | 
           431 | 
           #   *********** Removed error checking to get this working; should reenable later
  | 
        
        
            | 
            | 
           432 | 
           #      if ( version->parse( $fileList->{$file}->{'installed version'} ) && version->parse( $fileList->{$file}->{'installed version'} ) < version->parse( $fileList->{$file}->{'new version'} ) ) {
  | 
        
        
            | 
            | 
           433 | 
           #         # we have a new version, so overwrite it
  | 
        
        
            | 
            | 
           434 | 
           #      } elsif ( $fileList->{$file}->{'installed checksum'} eq $fileList->{$file}->{'installed checksum'} ) { # has file been modified
  | 
        
        
            | 
            | 
           435 | 
           #      }
  | 
        
        
            | 
            | 
           436 | 
           #         
  | 
        
        
            | 
            | 
           437 | 
           #
  | 
        
        
            | 
            | 
           438 | 
           #      next if $install->{'action'} eq 'upgrade' && ! defined( $fileList->{$file}->{'installed version'} )
  | 
        
        
            | 
            | 
           439 | 
           #              ||
  | 
        
        
            | 
            | 
           440 | 
           #              ( &dotVersion2Number( $fileList->{$file}->{'new version'} ) <= &dotVersion2Number($fileList->{$file}->{'installed version'} ) );
  | 
        
        
            | 
            | 
           441 | 
              | 
        
        
           | 132 | 
           rodolico | 
           442 | 
                 &checkDirectoryExists( $fileList->{$file}->{'target'}, $install->{'default permission'}, $install->{'default owner'} . ':' . $install->{'default group'} );
  | 
        
        
            | 
            | 
           443 | 
                 &runCommand( 
  | 
        
        
            | 
            | 
           444 | 
                       "cp $fileList->{$file}->{'source'} $fileList->{$file}->{'target'}",
  | 
        
        
            | 
            | 
           445 | 
                       "chmod $fileList->{$file}->{'permission'} $fileList->{$file}->{'target'}",
  | 
        
        
            | 
            | 
           446 | 
                       "chown $fileList->{$file}->{'owner'} $fileList->{$file}->{'target'}"
  | 
        
        
            | 
            | 
           447 | 
                       );
  | 
        
        
            | 
            | 
           448 | 
                 # if there is a post action, run it and store any return in @feedback
  | 
        
        
            | 
            | 
           449 | 
                 push @feedback, `$fileList->{$file}->{'post action'}` if defined $fileList->{$file}->{'post action'};
  | 
        
        
            | 
            | 
           450 | 
                 # if there is a message to be passed, store it in @messages
  | 
        
        
           | 156 | 
           rodolico | 
           451 | 
                 push @messages, $fileList->{$file}->{'message'} if defined $fileList->{$file}->{'message'};
  | 
        
        
           | 132 | 
           rodolico | 
           452 | 
              } # foreach file
  | 
        
        
            | 
            | 
           453 | 
              # set up crontab, if necessary
  | 
        
        
            | 
            | 
           454 | 
              &runCommand( $install->{'crontab'} ) if defined ( $install->{'crontab'} );
  | 
        
        
            | 
            | 
           455 | 
              return 1;
  | 
        
        
            | 
            | 
           456 | 
           }
  | 
        
        
            | 
            | 
           457 | 
              | 
        
        
            | 
            | 
           458 | 
              | 
        
        
            | 
            | 
           459 | 
           # installs binaries and libraries
  | 
        
        
            | 
            | 
           460 | 
           sub installOSStuff {
  | 
        
        
            | 
            | 
           461 | 
              my $install = shift;
  | 
        
        
           | 144 | 
           rodolico | 
           462 | 
              my %commands;
  | 
        
        
           | 132 | 
           rodolico | 
           463 | 
              my @actions = values( %{ $install->{'missing libraries'} } );
  | 
        
        
            | 
            | 
           464 | 
              push @actions, values( %{ $install->{'missing binaries'} } );
  | 
        
        
            | 
            | 
           465 | 
              foreach my $action ( @actions ) {
  | 
        
        
           | 144 | 
           rodolico | 
           466 | 
                 $commands{$action->{'command'}} .= ' ' . $action->{'parameter'};
  | 
        
        
            | 
            | 
           467 | 
                 #&logIt( $action );
  | 
        
        
            | 
            | 
           468 | 
                 #&runCommand( $action );
  | 
        
        
           | 132 | 
           rodolico | 
           469 | 
              }
  | 
        
        
           | 144 | 
           rodolico | 
           470 | 
              foreach my $command ( keys %commands ) {
  | 
        
        
            | 
            | 
           471 | 
                 print "Running command $command $commands{$command}\n";
  | 
        
        
            | 
            | 
           472 | 
                 `$command $commands{$command}`;
  | 
        
        
            | 
            | 
           473 | 
              }
  | 
        
        
           | 132 | 
           rodolico | 
           474 | 
           }
  | 
        
        
           | 144 | 
           rodolico | 
           475 | 
              | 
        
        
            | 
            | 
           476 | 
           ################################################################
  | 
        
        
            | 
            | 
           477 | 
           # validateCPAN
  | 
        
        
            | 
            | 
           478 | 
           #
  | 
        
        
            | 
            | 
           479 | 
           # some of the systems will need to run cpan to get some perl modules.
  | 
        
        
            | 
            | 
           480 | 
           # this will go through each of them and see if command starts with cpan
  | 
        
        
            | 
            | 
           481 | 
           # and, if so, will check that cpan is installed and configured for root.
  | 
        
        
            | 
            | 
           482 | 
           #
  | 
        
        
            | 
            | 
           483 | 
           # when cpan is installed, it requires one manual run as root from the cli
  | 
        
        
            | 
            | 
           484 | 
           # to determine where to get the files. If that is not done, cpan can not
  | 
        
        
            | 
            | 
           485 | 
           # be controlled by a program. We check to see if cpan is installed, then
  | 
        
        
            | 
            | 
           486 | 
           # verify /root/.cpan has been created by the configuration tool
  | 
        
        
            | 
            | 
           487 | 
           ################################################################
  | 
        
        
            | 
            | 
           488 | 
              | 
        
        
            | 
            | 
           489 | 
              | 
        
        
            | 
            | 
           490 | 
           sub validateCPAN {
  | 
        
        
            | 
            | 
           491 | 
              my $libraries = shift;
  | 
        
        
            | 
            | 
           492 | 
              my $needCPAN = 0;
  | 
        
        
            | 
            | 
           493 | 
              foreach my $app ( keys %$libraries ) {
  | 
        
        
            | 
            | 
           494 | 
                 if ( $libraries->{$app}->{'command'} =~ m/^cpan/ ) {
  | 
        
        
            | 
            | 
           495 | 
                    $needCPAN = 1;
  | 
        
        
            | 
            | 
           496 | 
                    last;
  | 
        
        
            | 
            | 
           497 | 
                 }
  | 
        
        
            | 
            | 
           498 | 
              }
  | 
        
        
            | 
            | 
           499 | 
              return unless $needCPAN;
  | 
        
        
            | 
            | 
           500 | 
              if ( `which cpan` ) {
  | 
        
        
            | 
            | 
           501 | 
                 die "****ERROR****\nWe need cpan, and it is installed, but not configured\nrun cpan as root one time to configure it\n" unless -d '/root/.cpan';
  | 
        
        
            | 
            | 
           502 | 
              } else {
  | 
        
        
            | 
            | 
           503 | 
                 die 'In order to install on this OS, we need cpan, which should have been installed with perl.' .
  | 
        
        
            | 
            | 
           504 | 
                     " Can not continue until cpan is installed and configured\n";
  | 
        
        
            | 
            | 
           505 | 
              }
  | 
        
        
            | 
            | 
           506 | 
           }   
  | 
        
        
           | 132 | 
           rodolico | 
           507 | 
              | 
        
        
            | 
            | 
           508 | 
              | 
        
        
            | 
            | 
           509 | 
           ################################################################
  | 
        
        
            | 
            | 
           510 | 
           #               Main Code                                      #
  | 
        
        
            | 
            | 
           511 | 
           ################################################################
  | 
        
        
            | 
            | 
           512 | 
              | 
        
        
            | 
            | 
           513 | 
           # handle any command line parameters that may have been passed in
  | 
        
        
            | 
            | 
           514 | 
              | 
        
        
            | 
            | 
           515 | 
           GetOptions (
  | 
        
        
            | 
            | 
           516 | 
                       "os|o=s"      => \$os,      # pass in the operating system
  | 
        
        
            | 
            | 
           517 | 
                       "dryrun|n"    => \$dryRun,  # do NOT actually do anything
  | 
        
        
            | 
            | 
           518 | 
                       'help|h'      => \$help,
  | 
        
        
           | 206 | 
           rodolico | 
           519 | 
                       'version|v'   => \$version,
  | 
        
        
            | 
            | 
           520 | 
                       'quiet|q'     => \$quiet,
  | 
        
        
            | 
            | 
           521 | 
                       'inplace|i'   => \$inplace
  | 
        
        
           | 132 | 
           rodolico | 
           522 | 
                       ) or die "Error parsing command line\n";
  | 
        
        
            | 
            | 
           523 | 
              | 
        
        
            | 
            | 
           524 | 
           if ( $help ) { &help() ; exit; }
  | 
        
        
           | 156 | 
           rodolico | 
           525 | 
           if ( $version ) { use File::Basename; print basename($0) . " $VERSION\n"; exit; }
  | 
        
        
           | 132 | 
           rodolico | 
           526 | 
              | 
        
        
           | 156 | 
           rodolico | 
           527 | 
           print "Logging to $logFile\n";
  | 
        
        
            | 
            | 
           528 | 
              | 
        
        
           | 138 | 
           rodolico | 
           529 | 
           &logIt( 'Beginning installation' );
  | 
        
        
            | 
            | 
           530 | 
              | 
        
        
           | 132 | 
           rodolico | 
           531 | 
           $install{'os'} = &setUpOperatingSystemSpecific( \%install, \%operatingSystems, $os ? $os : `$sourceDir/determineOS`, $sourceDir );
  | 
        
        
           | 138 | 
           rodolico | 
           532 | 
           &logIt( "Operating System is $install{'os'}" );
  | 
        
        
            | 
            | 
           533 | 
              | 
        
        
           | 132 | 
           rodolico | 
           534 | 
           $install{'missing libraries'} = &validateLibraries( \%libraries, $install{'os'} );
  | 
        
        
           | 144 | 
           rodolico | 
           535 | 
           &logIt( "Missing Libraries\n" . Dumper( $install{'missing libraries'} ) );
  | 
        
        
           | 138 | 
           rodolico | 
           536 | 
              | 
        
        
           | 132 | 
           rodolico | 
           537 | 
           $install{'missing binaries'} = &validateBinaries( \%binaries, $install{'os'} );
  | 
        
        
           | 144 | 
           rodolico | 
           538 | 
           &logIt( "Missing binaries\n" . Dumper( $install{'missing binaries'} ) );
  | 
        
        
           | 138 | 
           rodolico | 
           539 | 
              | 
        
        
           | 144 | 
           rodolico | 
           540 | 
           if ( $install{'missing libraries'} ) {
  | 
        
        
            | 
            | 
           541 | 
              &validateCPAN( $install{'missing libraries'} );
  | 
        
        
            | 
            | 
           542 | 
           }
  | 
        
        
            | 
            | 
           543 | 
              | 
        
        
           | 132 | 
           rodolico | 
           544 | 
           &getInstallActions( \%install );
  | 
        
        
           | 144 | 
           rodolico | 
           545 | 
           &logIt( "Completed getInstallActions\n" .  Dumper( \%install ) );
  | 
        
        
           | 138 | 
           rodolico | 
           546 | 
              | 
        
        
           | 206 | 
           rodolico | 
           547 | 
           # put source files where they need to be unless we're doing inplace upgrade
  | 
        
        
            | 
            | 
           548 | 
           &populateSourceDir( \%install, $sourceDir ) unless $inplace;
  | 
        
        
           | 132 | 
           rodolico | 
           549 | 
              | 
        
        
           | 206 | 
           rodolico | 
           550 | 
           if ( $quiet || &GetPermission( \%install ) ) {
  | 
        
        
           | 132 | 
           rodolico | 
           551 | 
              &installOSStuff( \%install );
  | 
        
        
           | 207 | 
           rodolico | 
           552 | 
              &getVersions( \%install ) unless $install{'action'} eq 'new' unless $inplace;
  | 
        
        
            | 
            | 
           553 | 
              &doInstall( \%install ) unless $inplace;
  | 
        
        
           | 132 | 
           rodolico | 
           554 | 
           } else {
  | 
        
        
            | 
            | 
           555 | 
              die "Please fix whatever needs to be done and try again\n";
  | 
        
        
           | 138 | 
           rodolico | 
           556 | 
              &logIt( "User chose to kill process" );
  | 
        
        
           | 132 | 
           rodolico | 
           557 | 
           }
  | 
        
        
            | 
            | 
           558 | 
              | 
        
        
           | 144 | 
           rodolico | 
           559 | 
           &logIt( "Installation done, running \&postInstall if it exists" );
  | 
        
        
           | 132 | 
           rodolico | 
           560 | 
              | 
        
        
           | 206 | 
           rodolico | 
           561 | 
           &postInstall( \%install, $quiet ) if defined( &postInstall );
  | 
        
        
           | 144 | 
           rodolico | 
           562 | 
              | 
        
        
            | 
            | 
           563 | 
           1;
  |