fix bugs based on testing
authorIan Kelling <iank@fsf.org>
Mon, 4 Mar 2019 16:06:35 +0000 (11:06 -0500)
committerIan Kelling <iank@fsf.org>
Mon, 4 Mar 2019 16:06:35 +0000 (11:06 -0500)
README
relay-cmd

diff --git a/README b/README
index 01be120b67a0699ed8c6f32f5a5f48e9c120e2d0..eb988e197b8328f574dcbeb902b9616bddd5c962 100644 (file)
--- 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:
index 40a01cf362b760d4fe86d68778546cfb7b9a47a2..46c6924ff8f7b95a27c653b47c2151e85772e6d4 100755 (executable)
--- 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