diff --git a/circlean_fs/root_partition/opt/groomer/config.sh b/circlean_fs/root_partition/opt/groomer/config.sh index dc862d4..64ba840 100755 --- a/circlean_fs/root_partition/opt/groomer/config.sh +++ b/circlean_fs/root_partition/opt/groomer/config.sh @@ -6,10 +6,10 @@ readonly USERNAME="kitten" readonly ID=$(/usr/bin/id -u) # Paths used in multiple scripts -readonly DEV_SRC="/dev/source_key" +readonly SRC_DEV="/dev/source_key" readonly SRC_MNT="/media/src" -readonly DEV_DST="/dev/dest_key" +readonly DST_DEV="/dev/dest_key" readonly DST_MNT="/media/dst" readonly TEMP="${DST_MNT}/temp" diff --git a/circlean_fs/root_partition/opt/groomer/groomer.sh b/circlean_fs/root_partition/opt/groomer/groomer.sh index 922660d..c7919d2 100755 --- a/circlean_fs/root_partition/opt/groomer/groomer.sh +++ b/circlean_fs/root_partition/opt/groomer/groomer.sh @@ -19,10 +19,10 @@ check_not_root() { fi } -check_partitions_not_empty () { +check_has_partitions () { local partitions=$1 if [ -z "${partitions}" ]; then - echo "GROOMER: ${DEV_SRC} does not have any partitions." + echo "GROOMER: ${SRC_DEV} does not have any partitions." exit fi } @@ -37,7 +37,7 @@ unmount_source_partition() { run_groomer() { local dev_partitions # Find the partition names on the device - let dev_partitions=$(ls "${DEV_SRC}"* | grep "${DEV_SRC}[1-9][0-6]*" || true) + dev_partitions=$(ls "${SRC_DEV}"* | grep "${SRC_DEV}[1-9][0-6]*" || true) check_has_partitions dev_partitions local partcount=1 local partition @@ -48,25 +48,19 @@ run_groomer() { # Mount the current partition in write mode ${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 + 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_MNT}" 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_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 ${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 diff --git a/circlean_fs/root_partition/opt/groomer/mount_dest.sh b/circlean_fs/root_partition/opt/groomer/mount_dest.sh index 3daa2f1..35ae0ca 100755 --- a/circlean_fs/root_partition/opt/groomer/mount_dest.sh +++ b/circlean_fs/root_partition/opt/groomer/mount_dest.sh @@ -7,7 +7,7 @@ clean(){ cp "${DEBUG_LOG}" "${DST_MNT}/groomer_debug_log.txt" fi echo "GROOMER: Cleaning up in mount_keys.sh." - rm -rf "${DST_MNT}/IN_PROGRESS"* + rm -rf "${DST_MNT}/IN_PROGRESS.txt"* ${SYNC} # Write anything in memory to disk # Unmount source and destination pumount "${SRC_MNT}" @@ -23,15 +23,15 @@ check_not_root() { } check_source_exists() { - if [ ! -b "${DEV_SRC}" ]; then - echo "GROOMER: Source device (${DEV_SRC}) does not exist." + if [ ! -b "${SRC_DEV}" ]; then + echo "GROOMER: Source device (${SRC_DEV}) does not exist." exit fi } check_dest_exists() { - if [ ! -b "${DEV_DST}" ]; then - echo "GROOMER: Destination device (${DEV_DST}) does not exist." + if [ ! -b "${DST_DEV}" ]; then + echo "GROOMER: Destination device (${DST_DEV}) does not exist." exit fi } @@ -43,25 +43,23 @@ unmount_dest_if_mounted() { } mount_dest_partition() { - 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}" + if ${PMOUNT} -w "${DST_DEV}1" "${DST_MNT}"; then # pmount automatically mounts on /media/ (at /media/dst in this case). + echo "GROOMER: Destination USB device (${DST_DEV}1) mounted at ${DST_MNT}" else - echo "GROOMER: Unable to mount ${DEV_DST}1 on ${DST_MNT}" + echo "GROOMER: Unable to mount ${DST_DEV}1 on ${DST_MNT}" exit fi } copy_in_progress_file() { - cp "/opt/groomer/IN_PROGRESS" "${DST_MNT}/IN_PROGRESS" + cp "/opt/groomer/IN_PROGRESS.txt" "${DST_MNT}/IN_PROGRESS.txt" } 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 + # Prepare temp dir and make sure it's empty if it already exists: mkdir -p "${TEMP}" - mkdir -p "${LOGS}" rm -rf "${TEMP:?}/"* - rm -rf "${LOGS:?}/"* } main() { @@ -81,4 +79,4 @@ main() { ./groomer.sh } -main \ No newline at end of file +main