Add IN_PROGRESS canary file to groomer scripts

pull/58/head
Dan Puttick 2017-08-10 17:28:28 -04:00
parent 6845f2b607
commit c6e5caa2bd
3 changed files with 14 additions and 8 deletions

View File

@ -0,0 +1 @@
NOTE: This file is copied to the destination key when CIRCLean starts, and deleted once it completes successfully. If you see this file on your destination key it means that the copying process was INTERRUPTED or an ERROR occurred. You should treat files on the source key and destination key with care, and consider repeating the sanitization process. If you think you have found a bug, please report it at https://github.com/CIRCL/Circlean.

View File

@ -56,20 +56,20 @@ run_groomer() {
echo "GROOMER: ${partition} mounted at /media/${SRC}"
# Put the filenames from the current partition in a logfile
find "/media/${SRC}" -fls "${LOGS_DIR}/contents_partition_${partcount}.txt"
# find "/media/${SRC}" -fls "${LOGS_DIR}/contents_partition_${partcount}.txt"
# Create a directory on ${DST} named PARTION_$PARTCOUNT
local target_dir="/media/${DST}/FROM_PARTITION_${partcount}"
mkdir -p "${target_dir}"
local logfile="${LOGS_DIR}/processing_log.txt"
# local logfile="${LOGS_DIR}/processing_log.txt"
# Run the current partition through filecheck.py
echo "==== Starting processing of /media/${SRC} to ${target_dir}. ====" >> "${logfile}"
# echo "==== Starting processing of /media/${SRC} to ${target_dir}. ====" >> "${logfile}"
filecheck.py --source /media/"${SRC}" --destination "${target_dir}" || true
echo "==== Done with /media/${SRC} to ${target_dir}. ====" >> "${logfile}"
# echo "==== Done with /media/${SRC} to ${target_dir}. ====" >> "${logfile}"
# List destination files (recursively) for debugging
ls -lR "${target_dir}"
# ls -lR "${target_dir}"
else
# Previous command (mounting current partition) failed
echo "GROOMER: Unable to mount ${partition} on /media/${SRC}"
@ -78,7 +78,6 @@ run_groomer() {
done
}
main() {
set -eu # exit when a line returns non-0 status, treat unset variables as errors
trap clean EXIT TERM INT # run clean when the script ends or is interrupted

View File

@ -7,6 +7,7 @@ clean(){
cp "${DEBUG_LOG}" "${DST_MNT}/groomer_debug_log.txt"
fi
echo "GROOMER: Cleaning up in mount_keys.sh."
rm -rf "/media/${DST}/IN_PROGRESS"*
${SYNC} # Write anything in memory to disk
# Unmount source and destination
pumount "${SRC}"
@ -50,7 +51,11 @@ mount_dest_partition() {
fi
}
prepare_dest_partition() {
copy_in_progress_file() {
cp "/opt/groomer/IN_PROGRESS" "/media/${DST}/IN_PROGRESS"
}
prepare_dest_key() {
rm -rf "/media/${DST}/FROM_PARTITION_"* # Remove any existing "FROM_PARTITION_" directories
# Prepare temp dirs and make sure they're empty if they already exist
mkdir -p "${TEMP}"
@ -70,7 +75,8 @@ main() {
check_source_exists
check_dest_exists
unmount_dest_if_mounted
mount_dest_partition
mount_dest_key
copy_in_progress_file
prepare_dest_partition
./groomer.sh
}