mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-31 12:20:29 +00:00
46 lines
1.2 KiB
Bash
Executable File
46 lines
1.2 KiB
Bash
Executable File
#!/bin/ash
|
|
|
|
exec 1>/dev/console 2>&1
|
|
|
|
P=/sys$DEVPATH
|
|
[ -r $P/../../uevent ] && . $P/../../uevent
|
|
[ -r $P/uevent ] && . $P/uevent
|
|
|
|
# Exit unless proper type
|
|
[ $SUBSYSTEM = "usb-serial" -a -n "$DRIVER" ] || exit 0
|
|
|
|
PATH="/sbin:/bin:/usr/sbin:/usr/bin"
|
|
|
|
ME=${0##*/}
|
|
say ()
|
|
{
|
|
echo "$ME: $@"
|
|
logger -t $ME "$@"
|
|
}
|
|
|
|
MANU=$( ( test -r $P/../manufacturer && cat $P/../manufacturer ) || \
|
|
( test -r $P/../../manufacturer && cat $P/../../manufacturer ) || echo "generic" )
|
|
|
|
PORT=$( cat $P/port_number )
|
|
DEV_NM="$DRIVER-$(cat $P/../../idVendor)-$(cat $P/../../idProduct)"
|
|
DEVP=/dev/ttyusb/$DEV_NM
|
|
|
|
if [ $ACTION = "add" ] ;then
|
|
mkdir -p $DEVP
|
|
ln -sf /dev/$MDEV $DEVP/$PORT
|
|
say "ADD $DEVPATH MANU $MANU"
|
|
say "Add $DEVP/$PORT -> /dev/$MDEV"
|
|
if [ -n $DEVNAME ] ;then
|
|
DEVADDR=$(echo $DEVNAME | tr / _)
|
|
ln -sf /dev/$MDEV $DEVP/$DEVADDR:$(cat $P/../bInterfaceNumber)
|
|
say "Add $DEVP/$DEVADDR -> /dev/$MDEV"
|
|
fi
|
|
elif [ $ACTION = "remove" ] ;then
|
|
rm -f /dev/ttyusb/$MANU/$DEV_NM/$PORT
|
|
say "REM $DEVPATH MANU $MANU"
|
|
say "Rem $DEVP/$PORT -> /dev/$MDEV"
|
|
else
|
|
say "Unknown action $ACTION for $MDEV $MANU $DEV_NM PATH $DEVPATH"
|
|
fi
|
|
|