Ensure hard drives are not mounted as storage media, add recipe for kanglam

This commit is contained in:
Ana Custura 2026-03-05 09:24:59 +00:00
parent 41e5269ae7
commit 0c0e770fca
3 changed files with 209 additions and 1 deletions

View file

@ -36,7 +36,7 @@
- name: Install udev rule
copy:
src: "{{ vmdb2_config_base_dir }}/99-usb-butter.rules"
src: "templates/99-usb-butter.rules"
dest: "/etc/udev/rules.d/99-usb-butter.rules"
- name: Install udev trigger script

View file

@ -0,0 +1,11 @@
# 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 and lighttpd config with our script.
# 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.