mirror of
https://github.com/duncs/clusterssh.git
synced 2025-04-22 09:22:24 +00:00
Move .csshrc to .csshrc.DISABLED
Move the old config file to one side since it should no longer be used and the error was more annoying than useful Also catch perltidy from previous commit
This commit is contained in:
parent
7755a60161
commit
a7296983e6
3 changed files with 76 additions and 46 deletions
1
Changes
1
Changes
|
@ -3,6 +3,7 @@
|
|||
* Re-add user back into the configurartion file
|
||||
* Add in missing newline for some error messages
|
||||
* Allow the path to rsh/ssh/telnet to be defined in the configuration file
|
||||
* Move .csshrc to .csshrc.DISABLED since it should no longer be used
|
||||
|
||||
2012-12-09 Duncan Ferguson <duncan_ferguson@user.sf.net> - v4.01_02
|
||||
* Fix logic when using 'autoclose' on the command line or config file
|
||||
|
|
|
@ -10,6 +10,7 @@ use Carp;
|
|||
use Try::Tiny;
|
||||
|
||||
use FindBin qw($Script);
|
||||
use File::Copy;
|
||||
|
||||
use base qw/ App::ClusterSSH::Base /;
|
||||
use App::ClusterSSH::Cluster;
|
||||
|
@ -130,23 +131,22 @@ sub validate_args {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (@unknown_config) {
|
||||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
unknown_config => \@unknown_config,
|
||||
error => $self->loc(
|
||||
'Unknown configuration parameters: [_1]'.$/,
|
||||
'Unknown configuration parameters: [_1]' . $/,
|
||||
join( ',', @unknown_config )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $self->{comms} ) {
|
||||
if ( !$self->{comms} ) {
|
||||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc( 'Invalid variable: comms'.$/),
|
||||
error => $self->loc( 'Invalid variable: comms' . $/ ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -154,17 +154,20 @@ sub validate_args {
|
|||
if ( !$self->{ $self->{comms} } ) {
|
||||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc( 'Invalid variable: [_1]'.$/, $self->{comms}),
|
||||
error => $self->loc(
|
||||
'Invalid variable: [_1]' . $/,
|
||||
$self->{comms}
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
# # Don't search for the path to the binary - assume it is on the path
|
||||
# # or defined correctly in the config.
|
||||
# if( !-e $self->{ $self->{comms} } )
|
||||
# {
|
||||
# $self->{ $self->{comms} } = $self->find_binary( $self->{comms} );
|
||||
# }
|
||||
|
||||
# # Don't search for the path to the binary - assume it is on the path
|
||||
# # or defined correctly in the config.
|
||||
# if( !-e $self->{ $self->{comms} } )
|
||||
# {
|
||||
# $self->{ $self->{comms} } = $self->find_binary( $self->{comms} );
|
||||
# }
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
@ -178,7 +181,8 @@ sub parse_config_file {
|
|||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc(
|
||||
'File [_1] does not exist or cannot be read'.$/, $config_file
|
||||
'File [_1] does not exist or cannot be read' . $/,
|
||||
$config_file
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -233,16 +237,6 @@ sub parse_config_file {
|
|||
sub load_configs {
|
||||
my ( $self, @configs ) = @_;
|
||||
|
||||
if ( -e $ENV{HOME} . '/.csshrc' ) {
|
||||
warn(
|
||||
$self->loc(
|
||||
'NOTICE: [_1] is no longer used - please see documentation and remove',
|
||||
$ENV{HOME} . '/.csshrc'
|
||||
),
|
||||
$/
|
||||
);
|
||||
}
|
||||
|
||||
for my $config (
|
||||
'/etc/csshrc',
|
||||
$ENV{HOME} . '/.csshrc',
|
||||
|
@ -276,6 +270,30 @@ sub load_configs {
|
|||
sub write_user_config_file {
|
||||
my ($self) = @_;
|
||||
|
||||
# attempt to move the old config file to one side
|
||||
if ( -f "$ENV{HOME}/.csshrc" ) {
|
||||
eval { move( "$ENV{HOME}/.csshrc", "$ENV{HOME}/.csshrc.DISABLED" ) };
|
||||
|
||||
if ($@) {
|
||||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc(
|
||||
'Unable to move [_1] to [_2]: [_3]' . $/,
|
||||
'$HOME/.csshrc', '$HOME/.csshrc.DISABLED', $@
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
warn(
|
||||
$self->loc(
|
||||
'Moved [_1] to [_2]' . $/, '$HOME/.csshrc',
|
||||
'$HOME/.csshrc.DISABLED'
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return if ( -f "$ENV{HOME}/.clusterssh/config" );
|
||||
|
||||
if ( !-d "$ENV{HOME}/.clusterssh" ) {
|
||||
|
@ -283,7 +301,7 @@ sub write_user_config_file {
|
|||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc(
|
||||
'Unable to create directory [_1]: [_2]'.$/,
|
||||
'Unable to create directory [_1]: [_2]' . $/,
|
||||
'$HOME/.clusterssh', $!
|
||||
),
|
||||
),
|
||||
|
@ -297,29 +315,36 @@ sub write_user_config_file {
|
|||
print CONFIG "$_=$self->{$_}\n";
|
||||
}
|
||||
close(CONFIG);
|
||||
warn(
|
||||
$self->loc(
|
||||
'Created new configuration file within [_1]' . $/,
|
||||
'$HOME/.clusterssh/'
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc(
|
||||
'Unable to write default [_1]: [_2]'.$/,
|
||||
'$HOME/.clusterssh/config',
|
||||
$!
|
||||
'Unable to write default [_1]: [_2]' . $/,
|
||||
'$HOME/.clusterssh/config', $!
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $self if ( !%old_clusters );
|
||||
|
||||
if ( open( my $fh, ">", "$ENV{HOME}/.clusterssh/clusters" ) ) {
|
||||
print $fh '# '
|
||||
. $self->loc('Tag definitions moved from old .csshrc file'), $/;
|
||||
foreach ( sort( keys(%old_clusters) ) ) {
|
||||
print $fh $_, ' ', join( ' ', $old_clusters{$_} ), $/;
|
||||
if (%old_clusters) {
|
||||
if ( open( my $fh, ">", "$ENV{HOME}/.clusterssh/clusters" ) ) {
|
||||
print $fh '# '
|
||||
. $self->loc('Tag definitions moved from old .csshrc file'),
|
||||
$/;
|
||||
foreach ( sort( keys(%old_clusters) ) ) {
|
||||
print $fh $_, ' ', join( ' ', $old_clusters{$_} ), $/;
|
||||
}
|
||||
close($fh);
|
||||
}
|
||||
close($fh);
|
||||
}
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -331,7 +356,7 @@ sub find_binary {
|
|||
if ( !$binary ) {
|
||||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc('argument not provided').$/,
|
||||
error => $self->loc('argument not provided') . $/,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -383,7 +408,8 @@ sub find_binary {
|
|||
croak(
|
||||
App::ClusterSSH::Exception::Config->throw(
|
||||
error => $self->loc(
|
||||
'"[_1]" binary not found - please amend $PATH or the cssh config file'.$/,
|
||||
'"[_1]" binary not found - please amend $PATH or the cssh config file'
|
||||
. $/,
|
||||
$binary
|
||||
),
|
||||
),
|
||||
|
|
21
t/15config.t
21
t/15config.t
|
@ -273,7 +273,10 @@ isa_ok( $config, "App::ClusterSSH::Config" );
|
|||
isa_ok( $config, "App::ClusterSSH::Config" );
|
||||
is( $trap->die, undef, 'die message correct' );
|
||||
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
||||
is( $trap->stderr, q{}, 'Expecting no STDERR' );
|
||||
is( $trap->stderr,
|
||||
'Created new configuration file within $HOME/.clusterssh/'.$/,
|
||||
'Got correct STDERR output for .csshrc'
|
||||
);
|
||||
|
||||
#note(qx/ls -laR $ENV{HOME}/);
|
||||
ok( -d $ENV{HOME} . '/.clusterssh', '.clusterssh dir exists' );
|
||||
|
@ -297,10 +300,8 @@ isa_ok( $config, "App::ClusterSSH::Config" );
|
|||
is( $trap->die, undef, 'die message correct' );
|
||||
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
||||
is( $trap->stderr,
|
||||
'NOTICE: '
|
||||
. $ENV{HOME}
|
||||
. '/.csshrc is no longer used - please see documentation and remove'
|
||||
. $/,
|
||||
'Moved $HOME/.csshrc to $HOME/.csshrc.DISABLED'.$/.
|
||||
'Created new configuration file within $HOME/.clusterssh/'.$/,
|
||||
'Got correct STDERR output for .csshrc'
|
||||
);
|
||||
ok( -d $ENV{HOME} . '/.clusterssh', '.clusterssh dir exists' );
|
||||
|
@ -308,6 +309,11 @@ ok( -f $ENV{HOME} . '/.clusterssh/config', '.clusterssh config file exists' );
|
|||
is_deeply( $config, \%expected, 'amended config is correct' );
|
||||
|
||||
note('.csshrc warning and .clusterssh dir plus config');
|
||||
# need to recreate .csshrc as it was just moved
|
||||
open( $csshrc, '>', $ENV{HOME} . '/.csshrc' );
|
||||
print $csshrc 'auto_quit = no', $/;
|
||||
close($csshrc);
|
||||
$expected{auto_quit} = 'no';
|
||||
open( $csshrc, '>', $ENV{HOME} . '/.clusterssh/config' );
|
||||
print $csshrc 'window_tiling = no', $/;
|
||||
close($csshrc);
|
||||
|
@ -322,10 +328,7 @@ isa_ok( $config, "App::ClusterSSH::Config" );
|
|||
is( $trap->die, undef, 'die message correct' );
|
||||
is( $trap->stdout, q{}, 'Expecting no STDOUT' );
|
||||
is( $trap->stderr,
|
||||
'NOTICE: '
|
||||
. $ENV{HOME}
|
||||
. '/.csshrc is no longer used - please see documentation and remove'
|
||||
. $/,
|
||||
'Moved $HOME/.csshrc to $HOME/.csshrc.DISABLED'.$/,
|
||||
'Got correct STDERR output for .csshrc'
|
||||
);
|
||||
ok( -d $ENV{HOME} . '/.clusterssh', '.clusterssh dir exists' );
|
||||
|
|
Loading…
Add table
Reference in a new issue