help() { cat </dev/null mount $MOUNT_OPTS "/dev/$partition" "/media/$media" } discover-shard() { MOUNT_OPTS="-o relatime,utf8,flush,umask=0000" lsblk -nlo NAME,FSTYPE | awk '$2 == "vfat" { print $1 }' | while read partition; do amount "$partition" find "/media/$partition" -name '*.pgp' -maxdepth 2 | while read file; do echo "Found potential shardfile: $file" done done } prepare-shard-media() { echo "Please re-insert the SD card" udevadm monitor --udev | while read udev ts operation path type; do if [ "$type" = "(block)" -a "$operation" = "add" ]; then partition="$(echo "$path" | cut -d/ -f12)" if [ ! -z "$partition" ]; then amount "$partition" "sdcard" # Weird quirk with bash: if udev doesn't have anything else printing, # it won't trigger the start of the next loop, and therefore won't # "break" the loop. Run `udevadm trigger` to give udevadm more things # to send to `read`. udevadm trigger break fi fi done } help echo discover-shard echo