fix bugs based on testing
[libremanage.git] / relay-cmd
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