44 lines
1.1 KiB
Bash
Executable file
44 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
# superscreen: open a screen session with ssh connections to some servers
|
|
|
|
window=0
|
|
session="default"
|
|
servers="db dns ftp mail web"
|
|
|
|
# wipe dead screens
|
|
screen -wipe
|
|
|
|
if screen -list | grep -q "$session"
|
|
then
|
|
echo "Error: session \"$session\" already exists; please kill it first."
|
|
echo "type \"screen -X -S $session quit\" to do so."
|
|
exit 1
|
|
fi
|
|
|
|
# main screen (physical host)
|
|
screen -d -m -S $session -t `hostname -s`
|
|
|
|
# servers' screens : open a ssh connexion from the host to them, then rename it
|
|
for server in $servers
|
|
do
|
|
window=$(( window + 1 ))
|
|
screen -S $session -X screen ssh $server
|
|
screen -S $session -p $window -X title $server
|
|
done
|
|
|
|
# do not attach screen if "-d" option is set
|
|
if [ ! -z "$1" ]
|
|
then
|
|
if [ $1 == "-d" ]
|
|
then
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
# dirty hack for unhappy services
|
|
#for jail in `seq 0 6`; do screen -p $jail -X stuff "/usr/local/bin/nrpe2 restart^M"; done
|
|
#screen -p ftp -X stuff "service vsftpd_ipv6 start^M"
|
|
#screen -p mail -X stuff "service qmailsmtpd start^M"
|
|
|
|
# attach to freshly-created screen
|
|
screen -r $session -p 0
|