ds_ssh 680 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # Copyright 2020 The Microsoft DeepSpeed Team
  3. command -v pdsh
  4. if [ $? != 0 ]; then
  5. echo "Cannot find pdsh, please install via 'apt-get install -y pdsh'"
  6. exit 1
  7. fi
  8. hostfile=/job/hostfile
  9. while getopts "h?f:" opt; do
  10. case "$opt" in
  11. h|\?)
  12. echo "-f <hostfile>: specify a hostfile, defaults to /job/hostfile"
  13. exit 0
  14. ;;
  15. f)
  16. hostfile=$OPTARG
  17. shift $((OPTIND-1))
  18. ;;
  19. esac
  20. done
  21. echo "hostfile=$hostfile"
  22. if [ -f $hostfile ]; then
  23. hosts=`cat $hostfile | awk '{print $1}' | paste -sd "," -`
  24. export PDSH_RCMD_TYPE=ssh
  25. pdsh -w ${hosts} $@
  26. else
  27. echo "Missing hostfile at ${hostfile}, unable to proceed"
  28. fi