-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdq-on-all
executable file
·39 lines (34 loc) · 1.03 KB
/
dq-on-all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
CLUSTER_START=${DQ_CLUSTER_START:-1}
CLUSTER_CNT=${DQ_CLUSTER_CNT:-24}
# not specifying array due to http://stackoverflow.com/questions/5564418/exporting-an-array-in-bash-script
EXCLUDE_START=${DQ_EXCLUDE_START:-25}
EXCLUDE_END=${DQ_EXCLUDE_END:-26}
CLUSTER_EXCLUDE=$(for i in `seq $EXCLUDE_START $EXCLUDE_END`; do echo $i; done)
CLUSTER=$(hostname -s | sed 's/[0-9]//g')
D=$(cd `dirname $0` && pwd)
Hs=$(for i in `seq $CLUSTER_START $CLUSTER_CNT`; do
skip=false;
for j in ${CLUSTER_EXCLUDE[@]}; do
if [[ "$i" -eq "$j" ]]; then
skip=true;
fi;
done;
if ! $skip; then
echo $CLUSTER$i;
fi
done);
SSH="ssh -q -x -o BatchMode=yes -o ConnectTimeout=10 -o ServerAliveInterval=3"
function cleanup {
echo "Cleaning up.."
kill -INT -- 0
sleep 0.1
kill -KILL -- 0
wait
}
for h in $Hs; do
$SSH $USER@$h CPATH=/dq:$PATH:$D:$D/scripts CPWD=$PWD $D/scripts/helper-on-all "\"$@\"" &
done
trap cleanup SIGINT
trap '' SIGTERM
wait