From c5f054a20758da2e66f1b1c42cabb7d44e5a319f Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 5 Dec 2018 19:12:31 -0500 Subject: [PATCH] minor cleanup --- config.json | 43 ++++++++++++++++----------------- hidusb-relay-cmd-setup | 30 +++++++++++++++++++++++ libremanage | 2 +- notes/hidusb-relay-cmd-setup.md | 10 -------- 4 files changed, 52 insertions(+), 33 deletions(-) create mode 100755 hidusb-relay-cmd-setup delete mode 100644 notes/hidusb-relay-cmd-setup.md diff --git a/config.json b/config.json index f261e11..4508088 100644 --- a/config.json +++ b/config.json @@ -1,25 +1,24 @@ { - "servers": { - "web2": { - "manager": "myboard", - "tty": { - "uncolor": true, - "file": "/dev/ttyUSB0", - "baud": 115200 - }, - "power": { - "type": "hidusb-relay-cmd", - "relay": "HURTM", - "channel": 2 - } - } - }, - "managers": { - "myboard": { - "host": "192.168.0.250", - "port": 22, - "username": "root" - } + "servers": { + "web2": { + "manager": "myboard", + "tty": { + "uncolor": false, + "file": "/dev/ttyUSB0", + "baud": 115200 + }, + "power": { + "type": "hidusb-relay-cmd", + "relay": "HURTM", + "channel": 2 + } } + }, + "managers": { + "myboard": { + "host": "192.168.0.250", + "port": 22, + "username": "root" + } + } } - diff --git a/hidusb-relay-cmd-setup b/hidusb-relay-cmd-setup new file mode 100755 index 0000000..73ac1fc --- /dev/null +++ b/hidusb-relay-cmd-setup @@ -0,0 +1,30 @@ +#!/bin/bash +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR + +rm -rf usb-relay-hid +git clone https://vcs.fsf.org/git/usb-relay-hid.git + +cd usb-relay-hid +git remote add upstream-github https://github.com/pavel-a/usb-relay-hid +git fetch upstream-github +if [[ $(git rev-parse master) != $(git rev-parse upstream-github/master) ]]; then + echo "WARNING from iank! github https://github.com/pavel-a/usb-relay-hid is different from vcs master" + echo "sleeping 10 so you see this" + sleep 10 +fi + + +cd commandline/makemake/ +apt update +apt-get install libusb-dev libusb-1.0-0-dev +make +cp hidusb-relay-cmd /usr/local/bin + +cat <<'EOF' +the output should be similar to this: +Board ID=[HURTM] State: R1=OFF R2=OFF +'HURTM' varies by board and goes into the libremanage config as the value for "relay" +EOF + +hidusb-relay-cmd state diff --git a/libremanage b/libremanage index 6b137d4..724c14d 100755 --- a/libremanage +++ b/libremanage @@ -34,7 +34,7 @@ Valid commands are as follows: - shutdown, reboot, poweron: Power management - tty: Open TTY in GNU Screen - - sanity, sanity-sh: SSH sanity tests, ignore + - sanity, sanity-sh: SSH sanity tests, which will whoami or just run sh. Define a configuration file in ~/.libremanage.json. See the included config.json for an example. Servers correspond to managed servers; managers diff --git a/notes/hidusb-relay-cmd-setup.md b/notes/hidusb-relay-cmd-setup.md deleted file mode 100644 index 6ec1003..0000000 --- a/notes/hidusb-relay-cmd-setup.md +++ /dev/null @@ -1,10 +0,0 @@ -git clone https://github.com/pavel-a/usb-relay-hid -cd usb-relay-hid/ -cd commandline/ -cd makemake/ -apt update -sudo apt install libusb-dev -sudo apt install libusb-1.0-0-dev -cp hidusb-relay-cmd /usr/local/bin -make -j4 -hidusb-relay-cmd state -- 2.25.1