From 5632c9096ac9394da4c03d25bbf76c0198787e8e Mon Sep 17 00:00:00 2001 From: Dan Puttick Date: Tue, 17 Jan 2017 10:15:36 -0500 Subject: [PATCH] Add udev rules for controlling where keys are found in /dev --- fs_filecheck/etc/udev/rules.d/10-usb.rules | 6 ++++++ fs_filecheck/opt/groomer/config.sh | 6 ++---- fs_filecheck/opt/groomer/init.sh | 7 ++++--- fs_filecheck/opt/groomer/mount_dest.sh | 6 +++--- 4 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 fs_filecheck/etc/udev/rules.d/10-usb.rules diff --git a/fs_filecheck/etc/udev/rules.d/10-usb.rules b/fs_filecheck/etc/udev/rules.d/10-usb.rules new file mode 100644 index 0000000..700bf79 --- /dev/null +++ b/fs_filecheck/etc/udev/rules.d/10-usb.rules @@ -0,0 +1,6 @@ +# The purpose of this rules file is to ensure that the top left usb port and its partitions have a symlink to /dev/source_key[num], and the other ports to /dev/dest_key[num] +KERNELS=="1-1.2", SUBSYSTEMS=="usb", SYMLINK+="source_key%n" +KERNELS=="1-1.[3-5]*", SUBSYSTEMS=="usb", SYMLINK+="dest_key%n" + +# KERNELS=="1-1.2", SUBSYSTEMS=="usb", ENV{USB} SYMLINK+="source_key%n" +# KERNELS=="1-1.[3-5]*", SUBSYSTEMS=="usb", SYMLINK+="dest_key%n" \ No newline at end of file diff --git a/fs_filecheck/opt/groomer/config.sh b/fs_filecheck/opt/groomer/config.sh index e31a4b5..f4612fc 100755 --- a/fs_filecheck/opt/groomer/config.sh +++ b/fs_filecheck/opt/groomer/config.sh @@ -4,13 +4,11 @@ ID=`/usr/bin/id -u` # Paths used in multiple scripts SRC="src" -DEV_SRC="/dev/sda" -DEV_SRC_ONE="/dev/sda1" +DEV_SRC="/dev/source_key" SRC_MNT="/media/src" DST="dst" -DEV_DST="/dev/sdb" -DEV_DST_ONE="/dev/sdb1" +DEV_DST="/dev/dest_key" DST_MNT="/media/dst" TEMP="${DST_MNT}/temp" diff --git a/fs_filecheck/opt/groomer/init.sh b/fs_filecheck/opt/groomer/init.sh index f990a4c..680f0ed 100755 --- a/fs_filecheck/opt/groomer/init.sh +++ b/fs_filecheck/opt/groomer/init.sh @@ -26,7 +26,8 @@ trap clean EXIT TERM INT ./music.sh & echo $! > /tmp/music.pid -# List block storage devices (for debugging) -lsblk |& tee ${GROOM_LOG} +# List block storage devices for debugging +# Make sure to set tee in append (-a) mode below if you uncomment +# lsblk |& tee ${GROOM_LOG} -su ${USERNAME} -c ./mount_dest.sh |& tee -a ${GROOM_LOG} +su ${USERNAME} -c ./mount_dest.sh |& tee ${GROOM_LOG} diff --git a/fs_filecheck/opt/groomer/mount_dest.sh b/fs_filecheck/opt/groomer/mount_dest.sh index 0e3d955..9753680 100755 --- a/fs_filecheck/opt/groomer/mount_dest.sh +++ b/fs_filecheck/opt/groomer/mount_dest.sh @@ -54,12 +54,12 @@ fi # Mount the first partition of DST (/dev/sdb1) # pmount automatically mounts on /media/ (at /media/dst in this case). -${PMOUNT} -w ${DEV_DST_ONE} ${DST} +${PMOUNT} -w /dev/dest_key1 ${DST} if [ ${?} -ne 0 ]; then - echo "GROOMER: Unable to mount ${DEV_DST_ONE} on ${DST_MNT}" + echo "GROOMER: Unable to mount ${DEV_DST}1 on ${DST_MNT}" exit else - echo "GROOMER: Destination USB device (${DEV_DST_ONE}) mounted at ${DST_MNT}" + echo "GROOMER: Destination USB device (${DEV_DST}1) mounted at ${DST_MNT}" # Remove any existing "FROM_PARTITION_" directories rm -rf "/media/${DST}/FROM_PARTITION_"*