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