From c01482a8b1a31f87d011c3595ac22620af017719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 29 Oct 2013 15:48:21 +0100 Subject: [PATCH] Increase reliability of the copy. * Continue if a copy fails * Assume the filenames are in UTF-8 --- fs/home/kitten/kitten_mount_dst | 2 +- fs/home/kitten/kitten_mount_src | 2 +- fs/opt/groomer/functions.sh | 31 ++++++++++++++++--------------- fs/opt/groomer/groomer.sh | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/fs/home/kitten/kitten_mount_dst b/fs/home/kitten/kitten_mount_dst index ebf44e0..19c7663 100755 --- a/fs/home/kitten/kitten_mount_dst +++ b/fs/home/kitten/kitten_mount_dst @@ -12,7 +12,7 @@ if [ $# -eq 3 ]; then # uid= only works on a vfat FS. What should we do if we get an ext* FS ? # the main problem is that we need the rw rights on the dest key. # It is not possible to ensure it on a non-vfat USB key. - mount -t vfat -o user,noexec,nosuid,nodev,rw,uid="${1}" "${2}" "${3}" + mount -t vfat -o user,noexec,nosuid,nodev,rw,uid="${1}",utf8=1 "${2}" "${3}" exit 0 else echo 'Invalid number of arguments.' diff --git a/fs/home/kitten/kitten_mount_src b/fs/home/kitten/kitten_mount_src index 26b7180..1721084 100755 --- a/fs/home/kitten/kitten_mount_src +++ b/fs/home/kitten/kitten_mount_src @@ -4,7 +4,7 @@ set -e #set -x if [ $# -eq 2 ]; then - mount -o noexec,nosuid,nodev "${1}" "${2}" + mount -o noexec,nosuid,nodev,utf8=1 "${1}" "${2}" # renaming autorun.inf on the source key. As it it case insensitive, we have to do the following... ls "${2}" | grep -i autorun.inf | xargs -I {} mv "${2}"/{} "${2}"/DANGEROUS_{}_DANGEROUS || true mount -o remount,ro "${1}" "${2}" diff --git a/fs/opt/groomer/functions.sh b/fs/opt/groomer/functions.sh index 677a59c..d90933a 100755 --- a/fs/opt/groomer/functions.sh +++ b/fs/opt/groomer/functions.sh @@ -1,7 +1,5 @@ #!/bin/bash -set -e -#set -x source ./constraint.sh source ./constraint_conv.sh @@ -14,9 +12,9 @@ LOGFILE="${LOGS}/processing.txt" # Something went wrong. error_handler(){ echo "FAILED." >> ${LOGFILE} - echo "Something went wrong during the duplication of the last file." >> ${LOGFILE} - echo "Please open a bug on https://www.github.com/Rafiot/KittenGroomer" >> ${LOGFILE} - + echo -e "\tSomething went wrong during the duplication of the last file." >> ${LOGFILE} + echo -e "\tPlease open a bug on https://www.github.com/Rafiot/KittenGroomer" >> ${LOGFILE} + continue } trap error_handler ERR TERM INT @@ -143,6 +141,8 @@ main(){ echo "Please specify the destination directory." exit fi + set -e + set -x if [ -z ${2} ]; then CURRENT_SRC=${SRC} @@ -177,31 +177,32 @@ main(){ echo -n "Processing ${file} (${mime})... " >> ${LOGFILE} case "${main_mime}" in "text") - text ${file} ${dest} + + text ${file} ${dest} || error_handler ;; "audio") - audio ${file} ${dest} + audio ${file} ${dest} || error_handler ;; "image") - image ${file} ${dest} + image ${file} ${dest} || error_handler ;; "video") - video ${file} ${dest} + video ${file} ${dest} || error_handler ;; "application") - application ${file} ${dest} ${details} + application ${file} ${dest} ${details} || error_handler ;; "example") - example ${file} ${dest} + example ${file} ${dest} || error_handler ;; "message") - message ${file} ${dest} + message ${file} ${dest} || error_handler ;; "model") - model ${file} ${dest} + model ${file} ${dest} || error_handler ;; "multipart") - multipart ${file} ${dest} + multipart ${file} ${dest} || error_handler ;; *) echo "This should never happen... :]" @@ -211,7 +212,7 @@ main(){ echo "done." >> ${LOGFILE} done IFS=$SAVEIFS + return 0 } -echo "Copy finished successfully." >> ${LOGFILE} diff --git a/fs/opt/groomer/groomer.sh b/fs/opt/groomer/groomer.sh index 026a44e..c0bcd80 100755 --- a/fs/opt/groomer/groomer.sh +++ b/fs/opt/groomer/groomer.sh @@ -106,7 +106,7 @@ do LOGFILE="${LOGS}/processing.txt" echo "==== Starting processing of ${SRC} to ${target_dir}. ====" >> ${LOGFILE} - main ${target_dir} + main ${target_dir} || true echo "==== Done with ${SRC} to ${target_dir}. ====" >> ${LOGFILE} ls -lR "${target_dir}"