Subversion Repositories camp_sysinfo_client_3

Rev

Rev 20 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20 Rev 21
Line 1... Line 1...
1
#!/usr/bin/env perl
1
#!/usr/bin/env perl
2
 
2
 
3
use warnings;
3
use warnings;
4
 
4
 
5
$main::VERSION = '1.0';
5
$main::VERSION = '1.1';
6
 
6
 
7
my $thisDir = `pwd`;
-
 
8
chomp $thisDir;
-
 
9
 
-
 
10
my $targetDir = '/opt/camp/sysinfo-client';
-
 
11
my $modulesDir = $targetDir . '/modules';
-
 
12
my $scriptsDir = $targetDir . '/scripts';
-
 
13
my $confDir = '/etc/camp/sysinfo-client';
-
 
14
 
-
 
15
# an extremely basic installer for sysinfo-client
7
# find our location and use it for searching for libraries
16
 
-
 
17
 
-
 
18
# prompt the user for a response, then allow them to enter it
-
 
19
# the first response is considered the default and is printed
-
 
20
# in all caps if more than one exists
-
 
21
# first answer is used if they simply press the Enter
-
 
22
# key. The response is returned all lower case if more than one
-
 
23
# exists.
8
BEGIN {
24
# it is assumed 
9
   use FindBin;
25
sub getAnswer {
-
 
26
   my ( $prompt, @answers ) = @_;
-
 
27
   my $default = $answers[0];
-
 
28
   my $onlyOneAnswer = scalar( @answers ) == 1;
-
 
29
   print $prompt . '[ ';
-
 
30
   $answers[0] = uc $answers[0] unless $onlyOneAnswer;
-
 
31
   print join( ' | ', @answers ) . ' ]: ';
-
 
32
   $thisAnswer = <>;
-
 
33
   chomp $thisAnswer;
10
   use File::Spec;
34
   $thisAnswer = $default unless $thisAnswer;
11
   use lib File::Spec->catdir($FindBin::Bin);
35
   return $thisAnswer;
-
 
36
}
12
}
37
 
13
 
38
sub yesno {
14
use sysinfoconf;
39
   my $prompt = shift;
-
 
40
   my $answer = &getAnswer( $prompt, ('yes','no' ) );
-
 
41
   return lc( substr( $answer, 0, 1 ) ) eq 'y';
-
 
42
}
15
 
-
 
16
# an extremely basic uninstaller for sysinfo-client
43
 
17
 
44
sub processParameters {
-
 
45
   while ( my $parameter = shift ) {
-
 
46
      if ( $parameter eq '-v' ) {
-
 
47
         print "$main::VERSION\n";
-
 
48
         exit;
-
 
49
      }
-
 
50
   } # while
-
 
51
}
-
 
52
 
18
 
53
&processParameters( @ARGV );
19
&processParameters( @ARGV );
54
 
20
 
55
 
21
 
56
if ( &yesno( "I am getting ready to remove sysinfo-client from the system\nOk?" ) ) {
22
if ( &yesno( "I am getting ready to remove sysinfo-client from the system\nOk?" ) ) {
57
   my $removeConfig = &yesno( "Do you want me to remove the configuration also?" );
23
   my $removeConfig = &yesno( "Do you want me to remove the configuration also?" );
58
   print "Uninstalling ";
24
   print "Uninstalling ";
59
   print "and removing config" if $removeConfig;
25
   print "and removing config" if $removeConfig;
60
   `rm -fRv $targetDir`;
26
   `rm -fRv $binDir`;
61
   `rm -fRv $confDir` if $removeConfig;
27
   `rm -fRv $confDir` if $removeConfig;
62
   unlink(  '/etc/fcron.daily/sysinfo.cron',
28
   unlink(  '/etc/fcron.daily/sysinfo.cron',
63
            '/etc/cron.daily/sysinfo',
29
            '/etc/cron.daily/sysinfo',
64
            '/usr/local/bin/sysinfo-client' 
30
            '/usr/local/bin/sysinfo-client' 
65
          );
31
          );