05 Dec

UPDATE TO: USB Automount Script for Raspberry Pi

Here an update to USB Automount Script for Raspberry Pi after some tests and some comments. The script now supports multiple partitions and those without labels.

You can download it here mount_manager (556 downloads) or checkout the code below. I also updated the original post.

regex='(/dev/sd[a-z][0-9]): (LABEL=\"([A-Za-z0-9_\-]+)\")?.*UUID=\"([a-zA-Z0-9\-]+)\".*TYPE=\"([a-zA-Z0-9]+)\"'
while IFS= read -r line; do
        if [[ $line =~ $regex ]];then
                name="${BASH_REMATCH[1]}"
                label="${BASH_REMATCH[3]}"
                uuid="${BASH_REMATCH[4]}"
                type="${BASH_REMATCH[5]}"
                if [ -z "${label}" ];then
                        label=${uuid}
                fi
                arr_plugged_in_path+=($name)
                arr_plugged_in_label+=($label)
                arr_plugged_in_type+=($type)
        fi
done < <(blkid)

Thanks to all who wrote me and enjoy!