Initial import of libxhcidbg library
[libxhcidbg.git] / misc / xhcidbg-log
1 #!/bin/sh
2
3 wait_for_file()
4 {
5         local dir=$1
6         local file=$2
7         until [ -e "$dir/$file" ]
8         do
9                 filename=$(inotifywait -q -e create $dir | cut -d' ' -f 3)
10                 if [ "$filename" = "$file" ] ; then
11                         break;
12                 fi
13         done
14
15 }
16
17 command -v inotifywait >/dev/null 2>&1 || \
18 {
19         echo >&2 "Command 'inotifywait' missing.";
20         echo >&2 "Try 'apt-get install inotify-tools' to install.";
21         exit 1;
22 }
23
24 wait_for_file "/dev" "serial"
25 wait_for_file "/dev/serial" "by-id"
26
27 while true;
28 do
29         for f in "/dev/serial/by-id/usb-secunet_HW.DbC"*; do
30                 if [ -e "$f" ] ; then
31                         cat "$f"
32                         break 2;
33                 else
34                         inotifywait -qe create /dev/serial/by-id 2>&1
35                 fi
36                 break;
37         done
38 done
39
40 exit 0