Subversion Repositories camp_sysinfo_client_3

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
33 rodolico 1
#! /usr/bin/env perl
2
 
3
use strict;
4
use warnings;
5
 
42 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
#
50 rodolico 15
# version 1.2 20170327 RWR
16
# did some major modifications to correctly work on BSD systems also
94 rodolico 17
#
18
# version 2.0 20190330 RWR
19
# changed it so all configs are YAML
33 rodolico 20
 
94 rodolico 21
our $VERSION = '2.0';
42 rodolico 22
 
33 rodolico 23
# find our location and use it for searching for libraries
24
BEGIN {
25
   use FindBin;
26
   use File::Spec;
27
   use lib File::Spec->catdir($FindBin::Bin);
28
}
29
 
30
use sysinfoconf;
101 rodolico 31
use YAML::Tiny;
94 rodolico 32
use Data::Dumper;
33 rodolico 33
use File::Basename;
35 rodolico 34
use Getopt::Long;
35
Getopt::Long::Configure ("bundling"); # allow -vd --os='debian'
33 rodolico 36
 
35 rodolico 37
# $verbose can have the following values
33 rodolico 38
# 0 - do everything
39
# 1 - Do everything except the install, display what would be done
40
# 2 - Be verbose to STDERR
41
# 3 - Be very verbose
35 rodolico 42
my $verbose = 0; # if test mode, simply show what would be done
43
my $dryRun = 0;
44
my $os;
45
my $help = 0;
46
my $version = 0;
33 rodolico 47
 
48
my $status; # exit status of the processes
49
my $sourceDir = File::Spec->catdir($FindBin::Bin);
34 rodolico 50
my $installType;
33 rodolico 51
 
57 rodolico 52
 
33 rodolico 53
my %install = (  'bindir' => '/opt/camp/sysinfo-client',
54
                 'confdir' => '/etc/camp/sysinfo-client',
34 rodolico 55
                 'application name' => 'sysinfo client',
50 rodolico 56
                 'default group' => 'root',
57
                 'default owner' => 'root',
58
                 'default permission' => '0700',
35 rodolico 59
                 'configuration' => {
60
                          'configurator' => '<bindir>/configure.pl',
94 rodolico 61
                          'configuration file' => '<confdir>/sysinfo-client.yaml',
62
                          'configuration seed file' => 'sysinfo-client.seed.yaml',
63
                          'old configuration file' => '<confdir>/sysinfo-client.conf',
35 rodolico 64
                          'permission' => '700',
50 rodolico 65
                          'owner'      => '<default owner>',
35 rodolico 66
                          'target'     => '<confdir>'
67
                            },
33 rodolico 68
                 'files' => {
69
                           'configure.pl' => { 
70
                                 'type' => 'file',
71
                                 'permission' => '700', 
50 rodolico 72
                                 'owner' => '<default owner>:<default group>', 
33 rodolico 73
                                 'target' =>  '<bindir>'
74
                              },
75
                           'sysinfo-client' => { 
76
                                 'type' => 'file',
77
                                 'permission' => '700',
50 rodolico 78
                                 'owner' => '<default owner>:<default group>',
33 rodolico 79
                                 'target' =>  '<bindir>'
80
                              },
81
                           'sysinfoconf.pm' => {
82
                                 'type' => 'file',
83
                                 'permission' => '600',
50 rodolico 84
                                 'owner' => '<default owner>:<default group>',
33 rodolico 85
                                 'target' =>  '<bindir>'
86
                              },
87
                           'notes' => { 
88
                                 'type' => 'file',
89
                                 'permission' => '600', 
50 rodolico 90
                                 'owner' => '<default owner>:<default group>', 
33 rodolico 91
                                 'target' =>  '<bindir>'
92
                              },
94 rodolico 93
                           'sysinfo-client.conf.template.yaml' => { 
33 rodolico 94
                                 'type' => 'file',
95
                                 'permission' => '600', 
50 rodolico 96
                                 'owner' => '<default owner>:<default group>', 
33 rodolico 97
                                 'target' =>  '<bindir>' 
98
                              },
99
                           'getSendEmail.pl' => { 
100
                                 'type' => 'file',
101
                                 'permission' => '700', 
50 rodolico 102
                                 'owner' => '<default owner>:<default group>', 
33 rodolico 103
                                 'target' =>  '<bindir>' 
104
                              },
105
                           'install.pl' => {
106
                                 'type' => 'file',
107
                                 'permission' => '700', 
50 rodolico 108
                                 'owner' => '<default owner>:<default group>', 
33 rodolico 109
                                 'target' =>  '<bindir>' 
110
                              },
111
                           'MANIFEST' => {
112
                                 'type' => 'file',
113
                                 'permission' => '600', 
50 rodolico 114
                                 'owner' => '<default owner>:<default group>', 
33 rodolico 115
                                 'target' =>  '<bindir>' 
116
                              },
94 rodolico 117
                           'sysinfo-client.seed.example.yaml' => { 
33 rodolico 118
                                 'type' => 'file',
119
                                 'permission' => '600', 
50 rodolico 120
                                 'owner' => '<default owner>:<default group>', 
33 rodolico 121
                                 'target' =>  '<bindir>' 
122
                              },
123
                           'VERSION' => { 
124
                                 'type' => 'file',
125
                                 'permission' => '600', 
50 rodolico 126
                                 'owner' => '<default owner>:<default group>', 
33 rodolico 127
                                 'target' =>  '<bindir>' 
128
                              },
129
                              'modules' => {
130
                                 'type' => 'directory',
131
                                 'permission' => '700', 
50 rodolico 132
                                 'owner' => '<default owner>:<default group>', 
33 rodolico 133
                                 'target' =>  '<bindir>',
134
                                 'action' => 'chmod 700 *'
135
                              },
136
                              'scripts' => {
137
                                 'type' => 'directory',
138
                                 'permission' => '700', 
50 rodolico 139
                                 'owner' => '<default owner>:<default group>', 
33 rodolico 140
                                 'target' =>  '<bindir>',
141
                                 'action' => 'chmod 700 *'
142
                              },
143
                     }
144
                  );
145
 
146
# hash to set up os specific rules                  
147
my %operatingSystems = (
148
                  'debian' => {
76 rodolico 149
                     'regex'  => '(debian|mx|devuan)',
33 rodolico 150
                     'bindir' => '/opt/camp/sysinfo-client',
151
                     'confdir' => '/etc/camp/sysinfo-client',
35 rodolico 152
                     'crontab' => 'ln -s <bindir>/sysinfo-client /etc/cron.daily/sysinfo-client',
57 rodolico 153
                     'modules' => '((linux)|(dpkg)|(unix)|(all))',
33 rodolico 154
                  },
155
                  'ipfire' => {
60 rodolico 156
                     'regex'  => 'ipfire',
33 rodolico 157
                     'bindir' => '/opt/camp/sysinfo-client',
158
                     'confdir' => '/etc/camp/sysinfo-client',
50 rodolico 159
                     'crontab' => 'ln -s <bindir>/sysinfo-client /etc/fcron.daily/sysinfo-client.fcron',
57 rodolico 160
                     'modules' => '((ipfire)|(unix)|(all))',
43 rodolico 161
                  },
162
                  'freebsd' => {
60 rodolico 163
                     'regex' => 'freebsd',
43 rodolico 164
                     'bindir' => '/usr/local/opt/camp/sysinfo-client',
165
                     'confdir' => '/usr/local/etc/camp/sysinfo-client',
50 rodolico 166
                     'crontab' => 'ln -s <bindir>/sysinfo-client /etc/periodic/daily/sysinfo-client',
57 rodolico 167
                     'modules' => '((bsd)|(unix)|(all))',
50 rodolico 168
                    'default group' => 'wheel',
169
                    'default owner' => 'root',
99 rodolico 170
                    'files' => {
171
                              'YAML' => { 
172
                                    'type' => 'directory',
173
                                    'permission' => '777', 
174
                                    'owner' => '<default owner>:<default group>', 
175
                                    'target' =>  '<bindir>'
176
                                 },
177
                              'Tiny.pm' => { 
178
                                    'type' => 'file',
179
                                    'permission' => '444',
180
                                    'owner' => '<default owner>:<default group>',
181
                                    'target' =>  '<bindir>/YAML'
182
                                 },
183
                              },
43 rodolico 184
                  },
94 rodolico 185
                  'opnsense' => {
186
                     'fileexists' => '/conf/config.xml',
187
                     'bindir' => '/usr/local/opt/camp/sysinfo-client',
188
                     'confdir' => '/usr/local/etc/camp/sysinfo-client',
189
                     'crontab' => 'ln -s <bindir>/sysinfo-client /etc/periodic/daily/sysinfo-client',
190
                     'modules' => '((bsd)|(unix)|(all))',
191
                    'default group' => 'wheel',
192
                    'default owner' => 'root',
99 rodolico 193
                    'files' => {
194
                              'YAML' => { 
195
                                    'type' => 'directory',
196
                                    'permission' => '777', 
197
                                    'owner' => '<default owner>:<default group>', 
198
                                    'target' =>  '<bindir>'
199
                                 },
200
                              'Tiny.pm' => { 
201
                                    'type' => 'file',
202
                                    'permission' => '444',
203
                                    'owner' => '<default owner>:<default group>',
204
                                    'target' =>  '<bindir>/YAML'
205
                                 },
206
                              },
94 rodolico 207
                 },
43 rodolico 208
 
209
                );
42 rodolico 210
 
81 rodolico 211
my %configuration;
212
 
42 rodolico 213
# list of libraries used by the system. We will offer to install them if
214
# we know how. NOTE: I have chosen to put the full installation command
215
# for each library. This allows us to use the package selector OR a different
216
# piece of code on a per-library basis, but results in something like
217
#      apt-get -y install perl-modules
218
#      apt-get -y install libwww-perl
219
# instead of
220
#      apt-get -y install libwww-perl perl-modules
221
# flexibility vs efficiency in this case.
222
my %libraries = ( 
223
                  'File::Basename' => { 'debian' => 'apt-get -y install perl-modules' },
224
                  'Exporter' => { 'debian' => 'apt-get -y install perl-base' },
50 rodolico 225
                  'LWP' => { 
226
                             'debian' => 'apt-get -y install libwww-perl',
55 rodolico 227
                             'freebsd' => 'pkg install -y p5-libwww'
50 rodolico 228
                           },
42 rodolico 229
                );
230
 
43 rodolico 231
# utilities md5sum
232
# freebsd isomd5sum
233
 
42 rodolico 234
# validates the libraries needed exist
235
# simply eval's each library. If it doesn't exist, creates a list of
236
# commands to be executed to install it, and displays missing libraries
237
# offering to install them if possible.
238
sub validateLibraries {
239
   my ( $libraries, $os ) = @_;
240
   my @command;
241
   my @missingLibs;
242
   foreach my $lib ( keys %$libraries ) {
98 rodolico 243
      print "Checking on libarary $lib\n";
42 rodolico 244
      eval( "use $lib;" );
245
      if ( $@ ) {
98 rodolico 246
         print "\tNot found, adding\n";
42 rodolico 247
         push @command,$$libraries{$lib}{$os} if $$libraries{$lib}{$os};
248
         push @missingLibs, $lib;
249
      }
250
   }
251
   if ( @missingLibs ) { # we have missing libraries
252
      if ( @command ) {
253
         &runCommand( join( "\n", @command ) )
254
            if &yesno(
255
                        'Following libraries need to be installed: ' . 
256
                        join( ' ', @missingLibs ) . "\n" .
257
                        "I can install them with the following command(s)\n" . 
258
                        join( "\n", @command ) . "\nDo you want me to do this?\n"
259
                     );
260
      } else {
261
         die unless &yesno( 'Following libraries need to be installed: ' . 
262
                            join( ' ', @missingLibs ) . 
263
                            "\nand I don't know how to do this. Abort?" );
264
      }
265
   } # if
266
} # validateLibraries
33 rodolico 267
 
94 rodolico 268
 
114 rodolico 269
 
270
 
33 rodolico 271
# attempt to locate the operating system.
272
# if found, will set some defaults for it.
94 rodolico 273
sub setUpOperatingSystemSpecific {
35 rodolico 274
   my ( $install, $operatingSystems, $os ) = @_;
107 rodolico 275
   print "They passed $os in as the \$os\n" if $verbose > 2;
35 rodolico 276
   if ( $os ) {
94 rodolico 277
      # We found the OS, set up some defaults
35 rodolico 278
      $$install{'os'} = $os;
279
      print "Setting keys for operating system\n" if $verbose > 2;
114 rodolico 280
      # merge operatingSystems into install
115 rodolico 281
      foreach my $key ( keys %{$operatingSystems->{ $os }} ) {
282
         if ( $key eq 'files' ) {
283
            $install->{'files'} = { %{$install->{'files'}}, %{$operatingSystems->{$os}->{'files'}} }
284
         } else {
285
            $install->{$key} = $operatingSystems->{ $os }->{$key};
286
         }
287
      } # if it is a known OS
35 rodolico 288
   } # if
289
   return $os;
33 rodolico 290
} # getOperatingSystem
291
 
37 rodolico 292
 
34 rodolico 293
# get some input from the user and decide how to install/upgrade/remove/whatever
294
sub getInstallActions {
295
   my $install = shift;
296
   if ( ! &yesno( "This looks like a $$install{'os'} machine, correct?" ) ) {
297
      die "User Aborted\n" if &yesno( "If we continue, I will set this up like a $$install{'os'} system. Abort?" );
298
   }
299
   if ( -d $$install{'confdir'} ) {
300
      $$install{'action'} = &getAnswer( "It looks like $$install{'application name'} is already installed, what do you want to do?", 
301
                            ( "upgrade","remove", "overwrite" )
302
                          );
303
   } else {
304
      if ( &yesno( "This looks like a fresh install, correct?" ) ) {
305
         $$install{'action'} = 'install';
306
         $$install{'preseed config'} = &yesno( "Preseed the configuration file?" );
307
      } else {
308
         die "Can not continue at this time: Do not understand your system\n";
309
      }
310
   }
311
   $$install{'build config'} = &yesno( "Edit config file when done?" );
312
   $$install{'setup cron'} = &yesno( "Set up for automatic running via crontab?" );
313
}
33 rodolico 314
 
34 rodolico 315
sub showWork { 
316
   my $install = shift;
91 rodolico 317
   print Dump( \%install );
34 rodolico 318
}
35 rodolico 319
 
320
 
321
sub doPlaceholderSubstitution {
322
   my ($hash, $placeholder) = @_;
323
   return if ref $hash ne 'HASH';
324
   foreach my $key ( keys %$hash ) {
325
      if ( ref( $$hash{$key} ) ) {
326
         &doPlaceholderSubstitution( $$hash{$key}, $placeholder );
327
      } else {
328
         foreach my $place ( keys %$placeholder ) {
329
            $$hash{$key} =~ s/$place/$$placeholder{$place}/;
330
         } # foreach
331
      } # if..else
332
   } # foreach
333
   return;
334
}
34 rodolico 335
 
336
# This will go through and first, see if anything is a directory, in
337
# which case, we'll create new entries for all files in there.
338
# then, it will do keyword substitution of <bindir> and <confdir>
339
# to populate the target.
340
# When this is done, each file should have a source and target that is
341
# a fully qualified path and filename
33 rodolico 342
sub populateSourceDir {
343
   my ( $install, $sourceDir ) = @_;
35 rodolico 344
   my %placeHolders = 
345
      ( 
346
        '<bindir>' => $$install{'bindir'},
50 rodolico 347
        '<confdir>' => $$install{'confdir'},
348
        '<default owner>' => $$install{'default owner'},
349
        '<default group>' => $$install{'default group'},
350
        '<default permission>' => $$install{'default permission'}
35 rodolico 351
      );
33 rodolico 352
 
353
   my $allFiles = $$install{'files'};
354
 
35 rodolico 355
   # find all directory entries and load files in that directory into $$install{'files'}
33 rodolico 356
   foreach my $dir ( keys %$allFiles ) {
357
      if ( defined( $$allFiles{$dir}{'type'} ) && $$allFiles{$dir}{'type'} eq 'directory' ) {
35 rodolico 358
         print "Found directory $dir\n" if $verbose > 2;
33 rodolico 359
         if ( opendir( my $dh, "$sourceDir/$dir" ) ) {
360
            my @files = map{ $dir . '/' . $_ } grep { ! /^\./ && -f "$sourceDir/$dir/$_" } readdir( $dh );
35 rodolico 361
            print "\tFound files " . join( ' ', @files ) . "\n" if $verbose > 2;
33 rodolico 362
            foreach my $file ( @files ) {
363
               $$allFiles{ $file }{'type'} = 'file';
37 rodolico 364
               if ( $dir eq 'modules' ) {
365
                  $$allFiles{ $file }{'permission'} = ( $file =~ m/$$install{'modules'}/ ) ? '0700' : '0600';
366
               } else {
367
                  $$allFiles{ $file }{'permission'} = $$allFiles{ $dir }{'permission'};
368
               }
33 rodolico 369
               $$allFiles{ $file }{'owner'} = $$allFiles{ $dir }{'owner'};
370
               $$allFiles{ $file }{'target'} = $$allFiles{ $dir }{'target'};
371
            } # foreach
372
            closedir $dh;
373
         } # if opendir
374
      } # if it is a directory
375
   } # foreach
35 rodolico 376
   # find all files, and set the source directory, and add the filename to
377
   # the target
33 rodolico 378
   foreach my $file ( keys %$allFiles ) {
379
      $$allFiles{$file}{'source'} = "$sourceDir/$file";
380
      $$allFiles{$file}{'target'} .= "/$file";
381
   } # foreach
35 rodolico 382
 
383
   # finally, do place holder substitution. This recursively replaces all keys
384
   # in  %placeHolders with the values.
385
   &doPlaceholderSubstitution( $install, \%placeHolders );
386
 
91 rodolico 387
   print Dump( $install ) if $verbose > 2;
35 rodolico 388
 
33 rodolico 389
   return 1;
390
} # populateSourceDir
391
 
34 rodolico 392
# there is a file named VERSIONS. We get the values out of the install
393
# directory and (if it exists) the target so we can decide what needs
394
# to be updated.
33 rodolico 395
sub getVersions {
396
   my $install = shift;
397
   my $currentVersionFile = $$install{'files'}{'VERSION'}{'target'};
398
   my $newVersionFile = $$install{'files'}{'VERSION'}{'source'};
399
   if ( open FILE,"<$currentVersionFile" ) {
400
      while ( my $line = <FILE> ) {
401
         chomp $line;
402
         my ( $filename, $version, $checksum ) = split( "\t", $line );
403
         $$install{'files'}{$filename}{'installed version'} = $version ? $version : '';
404
      }
405
      close FILE;
406
   }
407
   if ( open FILE,"<$newVersionFile" ) {
408
      while ( my $line = <FILE> ) {
409
         chomp $line;
410
         my ( $filename, $version, $checksum ) = split( "\t", $line );
411
         $$install{'files'}{$filename}{'new version'} = $version ? $version : '';
412
      }
413
      close FILE;
414
   }
40 rodolico 415
   foreach my $file ( keys %{$$install{'files'}} ) {
416
      $$install{'files'}{$file}{'installed version'} = -2 unless defined $$install{'files'}{$file}{'installed version'};
417
      $$install{'files'}{$file}{'new version'} = -1 unless defined $$install{'files'}{$file}{'new version'};
418
   }
33 rodolico 419
   return 1;
420
} # getVersions
421
 
34 rodolico 422
# this actually does the installation, except for the configuration
33 rodolico 423
sub doInstall {
424
   my $install = shift;
425
   my $fileList = $$install{'files'};
426
 
50 rodolico 427
   &checkDirectoryExists( $$install{'bindir'} . '/', $$install{'default permission'}, "$$install{'default owner'}:$$install{'default group'}" );
33 rodolico 428
   foreach my $file ( keys %$fileList ) {
429
      next unless ( $$fileList{$file}{'type'} && $$fileList{$file}{'type'} eq 'file' );
40 rodolico 430
      next if $$install{'action'} eq 'upgrade' && ! defined( $$fileList{$file}{'installed version'} )
431
              ||
432
              ( $$fileList{$file}{'new version'} eq $$fileList{$file}{'installed version'} );
50 rodolico 433
      &checkDirectoryExists( $$fileList{$file}{'target'}, $$install{'default permission'}, "$$install{'default owner'}:$$install{'default group'}" );
33 rodolico 434
      &runCommand( 
435
            "cp $$fileList{$file}{'source'} $$fileList{$file}{'target'}",
436
            "chmod $$fileList{$file}{'permission'} $$fileList{$file}{'target'}",
437
            "chown  $$fileList{$file}{'owner'} $$fileList{$file}{'target'}"
438
            );
439
   } # foreach file
440
   return 1;
441
}
442
 
35 rodolico 443
sub postInstall {
444
   my $install = shift;
37 rodolico 445
 
35 rodolico 446
   # set up crontab, if necessary
37 rodolico 447
   &runCommand( $$install{'crontab'} ) if defined ( $$install{'crontab'} );
448
 
449
   # seed configuration, if needed
450
   if ( $$install{'build config'} ) {
43 rodolico 451
      my $config;
452
      my @fileList;
37 rodolico 453
 
94 rodolico 454
      # the order is important here as, if multiple files exist, latter ones can
455
      # overwrite values in the previous. We do a push so the first value pushed
456
      # is processed last, ie has higher priority.
457
      push @fileList, $install->{'configuration'}->{'old configuration file'};
458
      push @fileList, $install->{'configuration'}->{'configuration file'};
459
 
460
      my $seedFile = $install->{'configuration'}->{'configuration seed file'};
461
      if ( -e $seedFile  && &yesno( 'Add installation seed file? ' ) ) {
43 rodolico 462
         push @fileList, $seedFile;
37 rodolico 463
      } # if preload seed file
464
 
92 rodolico 465
      $config = &makeConfig( @fileList );
54 rodolico 466
      # if ScriptDirs and moduleDirs not populated, do so from our configuration
88 rodolico 467
      if ( ! $$config{'scriptDirs'} || ! scalar @{ $$config{'scriptDirs'} }  ) {
90 rodolico 468
#         my @temp = ( $$install{'files'}{'scripts'}{'target'} );
469
#         $$config{'scriptDirs'} = \@temp;
470
         $config->{'scriptDirs'} = [ $install->{'files'}->{'scripts'}->{'target'} ];
471
 
54 rodolico 472
      }
88 rodolico 473
      if ( ! $$config{'moduleDirs'} || ! @{ $$config{'moduleDirs'} }  ) {
90 rodolico 474
         $config->{'moduleDirs'} = [ $install->{'files'}->{'modules'}->{'target'} ];
475
#         $$config{'moduleDirs'} = [ $$install{'files'}{'modules'}{'target'} ];
54 rodolico 476
      }
477
#      print Dumper ($config ) ; die;
43 rodolico 478
      my $content = &showConf( $config );
35 rodolico 479
      print $content;
37 rodolico 480
      print &writeConfig( $$install{'configuration'}{'configuration file'} , $content ) . "\n"
481
         if ( &yesno( "Write the above configuration to $$install{'configuration'}{'configuration file'}?" ) );
482
   } # if we are building/merging configuration
35 rodolico 483
 
484
}
34 rodolico 485
 
35 rodolico 486
sub help {
487
   my $oses = join( ' ', keys %operatingSystems );
488
   print <<END
489
$0 --verbose=x --os="osname" --dryrun --help --version
34 rodolico 490
 
35 rodolico 491
--os      - osname is one of [$oses]
492
--dryrun  - do not actually do anything, just tell you what I'd do
493
--verbose - x is 0 (normal) to 3 (horrible)
494
END
495
}
34 rodolico 496
 
35 rodolico 497
 
498
 
499
##########################################
500
# Main Loop
501
##########################################
502
 
503
# handle any command line parameters that may have been passed in
504
 
505
GetOptions (
506
            "verbose|v=i" => \$verbose, # verbosity level, 0-9
507
            "os|o=s"      => \$os,      # pass in the operating system
508
            "dryrun|n"    => \$dryRun,  # do NOT actually do anything
509
            'help|h'      => \$help,
510
            'version|V'   => \$version
511
            ) or die "Error parsing command line\n";
512
 
513
if ( $help ) { &help() ; exit; }
514
if ( $version ) { print "$0 version $VERSION\n"; exit; }
515
&setDryRun( $dryRun ); # tell the library whether this is a dry run or not
516
 
107 rodolico 517
$os = `$sourceDir/determineOS` unless $os;
94 rodolico 518
# figure out if we know our operating system and set up special stuff for it
115 rodolico 519
 
94 rodolico 520
$os = &setUpOperatingSystemSpecific( \%install, \%operatingSystems, $os );
33 rodolico 521
 
115 rodolico 522
#$os = &setUpOperatingSystemSpecific( \%install, \%operatingSystems, 'freebsd' );
523
#print Dumper( \%install ); die;
524
 
42 rodolico 525
&validateLibraries( \%libraries, $os );
526
 
35 rodolico 527
$installType = &getInstallActions( \%install );
34 rodolico 528
 
33 rodolico 529
# based on the defaults, flesh out the install hash
530
$status = &populateSourceDir( \%install, $sourceDir );
531
 
35 rodolico 532
 
33 rodolico 533
$status = &getVersions( \%install );
534
 
35 rodolico 535
&showWork( \%install );
536
die unless &yesno( "Ready to run? Select No to abort." );
537
 
94 rodolico 538
#my $config = &makeConfig( $install{'configuration'}{'configuration seed file'}, $install{'configuration'}{'configuration file'}, $install{'configuration'}{'old configuration file'} );
539
#print Dumper( $config );
540
#die;
541
 
542
 
33 rodolico 543
$status = &doInstall( \%install );
544
 
35 rodolico 545
$status = &postInstall( \%install );
34 rodolico 546
 
57 rodolico 547
# create uninstaller script
548
# find the last non-space string in the crontab value. This is the target of the link
549
$install{'crontab'} =~ m/([^ ]+)$/;
94 rodolico 550
my $uninstall = "#! /usr/bin/env sh\n\n# Uninstall syinfo\nrm -fR $install{'bindir'} $1\n";
57 rodolico 551
my $outFileName = $install{'bindir'} . '/uninstall';
552
open UNINSTALL, ">$outFileName" or die "could not write to $outFileName: $!\n";
553
print UNINSTALL $uninstall;
554
close UNINSTALL;
555
qx ( chmod 700 $outFileName );
556
 
557
print "Uninstall script has been created at $outFileName\n";
558
 
37 rodolico 559
if ( ( -x $install{'configuration'}{'configurator'} ) && $install{'build config'} ) {
560
   exec( $install{'configuration'}{'configurator'} );
561
} else {
562
   print "Done, you should check the files in $install{'bindir'} and $install{'confdir'} before running\n";
563
   print "If you need help configuring, the helper app at\n$install{'configuration'}{'configurator'}\ncan be used.\n";
564
}
565
 
35 rodolico 566
1;   
40 rodolico 567
 
568
 
569
# clean will look for any file in bindir which is NOT in the list of available files and remove them
570
# if files already exist in install, preserve their permissions