buildpackage: The date of the previous agent inventory's send is kept.

The file "tmp/lastExec.tmp" of the previously agent installed is kept
and restored after the instalation of the new agent. This prevent
that the agent sends the inventory more than once per day.
Signed-off-by: default avatarEdileuton Henrique de Oliveira <eho09@c3sl.ufpr.br>
parent eb598762
......@@ -148,11 +148,17 @@ else
SEED_MEC_HOME="/opt/seed_mec"
fi
AGENT_DIR="${SEED_MEC_HOME}/SEED2"
LASTEXEC="${AGENT_DIR}/tmp/lastExec.tmp"
LOGFILE=/tmp/collected-information.log
# Save stdout to file descriptor 3 and redirect all output to $LOGFILE
exec 3>&1 &> ${LOGFILE}
# Check if lastExec.tmp exist then save its content to prevent that
# agent send a inventory more than once per day
if test -f ${LASTEXEC}; then
LASTEXECBACKUP=$(cat ${LASTEXEC})
fi
# Remove any previous installation of the agent
rm -rf "${AGENT_DIR}"
/usr/sbin/userdel -r seed_mec
......@@ -236,6 +242,11 @@ fi
# Export a variable to inform the agent that this is its first execution
export FIRST_EXECUTION=1
# Restore lastExec.tmp
if ! test -z ${LASTEXECBACKUP};then
echo ${LASTEXECBACKUP} > ${LASTEXEC}
fi
# Run the agent and check if its execution was alright, exiting in case of error
if ! su -c "bash ${AGENT_DIR}/agent.sh" seed_mec; then
printf "ERRO: Falha na execução do novo agente.\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment