cat <<EOF
Usage: libremanage poweroff|poweron|reboot HOSTNAME|CHANNEL [BOARD_ID]
-BOARD_ID is not needed if only 1 relay device is connected. To
-understand CHANNEL and BOARD_ID, run hidusb-relay-cmd and
-hidusb-relay-cmd state.
-
-Using a configuration (/etc/libremanage.conf) allows you to use HOSTNAME
-instead of CHANNEL and BOARD_ID.
+HOSTNAME is based on configuration in /etc/libremanage.conf.
Note, the relay's channels default state when plugged in are off.
+Example config:
+
+# This config is sourced from bash, so make sure its valid bash.
+cephserver3_channel=1
+cephserver3_board_id=HURTM
+cephserver2_channel=2
+cephserver2_board_id=HURTM
+# end of config
+
+Example usage given the above config:
+
+libremanage reboot cephserver3
+
+BOARD_ID is not needed if only 1 relay device is connected, or if it is
+defined in the config. To understand CHANNEL and BOARD_ID, run
+hidusb-relay-cmd and hidusb-relay-cmd state.
+
+
WARNING: Avoid ever manually running "hidusb-relay-cmd on" in
production, because if you lose connectivity and can't turn it off, its
like the server's power button is stuck being pushed in and it won't
its running. If you run this script over ssh and lose connection as this
script is running, it will continue to run and complete.
-Example config:
-
-# This config is sourced from bash, so make sure its valid bash.
-# board_id is not needed if only 1 relay device is connected.
-cephserver3_channel=1
-cephserver3_board_id=HURTM
-cephserver2_channel=2
-cephserver2_board_id=HURTM
-
EOF
if [[ -e /etc/libremanage.conf ]]; then
echo "Current config:"
- v cat /etc/libremanage.conf
+ cat /etc/libremanage.conf
else
echo "Note: /etc/libremanage.conf does not exist on the current machine"
fi
source /etc/libremanage.conf
fi
-# Use config vars. We know the arg is a HOSTNAME if it doesn't start
-# with a number.
+# Use config vars when appropriate. We know the arg is a HOSTNAME if it
+# doesn't start with a number.
if [[ $chan != [0-9]* ]]; then
if [[ ! $board_id ]]; then
board_id_var=${chan}_board_id