summaryrefslogtreecommitdiff
path: root/bigclown-gateway/files/hotplug
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-09-12 23:59:58 +0200
committerKarel Kočí <cynerd@email.cz>2018-09-12 23:59:58 +0200
commit5b0c2421d6ca596154d03b8994680e58e52846c9 (patch)
tree69b7be810456276e7dcc51d4d47ac92a93afa95f /bigclown-gateway/files/hotplug
parentb801bd3cc5dec9df8a8742d3f6d6f59a46ae5e9f (diff)
downloadopenwrt-personal-pkgs-5b0c2421d6ca596154d03b8994680e58e52846c9.tar.gz
openwrt-personal-pkgs-5b0c2421d6ca596154d03b8994680e58e52846c9.tar.bz2
openwrt-personal-pkgs-5b0c2421d6ca596154d03b8994680e58e52846c9.zip
bigclown-gateway: replace udev with hotplug
Diffstat (limited to 'bigclown-gateway/files/hotplug')
-rw-r--r--bigclown-gateway/files/hotplug32
1 files changed, 32 insertions, 0 deletions
diff --git a/bigclown-gateway/files/hotplug b/bigclown-gateway/files/hotplug
new file mode 100644
index 0000000..fb1ef59
--- /dev/null
+++ b/bigclown-gateway/files/hotplug
@@ -0,0 +1,32 @@
+#!/bin/sh
+DEVNAME="$(ls "/sys/$DEVPATH" | grep "^ttyUSB[0-9]*$")"
+[ -n "$DEVNAME" ] || exit 0
+[ "$ID_VENDOR" = "0403" ] || exit 0
+[ "$ID_MODEL" = "6015" ] || exit 0
+echo "$ID_SERIAL" | grep -q ".*bc-usb-dongle.*" || exit 0
+
+action_add() {
+ local id=0
+ while [ -e "/dev/bcUD$id" ]; do
+ id=$(expr $id + 1)
+ done
+ ln -sf "/dev/$DEVNAME" "/dev/bcUD$id"
+}
+
+action_remove() {
+ local id=0
+ while [ "$(readlink "/dev/bcUD$id")" = "$DEVNAME" ]; do
+ [ -e "/dev/bcUD$id" ] || return 0
+ id=$(expr $id + 1)
+ done
+ rm "/dev/bcUD$id"
+}
+
+case "$ACTION" in
+ add)
+ action_add
+ ;;
+ remove)
+ action_remove
+ ;;
+esac