mirror of https://github.com/CIRCL/Circlean
Fix issue with $SRC+$DST and $SRC_MNT+$DST_MNT
parent
650ad783d7
commit
ab9c9eb309
|
@ -6,11 +6,9 @@ readonly USERNAME="kitten"
|
||||||
readonly ID=$(/usr/bin/id -u)
|
readonly ID=$(/usr/bin/id -u)
|
||||||
|
|
||||||
# Paths used in multiple scripts
|
# Paths used in multiple scripts
|
||||||
readonly SRC="src"
|
|
||||||
readonly DEV_SRC="/dev/source_key"
|
readonly DEV_SRC="/dev/source_key"
|
||||||
readonly SRC_MNT="/media/src"
|
readonly SRC_MNT="/media/src"
|
||||||
|
|
||||||
readonly DST="dst"
|
|
||||||
readonly DEV_DST="/dev/dest_key"
|
readonly DEV_DST="/dev/dest_key"
|
||||||
readonly DST_MNT="/media/dst"
|
readonly DST_MNT="/media/dst"
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ check_partitions_not_empty () {
|
||||||
|
|
||||||
unmount_source_partition() {
|
unmount_source_partition() {
|
||||||
# Unmount anything that is mounted on /media/src
|
# Unmount anything that is mounted on /media/src
|
||||||
if [ "$(${MOUNT} | grep -c "${SRC}")" -ne 0 ]; then
|
if [ "$(${MOUNT} | grep -c "${SRC_MNT}")" -ne 0 ]; then
|
||||||
${PUMOUNT} "${SRC}"
|
${PUMOUNT} "${SRC_MNT}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,27 +46,27 @@ run_groomer() {
|
||||||
echo "GROOMER: Processing partition ${partition}"
|
echo "GROOMER: Processing partition ${partition}"
|
||||||
unmount_source_partition
|
unmount_source_partition
|
||||||
# Mount the current partition in write mode
|
# Mount the current partition in write mode
|
||||||
${PMOUNT} -w ${partition} "${SRC}"
|
${PMOUNT} -w ${partition} "${SRC_MNT}"
|
||||||
# Mark any autorun.inf files as dangerous on the source device to be extra careful
|
# Mark any autorun.inf files as dangerous on the source device to be extra careful
|
||||||
ls "${SRC_MNT}" | grep -i autorun.inf | xargs -I {} mv "${SRC_MNT}"/{} "{SRC_MNT}"/DANGEROUS_{}_DANGEROUS || true
|
ls "${SRC_MNT}" | grep -i autorun.inf | xargs -I {} mv "${SRC_MNT}"/{} "{SRC_MNT}"/DANGEROUS_{}_DANGEROUS || true
|
||||||
# Unmount and remount the current partition in read-only mode
|
# Unmount and remount the current partition in read-only mode
|
||||||
${PUMOUNT} "${SRC}"
|
${PUMOUNT} "${SRC_MNT}"
|
||||||
|
|
||||||
if ${PMOUNT} -r "${partition}" "${SRC}"; then
|
if ${PMOUNT} -r "${partition}" "${SRC_MNT}"; then
|
||||||
echo "GROOMER: ${partition} mounted at /media/${SRC}"
|
echo "GROOMER: ${partition} mounted at ${SRC_MNT}"
|
||||||
|
|
||||||
# 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_MNT} named PARTION_$PARTCOUNT
|
||||||
local target_dir="/media/${DST}/FROM_PARTITION_${partcount}"
|
local target_dir="${DST_MNT}/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 ${SRC_MNT} to ${target_dir}. ====" >> "${logfile}"
|
||||||
filecheck.py --source /media/"${SRC}" --destination "${target_dir}" || true
|
filecheck.py --source "${SRC_MNT}" --destination "${target_dir}" || true
|
||||||
# echo "==== Done with /media/${SRC} to ${target_dir}. ====" >> "${logfile}"
|
# echo "==== Done with ${SRC_MNT} to ${target_dir}. ====" >> "${logfile}"
|
||||||
|
|
||||||
# List destination files (recursively) for debugging
|
# List destination files (recursively) for debugging
|
||||||
if [ "${DEBUG}" = true ]; then
|
if [ "${DEBUG}" = true ]; then
|
||||||
|
@ -74,7 +74,7 @@ run_groomer() {
|
||||||
fi
|
fi
|
||||||
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 ${SRC_MNT}"
|
||||||
fi
|
fi
|
||||||
let partcount=$((partcount + 1))
|
let partcount=$((partcount + 1))
|
||||||
done
|
done
|
||||||
|
|
|
@ -7,11 +7,11 @@ 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"*
|
rm -rf "${DST_MNT}/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_MNT}"
|
||||||
pumount "${DST}"
|
pumount "${DST_MNT}"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,13 +37,13 @@ check_dest_exists() {
|
||||||
}
|
}
|
||||||
|
|
||||||
unmount_dest_if_mounted() {
|
unmount_dest_if_mounted() {
|
||||||
if ${MOUNT}|grep "${DST}"; then
|
if ${MOUNT}|grep "${DST_MNT}"; then
|
||||||
${PUMOUNT} "${DST}" || true
|
${PUMOUNT} "${DST_MNT}" || true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
mount_dest_partition() {
|
mount_dest_partition() {
|
||||||
if "${PMOUNT}" -w "${DEV_DST}1" "${DST}"; then # pmount automatically mounts on /media/ (at /media/dst in this case).
|
if "${PMOUNT}" -w "${DEV_DST}1" "${DST_MNT}"; then # pmount automatically mounts on /media/ (at /media/dst in this case).
|
||||||
echo "GROOMER: Destination USB device (${DEV_DST}1) mounted at ${DST_MNT}"
|
echo "GROOMER: Destination USB device (${DEV_DST}1) mounted at ${DST_MNT}"
|
||||||
else
|
else
|
||||||
echo "GROOMER: Unable to mount ${DEV_DST}1 on ${DST_MNT}"
|
echo "GROOMER: Unable to mount ${DEV_DST}1 on ${DST_MNT}"
|
||||||
|
@ -52,11 +52,11 @@ mount_dest_partition() {
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_in_progress_file() {
|
copy_in_progress_file() {
|
||||||
cp "/opt/groomer/IN_PROGRESS" "/media/${DST}/IN_PROGRESS"
|
cp "/opt/groomer/IN_PROGRESS" "${DST_MNT}/IN_PROGRESS"
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_dest_key() {
|
prepare_dest_partition() {
|
||||||
rm -rf "/media/${DST}/FROM_PARTITION_"* # Remove any existing "FROM_PARTITION_" directories
|
rm -rf "${DST_MNT}/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}"
|
||||||
mkdir -p "${LOGS}"
|
mkdir -p "${LOGS}"
|
||||||
|
@ -75,7 +75,7 @@ main() {
|
||||||
check_source_exists
|
check_source_exists
|
||||||
check_dest_exists
|
check_dest_exists
|
||||||
unmount_dest_if_mounted
|
unmount_dest_if_mounted
|
||||||
mount_dest_key
|
mount_dest_partition
|
||||||
copy_in_progress_file
|
copy_in_progress_file
|
||||||
prepare_dest_partition
|
prepare_dest_partition
|
||||||
./groomer.sh
|
./groomer.sh
|
||||||
|
|
Loading…
Reference in New Issue