blob: 7048865fc9243067a7bf47595e650d34cb9cc030 [file] [log] [blame]
Derrick J. Wippleraaa0dbb2012-02-21 09:53:53 -06001#! /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
6TOP_DIR=`dirname $0`
7
Doug Hellmann88317ad2013-06-06 15:42:13 -04008# Import common functions in case the localrc (loaded via stackrc)
9# uses them.
10source $TOP_DIR/functions
11
Jiajun Liuf02be852013-05-22 08:55:25 +000012source $TOP_DIR/stackrc
13
Nikolay Fedotov7f665032016-02-24 16:07:18 +000014SCREENRC=$TOP_DIR/$SCREEN_NAME-screenrc
Derrick J. Wippleraaa0dbb2012-02-21 09:53:53 -060015# if screenrc exists, run screen
Nikolay Fedotov7f665032016-02-24 16:07:18 +000016if [[ -e $SCREENRC ]]; then
17 if screen -ls | egrep -q "[0-9]+.${SCREEN_NAME}"; then
Derrick J. Wippleraaa0dbb2012-02-21 09:53:53 -060018 echo "Attaching to already started screen session.."
Nikolay Fedotov7f665032016-02-24 16:07:18 +000019 exec screen -r $SCREEN_NAME
Derrick J. Wippleraaa0dbb2012-02-21 09:53:53 -060020 fi
Nikolay Fedotov7f665032016-02-24 16:07:18 +000021 exec screen -c $SCREENRC
Derrick J. Wippleraaa0dbb2012-02-21 09:53:53 -060022fi
23
Nikolay Fedotov7f665032016-02-24 16:07:18 +000024echo "Couldn't find $SCREENRC file; have you run stack.sh yet?"
Derrick J. Wippleraaa0dbb2012-02-21 09:53:53 -060025exit 1