summaryrefslogtreecommitdiff
path: root/tools/hotplug-ng/libsane.hotplug
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-10-06 14:00:40 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-10-06 14:00:40 +0200
commit6e9c41a892ed0e0da326e0278b3221ce3f5713b8 (patch)
tree2e301d871bbeeb44aa57ff9cc070fcf3be484487 /tools/hotplug-ng/libsane.hotplug
Initial import of sane-backends version 1.0.24-1.2
Diffstat (limited to 'tools/hotplug-ng/libsane.hotplug')
-rwxr-xr-xtools/hotplug-ng/libsane.hotplug29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/hotplug-ng/libsane.hotplug b/tools/hotplug-ng/libsane.hotplug
new file mode 100755
index 0000000..dec38a5
--- /dev/null
+++ b/tools/hotplug-ng/libsane.hotplug
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# This file is part of the SANE distribution.
+# Hotplug USB hook for SANE
+
+if [ "$ACTION" != "add" ]; then
+ exit 0
+fi
+
+DEVVID=$(printf %4s $(echo $PRODUCT | cut -d'/' -f1) | tr ' ' 0)
+DEVPID=$(printf %4s $(echo $PRODUCT | cut -d'/' -f2) | tr ' ' 0)
+
+DEVCONF=$(grep -i "^0x$DEVVID[[:space:]]\+0x$DEVPID" /etc/sane.d/hotplug/*.db 2> /dev/null)
+
+if [ $? != 0 ]; then
+ exit 0
+fi
+
+set $DEVCONF
+
+chown $3 $DEVICE && chmod $4 $DEVICE
+
+if [ ! -z $5 -a -x $5 ]; then
+ export DEVVID
+ export DEVPID
+ exec $5
+fi
+
+exit 0