| 1 | 1 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,18 @@ |
| 0 |
+#! /usr/bin/env bash |
|
| 1 |
+ |
|
| 2 |
+# This script rejoins an existing screen, or re-creates a |
|
| 3 |
+# screen session from a previous run of stack.sh. |
|
| 4 |
+ |
|
| 5 |
+TOP_DIR=`dirname $0` |
|
| 6 |
+ |
|
| 7 |
+# if screenrc exists, run screen |
|
| 8 |
+if [[ -e $TOP_DIR/stack-screenrc ]]; then |
|
| 9 |
+ if screen -ls | egrep -q "[0-9].stack"; then |
|
| 10 |
+ echo "Attaching to already started screen session.." |
|
| 11 |
+ exec screen -r stack |
|
| 12 |
+ fi |
|
| 13 |
+ exec screen -c $TOP_DIR/stack-screenrc |
|
| 14 |
+fi |
|
| 15 |
+ |
|
| 16 |
+echo "Couldn't find $TOP_DIR/stack-screenrc file; have you run stack.sh yet?" |
|
| 17 |
+exit 1 |
| ... | ... |
@@ -1249,10 +1249,31 @@ fi |
| 1249 | 1249 |
# so send the start command by forcing text into the window. |
| 1250 | 1250 |
# Only run the services specified in ``ENABLED_SERVICES`` |
| 1251 | 1251 |
|
| 1252 |
-# our screen helper to launch a service in a hidden named screen |
|
| 1252 |
+# Our screenrc file builder |
|
| 1253 |
+function screen_rc {
|
|
| 1254 |
+ SCREENRC=$TOP_DIR/stack-screenrc |
|
| 1255 |
+ if [[ ! -e $SCREENRC ]]; then |
|
| 1256 |
+ # Name the screen session |
|
| 1257 |
+ echo "sessionname stack" > $SCREENRC |
|
| 1258 |
+ # Set a reasonable statusbar |
|
| 1259 |
+ echo 'hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%< %= %H"' >> $SCREENRC
|
|
| 1260 |
+ echo "screen -t stack bash" >> $SCREENRC |
|
| 1261 |
+ fi |
|
| 1262 |
+ # If this service doesn't already exist in the screenrc file |
|
| 1263 |
+ if ! grep $1 $SCREENRC 2>&1 > /dev/null; then |
|
| 1264 |
+ NL=`echo -ne '\015'` |
|
| 1265 |
+ echo "screen -t $1 bash" >> $SCREENRC |
|
| 1266 |
+ echo "stuff \"$2$NL\"" >> $SCREENRC |
|
| 1267 |
+ fi |
|
| 1268 |
+} |
|
| 1269 |
+ |
|
| 1270 |
+# Our screen helper to launch a service in a hidden named screen |
|
| 1253 | 1271 |
function screen_it {
|
| 1254 | 1272 |
NL=`echo -ne '\015'` |
| 1255 | 1273 |
if is_service_enabled $1; then |
| 1274 |
+ # Append the service to the screen rc file |
|
| 1275 |
+ screen_rc "$1" "$2" |
|
| 1276 |
+ |
|
| 1256 | 1277 |
screen -S stack -X screen -t $1 |
| 1257 | 1278 |
# sleep to allow bash to be ready to be send the command - we are |
| 1258 | 1279 |
# creating a new window in screen and then sends characters, so if |