-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·40 lines (31 loc) · 827 Bytes
/
start.sh
File metadata and controls
executable file
·40 lines (31 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
if [ "$(whoami)" != "root" ] ; then
echo This script must be executed as root
exit 1
fi
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null
if [ ! -f config.sh ] ; then
echo Could not find config.sh - please copy the config.example.sh and adjust the values >&2
exit 2
fi
. config.sh
if ! which evtest &>/dev/null ; then
echo Could not find evtest executable - please install it >&2
exit 4
fi
while true ; do
# Read raw key events from the RFID reader to get the token ID
TOKEN_ID=""
evtest "$RFID_READER_INPUT_DEVICE" | while read line ; do
if ! [[ $line =~ .*EV_KEY.*value\ 1 ]] ; then
continue
fi
KEY="$(echo "$line" | sed 's/.*(KEY_\(.*\)).*/\1/')"
if [ "$KEY" = "ENTER" ] ; then
./actions.sh $TOKEN_ID
TOKEN_ID=""
else
TOKEN_ID="$TOKEN_ID$KEY"
fi
done
done