5c17bf2d8ee0abc7f20a4c4b80b5536755e19a5f
3 # ============================================================================
5 # Copyright (C) THALES. All rights reserved
6 # Author: Alexandre Cazalis
8 # Gestion attente lames esclaves au boot (ping,ssh)
10 # 2013-11-20 : V1.2 LMa
11 # - Ajout de la personalisation de la commande a executer
12 # par defaut (uptime). Ajout attente montage nfs avant demarrage
13 # 2014-05-28 : V1.3 LMa
14 # - Ajout d'un mode foreground pour ne tenter qu'une fois chaque commande
15 # - Ajout d'une commande pour exclude la lame maitre
17 # 2014-10-28 : Change owner
18 # ============================================================================
25 PROGNAME
=$
(basename $0)
30 echo "usage: $PROGNAME [-c command] [-h] [-i] [-o] [-t seconds] [-v] [-w] [-x] host1 host2..."
31 echo " -c: set command (default '$CMD')"
32 echo " -h: help message"
33 echo " -i: infinity loop mode [default]"
34 echo " -o: only try ones"
36 echo " -v: version message"
38 echo " -x: avoid master blade"
42 while [ $# -gt 0 ]; do
48 -t) shift; [[ "$1" =~
[^
0-9] ]] && { echo "incorrect timeout ($1)"; exit 1;}; TIMEOUT
=$1;;
49 -v) echo "$PROGNAME: version $VER"; exit;;
58 [ "$list" ] || list
=$
(awk '{sub(/#.*/, "")} /trc[0-9][0-9]/ && ! /-rf/ {print $2}' /etc
/hosts
)
59 list
=$
(echo $list" "|
sed s
/$EXCLUDE//)
62 if [ "$TIMEOUT" ]; then
63 trap "echo 'timeout expired (${TIMEOUT}s)'; exit 0;" SIGVTALRM
64 ( sleep $TIMEOUT; kill -SIGVTALRM $$
2>/dev
/null
; [ $?
-eq 0 ] && rc
=1 || rc
=0; exit $rc) &
73 ping -c 1 $host >&/dev
/null
&& { ssh -t -o ConnectTimeout
=1 root@
$host "$CMD" 2>/dev
/null
&& stat
=1 ||
echo "soon..."; } ||
echo
74 [ "$MODE" = "wait" -a $stat -eq 1 ] && list
=${list/$host }
76 [ "$MODE" = "ones" ] && break;
77 [[ "$list" =~
[a-zA-Z0-9_-
] ]] && sleep 1 ||
break;