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;
|
|
|
48 |
`rm /etc/fcron.daily/sysinfo.cron` if -e '/etc/fcron.daily/sysinfo.cron';
|
|
|
49 |
`rm /etc/cron.daily/sysinfo` if -e '/etc/cron.daily/sysinfo';
|
|
|
50 |
`rm /usr/local/bin/sysinfo-client` if -e '/usr/local/bin/sysinfo-client';
|
|
|
51 |
print "Standard sysinfo-client removed\n";
|
|
|
52 |
} else {
|
|
|
53 |
print "Uninstalled aborted\n"
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
exit 1;
|
|
|
57 |
|