Subversion Repositories camp_sysinfo_client_3

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
16 rodolico 1
#!/usr/bin/env perl
2
 
3
use warnings;
4
 
20 rodolico 5
$main::VERSION = '1.0';
6
 
16 rodolico 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
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.
24
# it is assumed 
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;
34
   $thisAnswer = $default unless $thisAnswer;
35
   return $thisAnswer;
36
}
37
 
38
sub yesno {
39
   my $prompt = shift;
40
   my $answer = &getAnswer( $prompt, ('yes','no' ) );
41
   return lc( substr( $answer, 0, 1 ) ) eq 'y';
42
}
43
 
20 rodolico 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
 
53
&processParameters( @ARGV );
54
 
55
 
16 rodolico 56
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?" );
58
   print "Uninstalling ";
59
   print "and removing config" if $removeConfig;
60
   `rm -fRv $targetDir`;
61
   `rm -fRv $confDir` if $removeConfig;
18 rodolico 62
   unlink(  '/etc/fcron.daily/sysinfo.cron',
63
            '/etc/cron.daily/sysinfo',
64
            '/usr/local/bin/sysinfo-client' 
65
          );
66
   print "\nStandard sysinfo-client removed\n";
16 rodolico 67
} else {
68
   print "Uninstalled aborted\n"
69
}
70
 
71
exit 1;
72