Apache-Logmonster
view release on metacpan or search on metacpan
bin/install_deps.pl view on Meta::CPAN
'apps' => [
# { app => 'expat' , info => { port => 'expat2', dport=>'expat2' } },
# { app => 'gettext' , info => { port => 'gettext', dport=>'gettext'} },
# { app => 'gmake' , info => { port => 'gmake', dport=>'gmake' } },
]
};
$EUID == 0 or die "You will have better luck if you run me as root.\n";
# this causes problems when CPAN is not configured.
#$ENV{PERL_MM_USE_DEFAULT} = 1; # supress CPAN prompts
$ENV{FTP_PASSIVE} = 1; # for FTP behind NAT/firewalls
my @failed;
foreach ( @{ $deps->{apps} } ) {
my $name = $_->{app} or die 'missing app name';
install_app( $name, $_->{info} );
};
foreach ( @{ $deps->{modules} } ) {
lib/Apache/Logmonster/Utility.pm view on Meta::CPAN
timeout => { type => SCALAR, optional => 1 },
password => { type => BOOLEAN, optional => 1, default => 0 },
test_ok => { type => BOOLEAN, optional => 1 },
}
);
my $pass = $p{password};
my $default = $p{default};
if ( ! $self->is_interactive() ) {
$log->audit( "not running interactively, can not prompt!");
return $default;
}
return $log->error( "ask called with \'$question\' which looks unsafe." )
if $question !~ m{\A \p{Any}* \z}xms;
my $response;
return $p{test_ok} if defined $p{test_ok};
lib/Apache/Logmonster/Utility.pm view on Meta::CPAN
%std_opts
},
);
# for 'make test' testing
return 1 if $question eq "test";
# force if interactivity testing is not working properly.
if ( !$p{force} && !$self->is_interactive ) {
carp "not running interactively, can't prompt!";
return;
}
my $response;
print "\nYou have $p{timeout} seconds to respond.\n" if $p{timeout};
print "\n\t\t$question";
# I wish I knew why this is not working correctly
# eval { local $SIG{__DIE__}; require Term::ReadKey };
lib/Apache/Logmonster/Utility.pm view on Meta::CPAN
=item ask
Get a response from the user. If the user responds, their response is returned. If not, then the default response is returned. If no default was supplied, 0 is returned.
############################################
# Usage : my $ask = $util->ask( "Would you like fries with that",
# default => "SuperSized!",
# timeout => 30
# );
# Purpose : prompt the user for information
#
# Returns : S - the users response (if not empty) or
# : S - the default ask or
# : S - an empty string
#
# Parameters
# Required : S - question - what to ask
# Optional : S - default - a default answer
# : I - timeout - how long to wait for a response
# Throws : no exceptions
lib/Apache/Logmonster/Utility.pm view on Meta::CPAN
=item check_homedir_ownership
Checks the ownership on all home directories to see if they are owned by their respective users in /etc/password. Offers to repair the permissions on incorrectly owned directories. This is useful when someone that knows better does something like "ch...
######### check_homedir_ownership ############
# Usage : $util->check_homedir_ownership();
# Purpose : repair user homedir ownership
# Returns : 0 - failure, 1 - success
# Parameters :
# Optional : I - auto - no prompts, just fix everything
# See Also : sysadmin
Comments: Auto mode should be run with great caution. Run it first to see the results and then, if everything looks good, run in auto mode to do the actual repairs.
=item chown_system
The advantage this sub has over a Pure Perl implementation is that it can utilize sudo to gain elevated permissions that we might not otherwise have.
t/Utility.t view on Meta::CPAN
skip "ask is an interactive only feature", 4 unless $util->is_interactive;
ok( $r = $util->ask( 'test yes ask',
default => 'yes',
timeout => 5
),
'ask, proper args'
);
is( lc($r), "yes", 'ask' );
ok( $r = $util->ask( 'any (non empty) answer' ), 'ask, tricky' );
# multiline prompt
ok( $r = $util->ask( 'test any (non empty) answer',
default => 'just hit enter',
),
'ask, multiline'
);
# default password prompt
ok( $r = $util->ask( 'type a secret word',
password => 1,
default => 'secret',
),
'ask, password'
);
}
# extract_archive
my $gzip = $util->find_bin( "gzip", fatal => 0 );
( run in 2.611 seconds using v1.01-cache-2.11-cpan-6aa56a78535 )