From 8c157441c5f76a1af3a9ac577a44ba365f306a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sun, 9 Jun 2013 19:37:41 +0200 Subject: [PATCH] Add logging, better error handling. --- fs/opt/groomer/functions.sh | 17 +++++++++++++++++ fs/opt/groomer/groomer.sh | 6 ++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/fs/opt/groomer/functions.sh b/fs/opt/groomer/functions.sh index 6849e06..5ed2ed7 100755 --- a/fs/opt/groomer/functions.sh +++ b/fs/opt/groomer/functions.sh @@ -9,6 +9,18 @@ source ./constraint_conv.sh RECURSIVE_ARCHIVE_MAX=3 RECURSIVE_ARCHIVE_CURRENT=0 ARCHIVE_BOMB=0 +LOGFILE="${LOGS}/processing" + +# Something went wrong. +error_handler(){ + echo "FAILED." >> ${LOGFILE} + echo "Something went wrong during the duplication." >> ${LOGFILE} + echo "Please open a bug on https://www.github.com/Rafiot/KittenGroomer" >> ${LOGFILE} + + exit +} + +trap error_handler INT copy(){ src_file=${1} @@ -143,6 +155,9 @@ main(){ if [ ${RECURSIVE_ARCHIVE_CURRENT} -gt ${RECURSIVE_ARCHIVE_MAX} ]; then echo Archive bomb. ARCHIVE_BOMB=1 + echo "ARCHIVE BOMB." >> ${LOGFILE} + echo "The content of the archive contains recursively other archives." >> ${LOGFILE} + echo "This is a bad sign so the archive is not extracted to the destination key." >> ${LOGFILE} return else RECURSIVE_ARCHIVE_CURRENT=`expr ${RECURSIVE_ARCHIVE_CURRENT} + 1` @@ -160,6 +175,7 @@ main(){ echo ${mime} main_mime=`echo ${mime} | cut -f1 -d/` details=`echo ${mime} | cut -f2 -d/` + echo -n "Processing ${file} (${mime})... " >> ${LOGFILE} case "${main_mime}" in "text") text ${file} ${dest} @@ -193,6 +209,7 @@ main(){ echo $mime $main_mime $details ;; esac + echo "done." >> ${LOGFILE} done IFS=$SAVEIFS } diff --git a/fs/opt/groomer/groomer.sh b/fs/opt/groomer/groomer.sh index 32a8d50..99af3e5 100755 --- a/fs/opt/groomer/groomer.sh +++ b/fs/opt/groomer/groomer.sh @@ -81,7 +81,6 @@ fi # Groom da kitteh! -COPYDIRTYPDF=0 PARTCOUNT=1 for partition in ${DEV_PARTITIONS} do @@ -98,14 +97,17 @@ do echo "${partition} mounted at ${SRC}" # Print the filenames on the current partition in a logfile - find "${SRC}" -fls "${LOGS}/${PARTCOUNT}" + find "${SRC}" -fls "${LOGS}/Content_partition_${PARTCOUNT}" # create a directory on ${DST} named PARTION_$PARTCOUNT target_dir="${DST}/FROM_PARTITION_${PARTCOUNT}" echo "copying to: ${target_dir}" mkdir -p "${target_dir}" + LOGFILE="${LOGS}/processing" + echo "==== Starting processing of ${SRC} to ${target_dir}. ====" >> ${LOGFILE} main ${target_dir} + echo "==== Done with ${SRC} to ${target_dir}. ====" >> ${LOGFILE} ls -lR "${target_dir}" fi