[cluster] Test the existence of the hosts' list

We now test if the hosts' list file exists before to work on it.
This commit is contained in:
Matteo Cypriani 2013-05-20 14:46:39 -04:00
parent 3a505db37b
commit 0eeeab14fc
4 changed files with 19 additions and 1 deletions

View File

@ -94,6 +94,10 @@ HOSTS_LIST_NAME="$1"
HOSTS="$HOME/.config/cluster/${HOSTS_LIST_NAME}.lst"
shift
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 3
fi
# Login
if [ "$LOGIN" != "" ] ; then

View File

@ -10,13 +10,19 @@
#
# Ping a list of remote hosts using fping.
# Check arguments
if [ $# -ne 1 ] ; then
echo "Usage: $0 <hosts_list>"
exit 1
fi
# Hosts' list file
HOSTS="$HOME/.config/cluster/$1.lst"
shift
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
# Go!
exec fping $(cat "$HOSTS") 2>/dev/null

View File

@ -47,6 +47,10 @@ fi
HOSTS="$HOME/.config/cluster/$1.lst"
shift
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
# Login
if [ "$LOGIN" != "" ] ; then

View File

@ -38,6 +38,10 @@ fi
HOSTS="$HOME/.config/cluster/$1.lst"
shift
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
# Login
if [ "$LOGIN" != "" ] ; then