mirror of
https://github.com/ovh/the-bastion.git
synced 2025-01-01 13:01:53 +08:00
parent
8d2aaf8d8f
commit
d400ceeb9f
3 changed files with 21 additions and 6 deletions
|
@ -20,12 +20,14 @@ my $remainingOptions = OVH::Bastion::Plugin::begin(
|
|||
'no-stdin' => \$noStdin,
|
||||
'command=s' => \$command,
|
||||
},
|
||||
helptext => <<'EOF',
|
||||
helptext => <<"EOF",
|
||||
Launch a remote command on several machines sequentially (clush-like)
|
||||
|
||||
Usage: --osh SCRIPT_NAME [OPTIONS] --command '"remote command"'
|
||||
|
||||
--list HOSTLIST Comma-separated list of the hosts to run the command on
|
||||
--list HOSTLIST Comma-separated list of the hosts (hostname or IP) to run the command on
|
||||
--user USER Specify which remote user should we use to connect (default: BASTION_ACCOUNT)
|
||||
--port PORT Specify which port to connect to (default: 22)
|
||||
--step-by-step Pause before running the command on each host
|
||||
--no-pause-on-failure Don't pause if the remote command failed (returned exit code != 0)
|
||||
--no-confirm Skip confirmation of the host list and command
|
||||
|
|
|
@ -16,7 +16,15 @@ Launch a remote command on several machines sequentially (clush-like)
|
|||
|
||||
.. option:: --list HOSTLIST
|
||||
|
||||
Comma-separated list of the hosts to run the command on
|
||||
Comma-separated list of the hosts (hostname or IP) to run the command on
|
||||
|
||||
.. option:: --user USER
|
||||
|
||||
Specify which remote user should we use to connect (default: BASTION_ACCOUNT)
|
||||
|
||||
.. option:: --port PORT
|
||||
|
||||
Specify which port to connect to (default: 22)
|
||||
|
||||
.. option:: --step-by-step
|
||||
|
||||
|
|
|
@ -97,6 +97,14 @@ sub begin {
|
|||
$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/pkg/bin';
|
||||
$ENV{'PLUGIN_NAME'} = $scriptName;
|
||||
|
||||
$HOME = OVH::Bastion::get_home_from_env()->value;
|
||||
$self = OVH::Bastion::get_user_from_env()->value;
|
||||
|
||||
# if we're generating documentation (PLUGIN_DOCGEN is set), leave the BASTION_ACCOUNT placeholder
|
||||
if ($_helptext && !$ENV{'PLUGIN_DOCGEN'}) {
|
||||
$_helptext =~ s/BASTION_ACCOUNT/$self/g;
|
||||
}
|
||||
|
||||
osh_header($header) if $header;
|
||||
|
||||
if (!$result) {
|
||||
|
@ -110,9 +118,6 @@ sub begin {
|
|||
osh_exit;
|
||||
}
|
||||
|
||||
$self = OVH::Bastion::get_user_from_env()->value;
|
||||
$HOME = OVH::Bastion::get_home_from_env()->value;
|
||||
|
||||
$fnret = OVH::Result::R('OK', value => {sysaccount => $self, account => $self, realm => undef, remoteaccount => undef});
|
||||
if ($< == 0) {
|
||||
; # called by root, don't verify if it's a bastion account (because it's not)
|
||||
|
|
Loading…
Reference in a new issue