mirror of https://github.com/CIRCL/Circlean
Add IN_PROGRESS canary file to groomer scripts
parent
6845f2b607
commit
c6e5caa2bd
|
@ -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.
|
|
@ -56,20 +56,20 @@ run_groomer() {
|
||||||
echo "GROOMER: ${partition} mounted at /media/${SRC}"
|
echo "GROOMER: ${partition} mounted at /media/${SRC}"
|
||||||
|
|
||||||
# Put the filenames from the current partition in a logfile
|
# 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
|
# Create a directory on ${DST} named PARTION_$PARTCOUNT
|
||||||
local target_dir="/media/${DST}/FROM_PARTITION_${partcount}"
|
local target_dir="/media/${DST}/FROM_PARTITION_${partcount}"
|
||||||
mkdir -p "${target_dir}"
|
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
|
# 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
|
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
|
# List destination files (recursively) for debugging
|
||||||
ls -lR "${target_dir}"
|
# ls -lR "${target_dir}"
|
||||||
else
|
else
|
||||||
# Previous command (mounting current partition) failed
|
# Previous command (mounting current partition) failed
|
||||||
echo "GROOMER: Unable to mount ${partition} on /media/${SRC}"
|
echo "GROOMER: Unable to mount ${partition} on /media/${SRC}"
|
||||||
|
@ -78,7 +78,6 @@ run_groomer() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
set -eu # exit when a line returns non-0 status, treat unset variables as errors
|
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
|
trap clean EXIT TERM INT # run clean when the script ends or is interrupted
|
||||||
|
|
|
@ -7,6 +7,7 @@ clean(){
|
||||||
cp "${DEBUG_LOG}" "${DST_MNT}/groomer_debug_log.txt"
|
cp "${DEBUG_LOG}" "${DST_MNT}/groomer_debug_log.txt"
|
||||||
fi
|
fi
|
||||||
echo "GROOMER: Cleaning up in mount_keys.sh."
|
echo "GROOMER: Cleaning up in mount_keys.sh."
|
||||||
|
rm -rf "/media/${DST}/IN_PROGRESS"*
|
||||||
${SYNC} # Write anything in memory to disk
|
${SYNC} # Write anything in memory to disk
|
||||||
# Unmount source and destination
|
# Unmount source and destination
|
||||||
pumount "${SRC}"
|
pumount "${SRC}"
|
||||||
|
@ -50,7 +51,11 @@ mount_dest_partition() {
|
||||||
fi
|
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
|
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
|
# Prepare temp dirs and make sure they're empty if they already exist
|
||||||
mkdir -p "${TEMP}"
|
mkdir -p "${TEMP}"
|
||||||
|
@ -70,7 +75,8 @@ main() {
|
||||||
check_source_exists
|
check_source_exists
|
||||||
check_dest_exists
|
check_dest_exists
|
||||||
unmount_dest_if_mounted
|
unmount_dest_if_mounted
|
||||||
mount_dest_partition
|
mount_dest_key
|
||||||
|
copy_in_progress_file
|
||||||
prepare_dest_partition
|
prepare_dest_partition
|
||||||
./groomer.sh
|
./groomer.sh
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue