Skip to content

Commit

Permalink
allow passing hostfile to ds_ssh (#1504)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffra authored Oct 30, 2021
1 parent ee6a92c commit 163f568
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions bin/ds_ssh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ 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}, executing command locally"
$@
echo "Missing hostfile at ${hostfile}, unable to proceed"
fi

0 comments on commit 163f568

Please sign in to comment.