captaincore/app/ssh
Austin Ginder 825b54016d 📦 NEW: Go CLI
2021-06-24 23:05:07 -04:00

56 lines
No EOL
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# SSH connection to one or more sites.
#
# `captaincore ssh <site>`
#
# [<site>...]
# One or more sites.
#
# [@<target>]
# Target groups of sites like @all @production or @staging.
#
# [--parallel=<number>]
# Number of SSH connections at same time
#
# [--command=<commands>]
# Runs command over SSH
#
# [--script=<name|script>] [--<script-argument-name>=<script-argument-value>]
# Runs script over SSH
#
# [--recipe=<recipe_id>
# Runs script over SSH
#
# [--debug]
# Outputs SSH command for debug purposes
#
read -r -d '' php_code << heredoc
\$arguments = <<<PHPHEREDOC
$@
PHPHEREDOC;
echo base64_encode( \$arguments );
heredoc
arguments=$( php -r "$php_code" )
if [[ "$1" == "" ]]; then
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Requires a <site>."
exit
fi
cd "$HOME/.captaincore/data"
if [[ "$CAPTAINCORE_DEBUG" == "true" ]]; then
wp eval-file ../lib/local-scripts/ssh.php arguments=$arguments
echo ""
exit
fi
run_ssh=$( wp eval-file ../lib/local-scripts/ssh.php arguments=$arguments )
if [[ "$run_ssh" == *"Error:"* ]]; then
echo $run_ssh
exit
fi
eval $run_ssh