From c54bf12823c5010c8945f4a90a05c8d92ca72914 Mon Sep 17 00:00:00 2001 From: Roman Lumetsberger Date: Wed, 22 Nov 2023 11:58:40 +0000 Subject: [PATCH 1/3] Add support for DEPLOY_SSH_REMOTE_SHELL --- deploy/ssh.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/deploy/ssh.sh b/deploy/ssh.sh index c66e2e19..dbe84153 100644 --- a/deploy/ssh.sh +++ b/deploy/ssh.sh @@ -25,6 +25,7 @@ # export DEPLOY_SSH_MULTI_CALL="" # yes or no, default to no or previously saved value # export DEPLOY_SSH_USE_SCP="" yes or no, default to no # export DEPLOY_SSH_SCP_CMD="" defaults to "scp -q" +# export DEPLOY_SSH_REMOTE_SHELL="" # defaults to sh -c # ######## Public functions ##################### @@ -71,6 +72,15 @@ ssh_deploy() { fi _savedeployconf DEPLOY_SSH_CMD "$DEPLOY_SSH_CMD" + # REMOTE_SHELL is optional. If not provided then use sh + _migratedeployconf Le_Deploy_ssh_remote_shell DEPLOY_SSH_REMOTE_SHELL + _getdeployconf DEPLOY_SSH_REMOTE_SHELL + _debug2 DEPLOY_SSH_REMOTE_SHELL "$DEPLOY_SSH_REMOTE_SHELL" + if [ -z "$DEPLOY_SSH_REMOTE_SHELL" ]; then + DEPLOY_SSH_REMOTE_SHELL="sh -c" + fi + _savedeployconf DEPLOY_SSH_REMOTE_SHELL "$DEPLOY_SSH_REMOTE_SHELL" + # BACKUP is optional. If not provided then default to previously saved value or yes. _migratedeployconf Le_Deploy_ssh_backup DEPLOY_SSH_BACKUP _getdeployconf DEPLOY_SSH_BACKUP @@ -428,7 +438,7 @@ _ssh_remote_cmd() { # quotations in bash cmd below intended. Squash travis spellcheck error # shellcheck disable=SC2029 - $_ssh_cmd "$DEPLOY_SSH_USER@$_host" sh -c "'$_cmd'" + $_ssh_cmd "$DEPLOY_SSH_USER@$_host" $DEPLOY_SSH_REMOTE_SHELL "'$_cmd'" _err_code="$?" if [ "$_err_code" != "0" ]; then From 6df4208e04054c9a2e773888ef1caafa15959e12 Mon Sep 17 00:00:00 2001 From: Roman Lumetsberger Date: Wed, 22 Nov 2023 12:14:53 +0000 Subject: [PATCH 2/3] allow to configure quoting of remote cmd string --- deploy/ssh.sh | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/deploy/ssh.sh b/deploy/ssh.sh index dbe84153..d13b0979 100644 --- a/deploy/ssh.sh +++ b/deploy/ssh.sh @@ -26,7 +26,7 @@ # export DEPLOY_SSH_USE_SCP="" yes or no, default to no # export DEPLOY_SSH_SCP_CMD="" defaults to "scp -q" # export DEPLOY_SSH_REMOTE_SHELL="" # defaults to sh -c -# +# export DEPLOY_SSH_REMOTE_CMD_QUOTE="" # yes or no, defaults to yes ######## Public functions ##################### #domain keyfile certfile cafile fullchain @@ -81,6 +81,16 @@ ssh_deploy() { fi _savedeployconf DEPLOY_SSH_REMOTE_SHELL "$DEPLOY_SSH_REMOTE_SHELL" + # REMOTE_CMD_QUOTE is optional. If not provided then yes + _migratedeployconf Le_Deploy_ssh_remote_cmd_quote DEPLOY_SSH_REMOTE_CMD_QUOTE + _getdeployconf DEPLOY_SSH_REMOTE_CMD_QUOTE + _debug2 DEPLOY_SSH_REMOTE_CMD_QUOTE "$DEPLOY_SSH_REMOTE_CMD_QUOTE" + if [ -z "$DEPLOY_SSH_REMOTE_CMD_QUOTE" ]; then + DEPLOY_SSH_REMOTE_CMD_QUOTE="yes" + fi + _savedeployconf DEPLOY_SSH_REMOTE_CMD_QUOTE "$DEPLOY_SSH_REMOTE_CMD_QUOTE" + + # BACKUP is optional. If not provided then default to previously saved value or yes. _migratedeployconf Le_Deploy_ssh_backup DEPLOY_SSH_BACKUP _getdeployconf DEPLOY_SSH_BACKUP @@ -436,9 +446,13 @@ _ssh_remote_cmd() { _secure_debug "Remote commands to execute: $_cmd" _info "Submitting sequence of commands to remote server by $_ssh_cmd" - # quotations in bash cmd below intended. Squash travis spellcheck error - # shellcheck disable=SC2029 - $_ssh_cmd "$DEPLOY_SSH_USER@$_host" $DEPLOY_SSH_REMOTE_SHELL "'$_cmd'" + if [ "$DEPLOY_SSH_REMOTE_CMD_QUOTE" = "yes" ]; then + # quotations in bash cmd below intended. Squash travis spellcheck error + # shellcheck disable=SC2029 + $_ssh_cmd "$DEPLOY_SSH_USER@$_host" $DEPLOY_SSH_REMOTE_SHELL "'$_cmd'" + else + $_ssh_cmd "$DEPLOY_SSH_USER@$_host" $DEPLOY_SSH_REMOTE_SHELL "$_cmd" + fi _err_code="$?" if [ "$_err_code" != "0" ]; then From ca74e63d875c9765a83f7a59910a2c26648ec710 Mon Sep 17 00:00:00 2001 From: Roman Lumetsberger Date: Wed, 22 Nov 2023 12:44:47 +0000 Subject: [PATCH 3/3] shell check and shellfmt fixes --- deploy/ssh.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/deploy/ssh.sh b/deploy/ssh.sh index d13b0979..d64340e2 100644 --- a/deploy/ssh.sh +++ b/deploy/ssh.sh @@ -90,7 +90,6 @@ ssh_deploy() { fi _savedeployconf DEPLOY_SSH_REMOTE_CMD_QUOTE "$DEPLOY_SSH_REMOTE_CMD_QUOTE" - # BACKUP is optional. If not provided then default to previously saved value or yes. _migratedeployconf Le_Deploy_ssh_backup DEPLOY_SSH_BACKUP _getdeployconf DEPLOY_SSH_BACKUP @@ -449,9 +448,9 @@ _ssh_remote_cmd() { if [ "$DEPLOY_SSH_REMOTE_CMD_QUOTE" = "yes" ]; then # quotations in bash cmd below intended. Squash travis spellcheck error # shellcheck disable=SC2029 - $_ssh_cmd "$DEPLOY_SSH_USER@$_host" $DEPLOY_SSH_REMOTE_SHELL "'$_cmd'" + $_ssh_cmd "$DEPLOY_SSH_USER@$_host" "$DEPLOY_SSH_REMOTE_SHELL" "'$_cmd'" else - $_ssh_cmd "$DEPLOY_SSH_USER@$_host" $DEPLOY_SSH_REMOTE_SHELL "$_cmd" + $_ssh_cmd "$DEPLOY_SSH_USER@$_host" "$DEPLOY_SSH_REMOTE_SHELL" "$_cmd" fi _err_code="$?"