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