diff --git a/circlean_fs/root_partition/opt/groomer/config.sh b/circlean_fs/root_partition/opt/groomer/config.sh index d172c5f..dc862d4 100755 --- a/circlean_fs/root_partition/opt/groomer/config.sh +++ b/circlean_fs/root_partition/opt/groomer/config.sh @@ -6,11 +6,9 @@ readonly USERNAME="kitten" readonly ID=$(/usr/bin/id -u) # Paths used in multiple scripts -readonly SRC="src" readonly DEV_SRC="/dev/source_key" readonly SRC_MNT="/media/src" -readonly DST="dst" readonly DEV_DST="/dev/dest_key" readonly DST_MNT="/media/dst" diff --git a/circlean_fs/root_partition/opt/groomer/groomer.sh b/circlean_fs/root_partition/opt/groomer/groomer.sh index 6fb817d..922660d 100755 --- a/circlean_fs/root_partition/opt/groomer/groomer.sh +++ b/circlean_fs/root_partition/opt/groomer/groomer.sh @@ -29,8 +29,8 @@ check_partitions_not_empty () { unmount_source_partition() { # Unmount anything that is mounted on /media/src - if [ "$(${MOUNT} | grep -c "${SRC}")" -ne 0 ]; then - ${PUMOUNT} "${SRC}" + if [ "$(${MOUNT} | grep -c "${SRC_MNT}")" -ne 0 ]; then + ${PUMOUNT} "${SRC_MNT}" fi } @@ -46,27 +46,27 @@ run_groomer() { echo "GROOMER: Processing partition ${partition}" unmount_source_partition # 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 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 - ${PUMOUNT} "${SRC}" + ${PUMOUNT} "${SRC_MNT}" - if ${PMOUNT} -r "${partition}" "${SRC}"; then - echo "GROOMER: ${partition} mounted at /media/${SRC}" + if ${PMOUNT} -r "${partition}" "${SRC_MNT}"; then + echo "GROOMER: ${partition} mounted at ${SRC_MNT}" # Put the filenames from the current partition in a logfile # 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}" + # Create a directory on ${DST_MNT} named PARTION_$PARTCOUNT + local target_dir="${DST_MNT}/FROM_PARTITION_${partcount}" mkdir -p "${target_dir}" # local logfile="${LOGS_DIR}/processing_log.txt" # Run the current partition through filecheck.py - # 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 "==== Starting processing of ${SRC_MNT} to ${target_dir}. ====" >> "${logfile}" + filecheck.py --source "${SRC_MNT}" --destination "${target_dir}" || true + # echo "==== Done with ${SRC_MNT} to ${target_dir}. ====" >> "${logfile}" # List destination files (recursively) for debugging if [ "${DEBUG}" = true ]; then @@ -74,7 +74,7 @@ run_groomer() { fi else # 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 let partcount=$((partcount + 1)) done diff --git a/circlean_fs/root_partition/opt/groomer/mount_dest.sh b/circlean_fs/root_partition/opt/groomer/mount_dest.sh index 9fba305..3daa2f1 100755 --- a/circlean_fs/root_partition/opt/groomer/mount_dest.sh +++ b/circlean_fs/root_partition/opt/groomer/mount_dest.sh @@ -7,11 +7,11 @@ 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"* + rm -rf "${DST_MNT}/IN_PROGRESS"* ${SYNC} # Write anything in memory to disk # Unmount source and destination - pumount "${SRC}" - pumount "${DST}" + pumount "${SRC_MNT}" + pumount "${DST_MNT}" exit } @@ -37,13 +37,13 @@ check_dest_exists() { } unmount_dest_if_mounted() { - if ${MOUNT}|grep "${DST}"; then - ${PUMOUNT} "${DST}" || true + if ${MOUNT}|grep "${DST_MNT}"; then + ${PUMOUNT} "${DST_MNT}" || true fi } 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}" else echo "GROOMER: Unable to mount ${DEV_DST}1 on ${DST_MNT}" @@ -52,11 +52,11 @@ mount_dest_partition() { } 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() { - rm -rf "/media/${DST}/FROM_PARTITION_"* # Remove any existing "FROM_PARTITION_" directories +prepare_dest_partition() { + 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 mkdir -p "${TEMP}" mkdir -p "${LOGS}" @@ -75,7 +75,7 @@ main() { check_source_exists check_dest_exists unmount_dest_if_mounted - mount_dest_key + mount_dest_partition copy_in_progress_file prepare_dest_partition ./groomer.sh