|
|
@ -1,6 +1,6 @@ |
|
|
|
#!/bin/sh |
|
|
|
# |
|
|
|
# tabssh.sh, Copyright © 2013 Matteo Cypriani <mcy@lm7.fr> |
|
|
|
# tabssh.sh, Copyright © 2013, 2019 Matteo Cypriani <mcy@lm7.fr> |
|
|
|
# (Formerly named cluster-ssh.sh) |
|
|
|
# |
|
|
|
# This program is free software. It comes without any warranty, to |
|
|
@ -56,9 +56,14 @@ elif [ $# -ne 1 ] ; then |
|
|
|
fi |
|
|
|
|
|
|
|
# Check dependencies |
|
|
|
SCREEN=$(command -v screen) |
|
|
|
if [ -z "$SCREEN" ] ; then |
|
|
|
err "GNU screen is required by this script." |
|
|
|
TMUX_CMD=$(command -v tmux) |
|
|
|
SCREEN_CMD=$(command -v screen) |
|
|
|
if [ -n "$TMUX_CMD" ] ; then |
|
|
|
echo "tmux is available, we'll be using it." |
|
|
|
elif [ -n "$SCREEN_CMD" ] ; then |
|
|
|
echo "tmux is not available, we'll be using GNU screen instead." |
|
|
|
else |
|
|
|
err "Either tmux or GNU screen is required by this script." |
|
|
|
exit $EXIT_DEPENDENCY |
|
|
|
fi |
|
|
|
|
|
|
@ -82,6 +87,10 @@ fi |
|
|
|
# Create the screen tabs |
|
|
|
while read -r HOST ; do |
|
|
|
SSH="ssh ${LOGIN}${HOST}" |
|
|
|
# shellcheck disable=SC2086 |
|
|
|
$SCREEN -t "$SSH" $SSH |
|
|
|
if [ -n "$TMUX_CMD" ] ; then |
|
|
|
$TMUX_CMD new-window -d -n "$SSH" -- "$SSH" |
|
|
|
else |
|
|
|
# shellcheck disable=SC2086 |
|
|
|
$SCREEN_CMD -t "$SSH" $SSH |
|
|
|
fi |
|
|
|
done <"$HOSTS" |