scripts/cluster/cluster-run.sh

30 lines
849 B
Bash
Executable File

#!/bin/sh
#
# cluster-run.sh, Copyright © 2013 Matteo Cypriani <mcy@lm7.fr>
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
#
# Run a command on a list of remote hosts using Parallel SSH.
if [ $# -lt 2 ] ; then
echo "Usage: $0 <hosts_list> <command>"
exit 1
fi
PSSH=$(command -v parallel-ssh || command -v pssh)
if [ "$PSSH" = "" ] ; then
echo "Parallel SSH (pssh) is required for this script to work."
exit 2
fi
HOSTS="$HOME/.config/cluster/$1.lst"
shift
echo "Using file '$HOSTS' as hosts' list."
echo "Command: $@"
exec $PSSH --print -l root -h "$HOSTS" -- $@