[ssh_tools] tabssh: check dependencies

This commit is contained in:
Matteo Cypriani 2019-10-21 18:22:13 +02:00
parent 81988f3c00
commit c661ccd8eb
1 changed files with 9 additions and 1 deletions

View File

@ -18,6 +18,7 @@ set -u
# Exit codes
readonly EXIT_SUCCESS=0
readonly EXIT_USAGE=127
readonly EXIT_DEPENDENCY=4
readonly EXIT_HOSTS_LIST=6
print_usage()
@ -54,6 +55,13 @@ elif [ $# -ne 1 ] ; then
bad_usage "Wrong number of arguments."
fi
# Check dependencies
SCREEN=$(command -v screen)
if [ -z "$SCREEN" ] ; then
err "GNU screen is required by this script."
exit $EXIT_DEPENDENCY
fi
# Hosts list file
[ -z ${XDG_CONFIG_HOME+x} ] && XDG_CONFIG_HOME="$HOME/.config"
HOSTS_LIST_NAME="$1"
@ -75,5 +83,5 @@ fi
while read -r HOST ; do
SSH="ssh ${LOGIN}${HOST}"
# shellcheck disable=SC2086
screen -t "$SSH" $SSH
$SCREEN -t "$SSH" $SSH
done <"$HOSTS"