churn/ansible/templates/99-usb-butter.rules

11 lines
609 B
Text

# Using udev to mount newly attached usb drives doesn't work.
# https://unix.stackexchange.com/a/507150/223286
# So, we depend on udisks to mount the disk. *Then* we want to
# to setup the symlink.
# We can run the script immediately because it waits for the disk
# to be mounted.
# Mount newly inserted drives, creating the directory if it doesn't exist
ACTION=="add", KERNEL=="sd[a-z][1-9]", ENV{ID_BUS}=="usb", TAG+="systemd", ENV{SYSTEMD_WANTS}+="udisks2-mount@%k.service", ENV{SYSTEMD_WANTS}+="serve-usb@%k.service"
# When the disk is `unmounted, the symlink will just point to a now-empty directory.