Commit 43810cf5 authored by Erik Alexandre Pucci's avatar Erik Alexandre Pucci

collect/integrity-checker.sh: Improve $PREFIX and add redirection to log

Signed-off-by: 's avatarErik Alexandre Pucci <eap08@c3sl.ufpr.br>
parent 0c9d0e1b
......@@ -26,7 +26,7 @@
# 0 - Success
# 1 - Error: could not restore files nor force update
PREFIX="$(dirname $0)"
PREFIX="$(dirname $(readlink -f $0))"
PREFIXESC="$(echo ${PREFIX} | sed "s/\./\\\./g")"
MD5DIR="${PREFIX}/.md5sum"
......@@ -35,6 +35,8 @@ MD5DIRESC="$(echo ${MD5DIR} | sed "s/\./\\\./g")"
BACKUPNAME=".backup"
BACKUPDIR="${PREFIX}/${BACKUPNAME}"
LOGFILE=${PREFIX}/log/collect.log
# ------------------------------------------------------------------------------
# Try to restore corrupted file
restore_backup(){
......@@ -155,6 +157,8 @@ update_myself(){
}
# ------------------------------------------------------------------------------
exec >> ${LOGFILE} 2>&1
date +"%F %T - Start of integrity checker execution."
# First, check if some update went wrong
......@@ -167,8 +171,9 @@ else
for FILE in $(find "${MD5DIR}" -type f); do
check_file_integrity ${FILE} ||
((try_force_update || update_myself) && exit 0) ||
(printf "ERROR: Could not restore files nor update the agent.\n"
&& exit 1)
(printf \
"ERROR: Could not restore files nor update the agent.\n" &&
exit 1)
done
fi
......
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