From 03cae7967e5e88a5451f589958fcc9c5a3eeec2f Mon Sep 17 00:00:00 2001 From: Erik Alexandre Pucci <eap08@c3sl.ufpr.br> Date: Tue, 23 Aug 2011 17:26:04 -0300 Subject: [PATCH] agent.sh: Added $returnValue to check client errors during the agent update This allows the verification of no Internet connection error during the update process (as soon as the client isn't able to check the agent's version). Changed the test(1) outside checkUpdate() from "-eq 1" to "-ne 0". Changed test(1) inside checkUpdate() to return 0 if it's the first execution of the agent. Signed-off-by: Erik Alexandre Pucci <eap08@c3sl.ufpr.br> Signed-off-by: Josiney de Souza <josineys@c3sl.ufpr.br> --- agent.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/agent.sh b/agent.sh index a264e01..2cd3f60 100755 --- a/agent.sh +++ b/agent.sh @@ -50,8 +50,9 @@ function rotateLogFile() function checkUpdate() { updateLink="$(${CLIENT} --update)" + returnValue=$? - if test $? -eq 4; then + if test ${returnValue} -eq 4; then test -f "${TMPDIR}/SEED2-update.run" || rm -f ${TMPDIR}/SEED2-update.run tryWget ${updateLink} \ @@ -65,11 +66,11 @@ function checkUpdate() rm -f ${TMPDIR}/SEED2-update.run - # Return 4 only if this isn't the first execution of the agent - test "${FIRST_EXECUTION}" || return 4 + # Return 0 if this is the first execution of the agent + test "${FIRST_EXECUTION}" && return 0 fi - return 0 + return ${returnValue} } #------------------------------------------------------------------------------ @@ -149,7 +150,7 @@ updateStatus=$? test "${FIRST_EXECUTION}" && echo "${REALVERSION}" > "${VERSIONFILE}" test ${updateStatus} -eq 4 && exit 0 -if test ${updateStatus} -eq 1; then +if test ${updateStatus} -ne 0; then date +"%F %T - Error while updating agent." exit 3 fi -- GitLab