-Advanced Usage: libremanage poweroff|poweron|reboot HOSTNAME|CHANNEL [BOARD_ID]
+Advanced Usage: libremanage [--switch] poweroff|poweron|reboot HOSTNAME|CHANNEL [BOARD_ID]
Note, the relay's channels default state when plugged in are off.
cephserver3_board_id=HURTM
cephserver2_channel=2
cephserver2_board_id=HURTM
+
+librecmc1_type=switch
+cephserver2_type=button # default
+
# end of config
-libremanage reboot cephserver3
+Example use:
+
+$ libremanage reboot cephserver3
+
+--switch means means that the relay controls on an on/off switch (with
+default on), instead of a pc power button, which is the default. This
+corresponds to the config option HOST_type=switch.
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
usage
fi
+switch=false
+if [[ $1 == --switch ]]; then
+ switch=true
+fi
+
read action chan board_id <<<"$@"
if [[ -e /etc/libremanage.conf ]]; then
echo "$0: doing $action. shell commands will be printed to the terminal."
case $action in
poweroff)
- v hidusb-relay-cmd $board_id_arg on $chan
- v sleep 6
- v hidusb-relay-cmd $board_id_arg off $chan
+ if $switch; then
+ v hidusb-relay-cmd $board_id_arg off $chan
+ else
+ v hidusb-relay-cmd $board_id_arg on $chan
+ v sleep 6
+ v hidusb-relay-cmd $board_id_arg off $chan
+ fi
;;
poweron)
- v hidusb-relay-cmd $board_id_arg on $chan
- v sleep 1
- v hidusb-relay-cmd $board_id_arg off $chan
+ if $switch; then
+ v hidusb-relay-cmd $board_id_arg on $chan
+ else
+ v hidusb-relay-cmd $board_id_arg on $chan
+ v sleep 1
+ v hidusb-relay-cmd $board_id_arg off $chan
+ fi
;;
reboot)
- v hidusb-relay-cmd $board_id_arg on $chan
- v sleep 6
- v hidusb-relay-cmd $board_id_arg off $chan
- v sleep 1
- v hidusb-relay-cmd $board_id_arg on $chan
- v sleep 1
- v hidusb-relay-cmd $board_id_arg off $chan
+ if $switch; then
+ v hidusb-relay-cmd $board_id_arg off $chan
+ v sleep 4
+ v hidusb-relay-cmd $board_id_arg on $chan
+ else
+ v hidusb-relay-cmd $board_id_arg on $chan
+ v sleep 6
+ v hidusb-relay-cmd $board_id_arg off $chan
+ v sleep 1
+ v hidusb-relay-cmd $board_id_arg on $chan
+ v sleep 1
+ v hidusb-relay-cmd $board_id_arg off $chan
+ fi
;;
*)
echo "error: action arg not supported" >&2