From 5f2a8d20ff229fa125b9c3af9ecb354127fc83ca Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Mon, 4 Mar 2019 11:06:35 -0500 Subject: [PATCH] fix bugs based on testing --- README | 2 +- relay-cmd | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README b/README index 01be120..eb988e1 100644 --- a/README +++ b/README @@ -3,7 +3,7 @@ Kelling also has a package for openwrt, not yet published. Ask him if you are interested. relay-cmd is a simple script config to use the relay from the device its -connected to. NOT YET TESTED. +connected to. libremanage is an overly complicated command that is deprecated. Some problems with it: diff --git a/relay-cmd b/relay-cmd index 40a01cf..46c6924 100755 --- a/relay-cmd +++ b/relay-cmd @@ -20,7 +20,6 @@ cephserver3_relay_id=HURTM cephserver2_channel=2 cephserver2_relay_id=HURTM EOF - exit $1 } @@ -36,16 +35,17 @@ fi # we know HOSTNAME is given if it doesn't start with a number. if [[ $chan != [0-9]* ]]; then + if [[ ! $relay_id ]]; then + relay_id_var=${chan}_relay_id + relay_id=${!relay_id_var} + fi chan_var=${chan}_channel chan=${!chan_var} + if [[ ! $chan ]]; then echo "error: channel not found in /etc/relay-cmd.conf" >&2 exit 1 fi - if [[ ! $relay_id ]]; then - relay_id_var=${chan}_relay_id - relay=${!relay_id_var} - fi fi @@ -77,14 +77,14 @@ fi # verbose command v() { - printf "+ %s\n" "$*" + printf "$0 running: %s\n" "$*" "$@" } # ignore hup so we complete even if there is a connection problem. trap '' HUP -echo "$0: doing $action. shell commands are printed to the terminal:" +echo "$0: doing $action. shell commands will be printed to the terminal." case $action in poweroff) v hidusb-relay-cmd $relay_id_arg on $chan -- 2.25.1