scripts/ssh_tools/multiping.sh

33 lines
890 B
Bash
Raw Normal View History

2013-04-29 22:43:41 +02:00
#!/bin/sh
#
# cluster-ping.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.
#
# Ping a list of remote hosts using fping.
# Check arguments
2013-04-29 22:43:41 +02:00
if [ $# -ne 1 ] ; then
echo "Usage: $0 <hosts_list>"
exit 1
fi
# Hosts' list file
if [ -z "$XDG_CONFIG_HOME" ] ; then
XDG_CONFIG_HOME="$HOME/.config"
fi
HOSTS="$XDG_CONFIG_HOME/cluster/$1.lst"
2013-04-29 22:43:41 +02:00
echo "Using file '$HOSTS' as hosts' list."
if [ ! -f "$HOSTS" ] ; then
echo "The hosts' list file doesn't exist or is not a regular file."
exit 2
fi
2013-04-29 22:43:41 +02:00
# Go!
# shellcheck disable=SC2046
2013-04-29 22:43:41 +02:00
exec fping $(cat "$HOSTS") 2>/dev/null