fix install script from returning false error
[libremanage.git] / hidusb-relay-cmd-setup
1 #!/bin/bash
2 set -eE -o pipefail
3 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
4
5
6 tmp="$(readlink -f -- "$BASH_SOURCE")"; script_dir=${tmp%/*}
7
8 rm -rf usb-relay-hid
9 git clone https://vcs.fsf.org/git/usb-relay-hid.git
10
11 cd usb-relay-hid
12 git remote add upstream-github https://github.com/pavel-a/usb-relay-hid
13 git fetch upstream-github
14 if [[ $(git rev-parse master) != $(git rev-parse upstream-github/master) ]]; then
15 echo "WARNING from iank! github https://github.com/pavel-a/usb-relay-hid is different from vcs master"
16 echo "sleeping 10 so you see this"
17 sleep 10
18 fi
19
20
21 cd commandline/makemake/
22 apt update
23 apt-get install libusb-dev libusb-1.0-0-dev
24 make
25 cp $script_dir/libremanage hidusb-relay-cmd /usr/local/bin
26
27 cat <<'EOF'
28 the output should be similar to this:
29 Board ID=[HURTM] State: R1=OFF R2=OFF
30 'HURTM' varies by board and goes into the libremanage config as the value for "relay"
31 EOF
32
33 if ! hidusb-relay-cmd state; then
34 echo "$0: WARNING: running hidusb-relay-cmd state failed. this is expected if a relay is not plugged in" >&2
35 fi