blob: 843a39fcacbb3da56dbafff01c23982d8da5fd5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/bin/bash
#
# simple autossh and screen wrapper
#
BASENAME="`basename $0`"
DEST="$1"
COMMAND="$2"
if [ -z "$DEST" ]; then
exit 1
fi
if [ "$BASENAME" == "shells" ]; then
# Remote screen shell using autossh
#
# We're setting TERM for compatibility with older systems without rxvt-unicode-256
# support, see https://bbs.archlinux.org/viewtopic.php?id=50647
if [ "$COMMAND" == "root" ]; then
autossh $DEST -t -- TERM=rxvt sudo screen -x
else
autossh $DEST -t -- TERM=rxvt screen -x $COMMAND
fi
else
if [ -z "$COMMAND" ] && screen -ls $DEST | grep -q "There is a screen on"; then
# Local existing screen shell
wscreen $DEST
elif [ -z "$COMMAND" ] && [ "$DEST" == "root" ]; then
# Local root shell
sudo screen -x
elif [ "$DEST" == "local" ]; then
# Local screen shell
wscreen $COMMAND
else
# Remote shell using autossh
autossh $DEST -t -- $COMMAND
fi
fi
|