mirror of
https://github.com/ovh/the-bastion.git
synced 2025-10-06 19:45:43 +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,
|
'no-stdin' => \$noStdin,
|
||||||
'command=s' => \$command,
|
'command=s' => \$command,
|
||||||
},
|
},
|
||||||
helptext => <<'EOF',
|
helptext => <<"EOF",
|
||||||
Launch a remote command on several machines sequentially (clush-like)
|
Launch a remote command on several machines sequentially (clush-like)
|
||||||
|
|
||||||
Usage: --osh SCRIPT_NAME [OPTIONS] --command '"remote command"'
|
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
|
--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-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
|
--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
|
.. 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
|
.. 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{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/pkg/bin';
|
||||||
$ENV{'PLUGIN_NAME'} = $scriptName;
|
$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;
|
osh_header($header) if $header;
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
@ -110,9 +118,6 @@ sub begin {
|
||||||
osh_exit;
|
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});
|
$fnret = OVH::Result::R('OK', value => {sysaccount => $self, account => $self, realm => undef, remoteaccount => undef});
|
||||||
if ($< == 0) {
|
if ($< == 0) {
|
||||||
; # called by root, don't verify if it's a bastion account (because it's not)
|
; # called by root, don't verify if it's a bastion account (because it's not)
|
||||||
|
|
Loading…
Add table
Reference in a new issue