Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:base-system:hotplug [2024/01/15 17:00] – [Coldplug] systemcrash | docs:guide-user:base-system:hotplug [2024/08/23 10:25] – Avoid duplication/duplicate execution oliv3r | ||
|---|---|---|---|
| Line 22: | Line 22: | ||
| | **ntp** | | **ntp** | ||
| | **tftp** | | **tftp** | ||
| + | | **tty** | ||
| | **usb** | | **usb** | ||
| - | | **usbmisc** | + | | **usbmisc** |
| See also: | See also: | ||
| Line 146: | Line 147: | ||
| Even without NTP sync, you will receive a " | Even without NTP sync, you will receive a " | ||
| + | |||
| + | ==== tty ==== | ||
| + | ^ Variable name ^ description ^ | ||
| + | | ACTION | add, remove, bind, unbind as above | | ||
| + | | DEVICENAME | eg " | ||
| + | | DEVNAME | only for bind/ | ||
| + | | DEVPATH | eg, "/ | ||
| + | | SEQNUM | (action number since boot for this subsystem) eg 335 | | ||
| + | | SUBSYSTEM | Specific type of device, eg, " | ||
| + | | MAJOR | eg 189 | | ||
| + | | MINOR | eg 1 | | ||
| ==== usb ==== | ==== usb ==== | ||
| Line 186: | Line 198: | ||
| ==== Symlink instead of rename a device ==== | ==== Symlink instead of rename a device ==== | ||
| An other script to create a symlink instead of renaming the device. | An other script to create a symlink instead of renaming the device. | ||
| - | I test if DEVICE_NAME is empty because when I plug usb device I retrieve two add event, and the first come before created device, so symlink fails. | ||
| <code bash> | <code bash> | ||
| cat << " | cat << " | ||
| - | CP210_PRODID="10c4/ | + | CP210_PRODID='10c4/ |
| SYMLINK=" | SYMLINK=" | ||
| - | if [ " | + | set -eu |
| - | if [ " | + | |
| - | DEVICE_NAME=$(ls / | + | |
| - | if [ -z ${DEVICE_NAME} ]; then | + | |
| - | logger -t hotplug " | + | |
| - | exit 0 | + | |
| - | fi | + | |
| - | logger -t hotplug " | + | |
| - | ln -s / | + | |
| - | logger -t hotplug " | + | |
| - | fi | + | |
| - | fi | + | |
| - | if [ " | + | if [ " |
| - | if [ " | + | [ " |
| - | rm / | + | if [ " |
| - | logger -t hotplug " | + | if [ -L "/ |
| - | fi | + | logger -t hotplug " |
| + | exit 0 | ||
| + | fi | ||
| + | |||
| + | DEVICE_NAME=" | ||
| + | if [ -z " | ||
| + | logger -t hotplug ' | ||
| + | exit 0 | ||
| + | fi | ||
| + | |||
| + | logger -t hotplug " | ||
| + | ln -s "/ | ||
| + | logger -t hotplug " | ||
| + | fi | ||
| + | |||
| + | |||
| + | if [ " | ||
| + | rm "/ | ||
| + | logger -t hotplug " | ||
| + | fi | ||
| fi | fi | ||
| EOF | EOF | ||
| </ | </ | ||
| - | |||
| ==== Script that detects whether plugged usb device is bluetooth or not ==== | ==== Script that detects whether plugged usb device is bluetooth or not ==== | ||
| <code bash> | <code bash> | ||
| Line 454: | Line 472: | ||
| </ | </ | ||
| + | ==== Create deterministic/ | ||
| + | Resulting links will be placed in / | ||
| + | with a name structure closely resembling links created by udev, but not fully exact. | ||
| + | |||
| + | <code bash> | ||
| + | set -o pipefail | ||
| + | [ " | ||
| + | [ " | ||
| + | [ -n " | ||
| + | |||
| + | if [ " | ||
| + | subsystem=" | ||
| + | |||
| + | [ " | ||
| + | |||
| + | replace_whitespace=" | ||
| + | manufacturer=" | ||
| + | product=" | ||
| + | serial=" | ||
| + | interface=" | ||
| + | port=" | ||
| + | |||
| + | replace_chars=" | ||
| + | id_link=$(echo " | ||
| + | path_link=$(echo " | ||
| + | |||
| + | mkdir -p / | ||
| + | ln -sf "/ | ||
| + | ln -sf "/ | ||
| + | elif [ " | ||
| + | for link in $(find /dev/serial -type l); do | ||
| + | [ -L ${link} -a " | ||
| + | done | ||
| + | fi | ||
| + | </ | ||
| + | [[https:// | ||