From 5b0c2421d6ca596154d03b8994680e58e52846c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 12 Sep 2018 23:59:58 +0200 Subject: bigclown-gateway: replace udev with hotplug --- bigclown-gateway/Makefile | 6 +++--- bigclown-gateway/files/hotplug | 32 ++++++++++++++++++++++++++++++++ bigclown-gateway/files/udev | 1 - 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 bigclown-gateway/files/hotplug delete mode 100644 bigclown-gateway/files/udev (limited to 'bigclown-gateway') diff --git a/bigclown-gateway/Makefile b/bigclown-gateway/Makefile index 4c41fc5..17bcbae 100644 --- a/bigclown-gateway/Makefile +++ b/bigclown-gateway/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=bigclown-gateway -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_SOURCE_URL:=https://github.com/bigclownlabs/bch-gateway.git PKG_MAINTAINER:=Karel Kočí @@ -21,8 +21,8 @@ define Py3Package/$(PKG_NAME)/install $(INSTALL_CONF) ./files/config $(1)/etc/config/bigclown-gateway $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/init $(1)/etc/init.d/bigclown-gateway - $(INSTALL_DIR) $(1)/lib/udev/rules.d/ - $(INSTALL_DATA) ./files/udev $(1)/lib/udev/rules.d/58-bigclown-usb-dongle.rules + $(INSTALL_DIR) $(1)/etc/hotplug.d/usb + $(INSTALL_DATA) ./files/hotplug $(1)/etc/hotplug.d/usb/50-bigclown-usb-dongle endef define Package/$(PKG_NAME)/conffiles 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 diff --git a/bigclown-gateway/files/udev b/bigclown-gateway/files/udev deleted file mode 100644 index 5409c56..0000000 --- a/bigclown-gateway/files/udev +++ /dev/null @@ -1 +0,0 @@ -SUBSYSTEMS=="usb", ACTION=="add", KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", ATTRS{serial}=="bc-usb-dongle*", SYMLINK+="bcUD%n" -- cgit v1.2.3