Skip to content

Commit be1e551

Browse files
authored
Merge pull request #676 from atisne/feat-debug_remote_cmd
Do not redirect outputs on remote commands when the debug option is used
2 parents 9cf1897 + 32f56a9 commit be1e551

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

getssl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
# 2021-02-18 Add FULL_CHAIN_INCLUDE_ROOT
261261
# 2021-03-25 Fix DNS challenge completion check if CNAMEs on different NS are used (sideeffect42)(2.35)
262262
# 2021-05-08 Merge from tlhackque/getssl: GoDaddy, split-view, tempfile permissions fixes, --version(2.36)
263+
# 2021-07-12 Do not redirect outputs on remote commands when the debug option is used (atisne)
263264
# ----------------------------------------------------------------------------------------
264265

265266
case :$SHELLOPTS: in
@@ -329,6 +330,7 @@ _MUTE=0
329330
_NOTIFY_VALID=0
330331
_QUIET=0
331332
_RECREATE_CSR=0
333+
_REDIRECT_OUTPUT="1>/dev/null 2>&1"
332334
_REVOKE=0
333335
_RUNNING_TEST=0
334336
_TEST_SKIP_CNAME_CALL=0
@@ -1365,10 +1367,10 @@ for d in "${alldomains[@]}"; do
13651367
if [[ "${t_loc:0:4}" == "ssh:" ]] ; then
13661368
sshhost=$(echo "${t_loc}"| awk -F: '{print $2}')
13671369
command="rm -f ${t_loc:(( ${#sshhost} + 5))}/${token:?}"
1368-
debug "running following command to remove token"
1369-
debug "ssh $SSH_OPTS $sshhost ${command}"
1370+
debug "running following command to remove token:"
1371+
debug "ssh $SSH_OPTS $sshhost ${command} $_REDIRECT_OUTPUT"
13701372
# shellcheck disable=SC2029 disable=SC2086
1371-
ssh $SSH_OPTS "$sshhost" "${command}" 1>/dev/null 2>&1
1373+
ssh $SSH_OPTS "$sshhost" "${command}" $_REDIRECT_OUTPUT
13721374
rm -f "${TEMP_DIR:?}/${token:?}"
13731375
elif [[ "${t_loc:0:4}" == "ftp:" ]] ; then
13741376
debug "using ftp to remove token file"
@@ -2101,10 +2103,10 @@ reload_service() { # Runs a command to reload services ( via ssh if needed)
21012103
sshhost=$(echo "$ARELOAD_CMD"| awk -F: '{print $2}')
21022104
command=${ARELOAD_CMD:(( ${#sshhost} + 5))}
21032105
debug "running following command to reload cert:"
2104-
debug "ssh $SSH_OPTS $sshhost ${command}"
2106+
debug "ssh $SSH_OPTS $sshhost ${command} $_REDIRECT_OUTPUT"
21052107
# shellcheck disable=SC2029
21062108
# shellcheck disable=SC2086
2107-
ssh $SSH_OPTS "$sshhost" "${command}" 1>/dev/null 2>&1
2109+
ssh $SSH_OPTS "$sshhost" "${command}" $_REDIRECT_OUTPUT
21082110
# allow 2 seconds for services to restart
21092111
sleep 2
21102112
else
@@ -2651,6 +2653,11 @@ while [[ -n ${1+defined} ]]; do
26512653
shift
26522654
done
26532655

2656+
if [[ ${_USE_DEBUG} -eq 1 ]]; then
2657+
# Do not hide outputs when debug mode is on
2658+
_REDIRECT_OUTPUT=""
2659+
fi
2660+
26542661
# Main logic
26552662
############
26562663

0 commit comments

Comments
 (0)