UDEV

UDEV

Infos sur un device

Exemple, info sur clef thermoetre USB / serial

# udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0)

tracer udev

# udevadm monitor

recharger les rules udev

#udevadm control --reload-rules #udevadm trigger

Exemple : USB thermometre

    • /etc/udev/rules.d/99-patrick.rules

ACTION=="add", KERNEL=="tty[A-Z]*[0-9]", RUN+="/usr/local/bin/usbtemp %k"

    • /usr/local/bin/usbtemp

#!/bin/sh

logfile=`basename $0`

t=`/usr/local/bin/usbtemp.py $1`

export DISPLAY=:0

icon=/usr/share/icons/gnome/scalable/status/weather-few-clouds.svg

for user in `who | cut -d\ -f1 | uniq` ; do

export XAUTHORITY=/home/$user/.Xauthority

sudo -u $user /usr/bin/notify-send -u critical -i $icon "$1 $t" "$2" >> /var/log/${logfile}.log 2>&1

done

UDEV

    • dans /etc/udev/rules.d/99-patrick.rules

ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", KERNEL=="sd[a-z]", OPTIONS+="all_partitions", RUN+="/etc/patrick-backup add %k &" ACTION=="remove", KERNEL=="sd[a-z]", RUN+="/etc/patrick-backup remove %k" ACTION=="add", SUBSYSTEMS=="usb", RUN+="/etc/init.d/motion restart &"