#!/bin/sh
#
# trigger-rcmp: Trigger remote commands
-# Copyright (c)2014 Alexander Barton (alex@barton.de)
+# Copyright (c)2014-2015 Alexander Barton (alex@barton.de)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
for i in `seq 1 $SSH_CHECKS`; do
echo "$NAME: checking SSH connection ($i/$SSH_CHECKS) ..."
- ssh -q "$SYSTEM" true >/dev/null 2>&1 && break
+ ssh -q -o "ServerAliveInterval 120" "$SYSTEM" true >/dev/null 2>&1 && break
echo "$NAME: SSH on \"$SYSTEM\" not ready. Waiting ..."
sleep 10s
done
echo "$NAME: calling \"$CMD\" on \"$SYSTEM\" ..."
echo
- ssh -q "$SYSTEM" "$CMD" </dev/null ; r=$?
+ ssh -q -o "ServerAliveInterval 120" "$SYSTEM" "$CMD" </dev/null ; r=$?
echo
echo "$NAME: remote command ended with return code $r."
rsys_users=`ssh -q "$SYSTEM" w | tail -n +3 | wc -l`
if [ "$rsys_users" = "0" ]; then
echo "$NAME: power off \"$SYSTEM\" again ..."
- ssh -q "$SYSTEM" "sync; shutdown -hP $SHUTDOWN_TIME" >/dev/null
+ ssh -q -o "ServerAliveInterval 120" "$SYSTEM" "sync; shutdown -hP $SHUTDOWN_TIME" >/dev/null
if [ $? -ne 0 ]; then
echo "$NAME: failed to power off \"$SYSTEM\"!" >&2
return 5