Daemon-Shutdown
view release on metacpan or search on metacpan
lib/Daemon/Shutdown.pm view on Meta::CPAN
my %params = @_;
# Remove any undefined parameters from the params hash
map { delete( $params{$_} ) if not $params{$_} } keys %params;
# Validate the config file
%params = validate_with(
params => \%params,
spec => {
config => {
callbacks => {
'File exists' => sub { -f shift }
},
default => '/etc/sdd.conf',
},
},
allow_extra => 1,
);
my $self = {};
# Read the config file
lib/Daemon/Shutdown.pm view on Meta::CPAN
# Merge the default, config file, and passed parameters
%params = ( %$file_config, %params );
my @validate = map { $_, $params{$_} } keys( %params );
%params = validate_with(
params => \%params,
spec => {
log_file => {
default => '/var/log/sdd.log',
callbacks => {
'Log file is writable' => sub {
my $filepath = shift;
if ( -f $filepath ) {
return -w $filepath;
} else {
# Is directory writable
return -w dirname( $filepath );
}
},
lib/Daemon/Shutdown.pm view on Meta::CPAN
default => 0,
regex => qr/^[1|0]$/,
},
use_sudo => {
default => 0,
regex => qr/^[1|0]$/,
},
shutdown_binary => {
default => '/sbin/poweroff',
type => SCALAR,
callbacks => {
'Shutdown binary exists' => sub {
-x shift();
},
},
},
shutdown_args => {
type => ARRAYREF,
optional => 1
},
monitor => { type => HASHREF, },
lib/Daemon/Shutdown.pm~ view on Meta::CPAN
my %params = @_;
# Remove any undefined parameters from the params hash
map { delete( $params{$_} ) if not $params{$_} } keys %params;
# Validate the config file
%params = validate_with(
params => \%params,
spec => {
config => {
callbacks => {
'File exists' => sub { -f shift }
},
default => '/etc/sdd.conf',
},
},
allow_extra => 1,
);
my $self = {};
# Read the config file
lib/Daemon/Shutdown.pm~ view on Meta::CPAN
# Merge the default, config file, and passed parameters
%params = ( %$file_config, %params );
my @validate = map { $_, $params{$_} } keys( %params );
%params = validate_with(
params => \%params,
spec => {
log_file => {
default => '/var/log/sdd.log',
callbacks => {
'Log file is writable' => sub {
my $filepath = shift;
if ( -f $filepath ) {
return -w $filepath;
} else {
# Is directory writable
return -w dirname( $filepath );
}
},
lib/Daemon/Shutdown.pm~ view on Meta::CPAN
default => 0,
regex => qr/^[1|0]$/,
},
use_sudo => {
default => 0,
regex => qr/^[1|0]$/,
},
shutdown_binary => {
default => '/sbin/poweroff',
type => SCALAR,
callbacks => {
'Shutdown binary exists' => sub {
-x shift();
},
},
},
shutdown_args => {
type => ARRAYREF,
optional => 1
},
monitor => { type => HASHREF, },
lib/Daemon/Shutdown/Monitor/hdparm.pm view on Meta::CPAN
regex => qr/^\d*$/,
default => 60,
},
trigger_time => {
regex => qr/^\d*$/,
default => 3600,
},
disks => {
type => ARRAYREF,
default => ['/dev/sda'],
callbacks => {
'Disks exist' => sub {
my $disks_ref = shift();
foreach my $disk ( @{$disks_ref} ) {
return 0 if !-e $disk;
}
return 1;
},
},
},
use_sudo => {
lib/Daemon/Shutdown/Monitor/hdparm.pm~ view on Meta::CPAN
regex => qr/^\d*$/,
default => 60,
},
trigger_time => {
regex => qr/^\d*$/,
default => 3600,
},
disks => {
type => ARRAYREF,
default => [ '/dev/sda' ],
callbacks => {
'Disks exist' => sub {
my $disks_ref = shift();
foreach my $disk ( @{$disks_ref} ) {
return 0 if !-e $disk;
}
return 1;
},
},
},
use_sudo => {
( run in 1.356 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )