diff --git a/files/home/hpf-ans/bin/ansible-pull.sh b/files/home/hpf-ans/bin/ansible-pull.sh index c6d519c..0c31f8d 100644 --- a/files/home/hpf-ans/bin/ansible-pull.sh +++ b/files/home/hpf-ans/bin/ansible-pull.sh @@ -54,21 +54,20 @@ GIT_REPO_BASE="https://gitea.admin-a.hpetersenfamily.com/heath/ansible" GIT_REPO="${GIT_REPO_BASE}.git" # - Include ansible virtual environment (in case not already done - we don't know how we're being run) -VIRTUAL_ENV_DISABLE_PROMPT=true . "${VENV_ACTIVATE_SCRIPT}" # - If we can't get a lock, don't proceed if ! exec 9>"${LOCK_FILE}" ; then - echo "${SCRIPT_NAME}: ERROR - Unable to open the lock file (${LOCK_FILE})! Exiting..." >&2 + echo "${SCRIPT_NAME}: ERROR - Unable to open the lock file (${LOCK_FILE})! Exiting..." >&2 exit 10 fi if ! flock -n 9 ; then - echo "${SCRIPT_NAME}: ERROR - Another copy is already running! Exiting..." >&2 + echo "${SCRIPT_NAME}: ERROR - Another copy is already running! Exiting..." >&2 exit 11 fi # - If debugging requested or running from a terminal . . . -if [ "${DEBUG_FLAG}" = "true" || test -t 1 ] ; then +if [ "${DEBUG_FLAG}" = "true" ] || test -t 0 ; then exec > >(tee -a "${LOG_FILE}") 2>&1 # - send STDOUT and STDERR to both STDOUT and the log file else exec >>"${LOG_FILE}" 2>&1 # - send STDOUT and STDERR to the log file only @@ -76,7 +75,7 @@ fi # - Log that we've gotten this far echo -echo "${SCRIPT_NAME}: $(date "+%Y-%m-%d %H:%M:%S") ----------------------------------------" +echo "${SCRIPT_NAME}: ------------------------------- $(date "+%Y-%m-%d %H:%M:%S") -------------------------------" # - Do our work ansible-pull ${OIC_FLAG} ${VERBOSE_FLAG} --url "${GIT_REPO}" --checkout "${GIT_REPO_BRANCH}" "${@}" \ No newline at end of file diff --git a/scraps/redirect_exec.sh b/scraps/redirect_exec.sh new file mode 100755 index 0000000..6f193cd --- /dev/null +++ b/scraps/redirect_exec.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +send_some_output() { + echo "hello" + echo "here" + echo "goodbye" +} + +exec > >(tee -a ./x.out) 2>&1 + +send_some_output >&2