How to run shell script after installing device using UDEV

I wanted to know how to run the script after inserting the USB drive and automatically mounted Until I can run the script as soon as the device is inserted, however, the installation of the device will occur after the script shell completes the action.

+3
source share
2 answers

You can write udev rules in /etc/udev/rules.d/and use RUNlike:

KERNEL=="sd?1",ATTRS{serial}=="001CC27F",ACTION=="add",RUN+="/path/to/script.sh'"

Note: script.sh will run with root privileges.

+2
source

You will need to listen to the corresponding D-Bus signals, notifying that the volume is mounted.

0

Source: https://habr.com/ru/post/1768959/


All Articles