2015-04-19 15:34:24 +02:00
|
|
|
#!/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
|
|
|
|
|
2015-09-10 22:02:26 +02:00
|
|
|
# main screen (physical host)
|
2023-08-10 21:47:21 +02:00
|
|
|
screen -d -m -S "$session" -t "$(hostname -s)"
|
2015-04-19 15:34:24 +02:00
|
|
|
|
2015-09-10 22:02:26 +02:00
|
|
|
# servers' screens : open a ssh connexion from the host to them, then rename it
|
2015-04-19 15:34:24 +02:00
|
|
|
for server in $servers
|
|
|
|
do
|
2015-09-10 22:02:26 +02:00
|
|
|
window=$(( window + 1 ))
|
2023-08-10 21:47:21 +02:00
|
|
|
screen -S "$session" -X screen ssh "$server"
|
|
|
|
screen -S "$session" -p "$window" -X title "$server"
|
2015-04-19 15:34:24 +02:00
|
|
|
done
|
|
|
|
|
2015-09-10 22:04:22 +02:00
|
|
|
# do not attach screen if "-d" option is set
|
2023-08-10 21:47:21 +02:00
|
|
|
if [ -n "$1" ]
|
2015-09-10 22:04:22 +02:00
|
|
|
then
|
2023-08-10 21:47:21 +02:00
|
|
|
if [ "$1" = "-d" ]
|
2015-09-10 22:04:22 +02:00
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
2016-03-28 15:54:03 +02:00
|
|
|
|
|
|
|
# dirty hack for unhappy services
|
2016-12-06 22:26:07 +01:00
|
|
|
#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"
|
2016-03-28 15:54:03 +02:00
|
|
|
|
|
|
|
# attach to freshly-created screen
|
2015-04-19 15:34:24 +02:00
|
|
|
screen -r $session -p 0
|