mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-28 11:50:42 +00:00
38 lines
885 B
Bash
Executable File
38 lines
885 B
Bash
Executable File
#!/bin/ash
|
|
|
|
exec 1>/dev/console 2>&1
|
|
|
|
P=/sys$DEVPATH
|
|
[ -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 $DEVP/$PORT -> /dev/$MDEV MANU $MANU"
|
|
elif [ $ACTION = "remove" ] ;then
|
|
rm -f /dev/ttyusb/$MANU/$DEV_NM/$PORT
|
|
say "Rem $DEVP/$PORT -> /dev/$MDEV MANU $MANU"
|
|
else
|
|
say "Unknown action $ACTION for $MDEV $MANU $DEV_NM"
|
|
fi
|
|
|