mirror of
https://github.com/duncs/clusterssh.git
synced 2025-07-03 01:43:25 +00:00
Further enhancements to the config module
Continue work to move all the config code out of the main module into a sub module. Not yet used by the main module.
This commit is contained in:
parent
81a79902b6
commit
b51644512d
6 changed files with 142 additions and 4 deletions
|
@ -9,6 +9,7 @@ use Carp;
|
|||
|
||||
use base qw/ App::ClusterSSH::Base /;
|
||||
use App::ClusterSSH::Host;
|
||||
use App::ClusterSSH::Config;
|
||||
|
||||
use POSIX ":sys_wait_h";
|
||||
use Pod::Usage;
|
||||
|
@ -50,12 +51,19 @@ sub new {
|
|||
|
||||
my $self = $class->SUPER::new(%args);
|
||||
|
||||
$self->{config} = App::ClusterSSH::Config->new();
|
||||
|
||||
# catch and reap any zombies
|
||||
$SIG{CHLD} = \&REAPER;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub config {
|
||||
my ($self) = @_;
|
||||
return $self->{config};
|
||||
}
|
||||
|
||||
sub REAPER {
|
||||
my $kid;
|
||||
do {
|
||||
|
@ -2316,6 +2324,8 @@ the code until this time.
|
|||
|
||||
=item close_inactive_sessions
|
||||
|
||||
=item config
|
||||
|
||||
=item create_menubar
|
||||
|
||||
=item create_windows
|
||||
|
|
|
@ -11,7 +11,7 @@ use Carp;
|
|||
use base qw/ App::ClusterSSH::Base /;
|
||||
|
||||
my %clusters;
|
||||
my @app_specific = ( qw/ title comms method ssh rsh telnet ccon / );
|
||||
my @app_specific = (qw/ title comms method ssh rsh telnet ccon /);
|
||||
my %default_config = (
|
||||
terminal => "xterm",
|
||||
terminal_args => "",
|
||||
|
@ -167,6 +167,64 @@ sub parse_config_file {
|
|||
$self->validate_args(%read_config);
|
||||
}
|
||||
|
||||
# could use File::Which for some of this but we also search a few other places
|
||||
# just in case $PATH isnt set up right
|
||||
sub find_binary {
|
||||
my ( $self, $binary ) = @_;
|
||||
|
||||
if ( !$binary ) {
|
||||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc('argument not provided'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$self->debug( 2, "Looking for $binary" );
|
||||
my $path;
|
||||
if ( !-x $binary || substr( $binary, 0, 1 ) ne '/' ) {
|
||||
|
||||
foreach (
|
||||
split( /:/, $ENV{PATH} ), qw!
|
||||
/bin
|
||||
/sbin
|
||||
/usr/sbin
|
||||
/usr/bin
|
||||
/usr/local/bin
|
||||
/usr/local/sbin
|
||||
/opt/local/bin
|
||||
/opt/local/sbin
|
||||
!
|
||||
)
|
||||
{
|
||||
$self->debug( 3, "Looking in $_" );
|
||||
|
||||
if ( -f $_ . '/' . $binary && -x $_ . '/' . $binary ) {
|
||||
$path = $_ . '/' . $binary;
|
||||
$self->debug( 2, "Found at $path" );
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$self->debug( 2, "Already configured OK" );
|
||||
$path = $binary;
|
||||
}
|
||||
if ( !$path || !-f $path || !-x $path ) {
|
||||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc(
|
||||
'"[_1]" binary not found - please amend $PATH or the cssh config file',
|
||||
$binary
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
chomp($path);
|
||||
return $path;
|
||||
}
|
||||
|
||||
#use overload (
|
||||
# q{""} => sub {
|
||||
# my ($self) = @_;
|
||||
|
@ -197,7 +255,7 @@ Object representing application configuration
|
|||
|
||||
Create a new configuration object.
|
||||
|
||||
=item $config->parse_config_file('<filename');
|
||||
=item $config->parse_config_file('<filename>');
|
||||
|
||||
Read in configuration from given filename
|
||||
|
||||
|
@ -205,6 +263,11 @@ Read in configuration from given filename
|
|||
|
||||
Validate and apply all configuration loaded at this point
|
||||
|
||||
=item $path = $self->find_binary('<name>');
|
||||
|
||||
Locate the binary <name> and return the full path. Doesn't just search
|
||||
$PATH in case the environment isn't set up correctly
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHOR
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue