Derrick J. Wippler | aaa0dbb | 2012-02-21 09:53:53 -0600 | [diff] [blame] | 1 | #! /usr/bin/env bash |
| 2 | |
| 3 | # This script rejoins an existing screen, or re-creates a |
| 4 | # screen session from a previous run of stack.sh. |
| 5 | |
| 6 | TOP_DIR=`dirname $0` |
| 7 | |
Doug Hellmann | 88317ad | 2013-06-06 15:42:13 -0400 | [diff] [blame] | 8 | # Import common functions in case the localrc (loaded via stackrc) |
| 9 | # uses them. |
| 10 | source $TOP_DIR/functions |
| 11 | |
Jiajun Liu | f02be85 | 2013-05-22 08:55:25 +0000 | [diff] [blame] | 12 | source $TOP_DIR/stackrc |
| 13 | |
Nikolay Fedotov | 7f66503 | 2016-02-24 16:07:18 +0000 | [diff] [blame] | 14 | SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc |
Derrick J. Wippler | aaa0dbb | 2012-02-21 09:53:53 -0600 | [diff] [blame] | 15 | # if screenrc exists, run screen |
Nikolay Fedotov | 7f66503 | 2016-02-24 16:07:18 +0000 | [diff] [blame] | 16 | if [[ -e $SCREENRC ]]; then |
| 17 | if screen -ls | egrep -q "[0-9]+.${SCREEN_NAME}"; then |
Derrick J. Wippler | aaa0dbb | 2012-02-21 09:53:53 -0600 | [diff] [blame] | 18 | echo "Attaching to already started screen session.." |
Nikolay Fedotov | 7f66503 | 2016-02-24 16:07:18 +0000 | [diff] [blame] | 19 | exec screen -r $SCREEN_NAME |
Derrick J. Wippler | aaa0dbb | 2012-02-21 09:53:53 -0600 | [diff] [blame] | 20 | fi |
Nikolay Fedotov | 7f66503 | 2016-02-24 16:07:18 +0000 | [diff] [blame] | 21 | exec screen -c $SCREENRC |
Derrick J. Wippler | aaa0dbb | 2012-02-21 09:53:53 -0600 | [diff] [blame] | 22 | fi |
| 23 | |
Nikolay Fedotov | 7f66503 | 2016-02-24 16:07:18 +0000 | [diff] [blame] | 24 | echo "Couldn't find $SCREENRC file; have you run stack.sh yet?" |
Derrick J. Wippler | aaa0dbb | 2012-02-21 09:53:53 -0600 | [diff] [blame] | 25 | exit 1 |