File size: 680 Bytes
d75ad39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# Copyright 2020 The Microsoft DeepSpeed Team

command -v pdsh
if [ $? != 0 ]; then
    echo "Cannot find pdsh, please install via 'apt-get install -y pdsh'"
    exit 1
fi

hostfile=/job/hostfile

while getopts "h?f:" opt; do
  case "$opt" in
    h|\?)
      echo "-f <hostfile>: specify a hostfile, defaults to /job/hostfile"
      exit 0
      ;;
    f)
      hostfile=$OPTARG
      shift $((OPTIND-1))
      ;;
  esac
done

echo "hostfile=$hostfile"

if [ -f $hostfile ]; then
    hosts=`cat $hostfile | awk '{print $1}' | paste -sd "," -`
    export PDSH_RCMD_TYPE=ssh
    pdsh -w ${hosts} $@
else
    echo "Missing hostfile at ${hostfile}, unable to proceed"
fi