Make error messages more clear

This commit is contained in:
Ivan Ilves 2018-11-17 01:26:08 +01:00
parent 5d0c3e6d35
commit 5c0ff25c35
2 changed files with 16 additions and 2 deletions

View File

@ -2,7 +2,7 @@
# #
# Bootstrap sudoers.d config on server side before doing anything else! # Bootstrap sudoers.d config on server side before doing anything else!
# #
set -e set -eo pipefail
if [[ ${#} -lt 1 ]]; then if [[ ${#} -lt 1 ]]; then
echo "Usage: ${0} [OPTIONS] [SSH_USER@]SSH_SERVER" echo "Usage: ${0} [OPTIONS] [SSH_USER@]SSH_SERVER"
@ -17,4 +17,4 @@ declare -r STDOUTERR=/tmp/xiringuito.$(basename ${0}).${USER}
ssh -t -oStrictHostKeyChecking=no ${@} \ ssh -t -oStrictHostKeyChecking=no ${@} \
"sudo true && sudo bash -c \ "sudo true && sudo bash -c \
\"umask 0337 && echo -e ${SUDO_NOTE}'\n'\${USER} ${SUDO_CONF} | tee ${BASE_NAME}-\${USER}\" >/dev/null" \ \"umask 0337 && echo -e ${SUDO_NOTE}'\n'\${USER} ${SUDO_CONF} | tee ${BASE_NAME}-\${USER}\" >/dev/null" \
&>${STDOUTERR} &>${STDOUTERR} || (cat ${STDOUTERR} >>/dev/stderr && exit 1)

14
xaval
View File

@ -271,6 +271,8 @@ function wait_connection(){
local WAIT_TIME=0 local WAIT_TIME=0
while [[ "$(get_profile_status ${PROFILE})" != "UP" ]]; do while [[ "$(get_profile_status ${PROFILE})" != "UP" ]]; do
if [[ ${WAIT_TIME} -ge ${WAIT_TIMEOUT} ]]; then if [[ ${WAIT_TIME} -ge ${WAIT_TIMEOUT} ]]; then
dump_profile_log ${PROFILE}
commit_suicide "Unable to bring up \"${PROFILE}\" after ${WAIT_TIMEOUT} seconds" commit_suicide "Unable to bring up \"${PROFILE}\" after ${WAIT_TIMEOUT} seconds"
fi fi
@ -303,6 +305,18 @@ function logs_profile() {
echo "STATUS: $(get_profile_status ${PROFILE})" echo "STATUS: $(get_profile_status ${PROFILE})"
} }
function dump_profile_log() {
local PROFILE=${1}
suicide_on_absent_profile ${PROFILE}
local LOG_FILE=${LOG_DIR}/${PROFILE}
echo "--- LOG ---" >>/dev/stderr
cat ${LOG_FILE} >>/dev/stderr
echo "--- LOG ---" >>/dev/stderr
}
function rename_profile(){ function rename_profile(){
local OLD_PROFILE=${1} local OLD_PROFILE=${1}
local NEW_PROFILE=${2} local NEW_PROFILE=${2}