filter partitions { optical = false partition_table = false usage = filesystem } filter optical-udf { optical = true partition_table = false usage = filesystem type = udf } filter optical-other { optical = true partition_table = false usage = filesystem } filter disks { optical = false partition = false } match partitions { automount = true post_mount_command = ' sudo chmod a+rwx "%mount_point" 2>/dev/null if [ -f /usr/bin/net ] && /bin/systemctl is-enabled samba > /dev/null 2>&1; then count=120 sharename=$(basename "%mount_point") id -u "${sharename,,}" > /dev/null 2>&1 && sharename+="-auto" while [ $count -gt 0 ]; do if sudo /usr/bin/net usershare add "$sharename" "%mount_point" "Auto-mount Volume" "$(hostname -s)\osmc:f" then break fi sleep 5; let count-=5 done fi' post_unmount_command = ' if [ -f /usr/bin/net ]; then unsharename=$(basename "%mount_point") id -u "${unsharename,,}" > /dev/null 2>&1 && unsharename+="-auto" sudo /usr/bin/net usershare delete "$unsharename" fi' } match optical-udf { automount = true automount_options = { 'mode=0444','dmode=0555','uid=1000','gid=1000','umask=0000' } post_mount_command = ' if [ -f /usr/bin/net ] && /bin/systemctl is-enabled samba > /dev/null 2>&1; then count=120 udfname=$(basename "%mount_point") id -u "${udfname,,}" > /dev/null 2>&1 && udfname+="-auto" while [ $count -gt 0 ]; do if sudo /usr/bin/net usershare add "$udfname" "%mount_point" "Auto-mount Volume" "$(hostname -s)\osmc:r" then break fi sleep 5; let count-=5 done fi' post_unmount_command = ' if [ -f /usr/bin/net ]; then unudfname=$(basename "%mount_point") id -u "${unudfname,,}" > /dev/null 2>&1 && unudfname+="-auto" sudo /usr/bin/net usershare delete "$unudfname" fi /usr/bin/eject %device_file' } match optical-other { automount = true automount_options = { 'mode=0444','dmode=0555','uid=1000','gid=1000' } post_mount_command = ' if [ -f /usr/bin/net ] && /bin/systemctl is-enabled samba > /dev/null 2>&1; then count=120 othname=$(basename "%mount_point") id -u "${thname,,}" > /dev/null 2>&1 && othname+="-auto" while [ $count -gt 0 ]; do if sudo /usr/bin/net usershare add "$othname" "%mount_point" "Auto-mount Volume" "$(hostname -s)\osmc:r" then break fi sleep 5; let count-=5 done fi' post_unmount_command = ' if [ -f /usr/bin/net ]; then unothname=$(basename "%mount_point") id -u "${unothname,,}" > /dev/null 2>&1 && unothname+="-auto" sudo /usr/bin/net usershare delete "$onothname" fi /usr/bin/eject %device_file' } match disks { post_insertion_command = ' if [ $(/bin/lsblk -n -d -o RM "%device_file") -eq 1 ] || [ $(/bin/lsblk -n -d -o ROTA "%device_file") -eq 0 ]; then device=$(/bin/lsblk -n -d -o MAJ:MIN,TYPE -s "%device_file" | grep disk | sed "s/[^0-9:]*//g") echo 1024 | sudo tee "/sys/dev/block/$device/queue/read_ahead_kb" > /dev/null else sudo /sbin/hdparm -S 240 %device_file fi' } default { post_insertion_command = 'echo "Device %device_file did not match any rules."; ls -al "%device_file"; echo "blkid: $(/sbin/blkid %device_file)"; /usr/bin/udisks --show-info %device_file' }