ctdb-build: Move internal include files in a separate directory
[samba.git] / selftest / in_screen
index 8a3cc5c601b43c60e5a4c12be76e5b73c61ceb05..5468a216e310fb7c2c2cc27804f97252fac37486 100755 (executable)
@@ -1,10 +1,24 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 export TMPDIR="$SELFTEST_TMPDIR"
 
 SERVERNAME="$ENVNAME"
 [ -z "$SERVERNAME" ] && SERVERNAME="base"
 basedir=$TMPDIR
 
 export TMPDIR="$SELFTEST_TMPDIR"
 
 SERVERNAME="$ENVNAME"
 [ -z "$SERVERNAME" ] && SERVERNAME="base"
 basedir=$TMPDIR
+osname=$(uname)
+if [ "$osname" = "Linux" ]; then
+       vars=$(mktemp)
+else
+       vars=$(mktemp -t tmpsmb)
+       function seq() {
+               dpt=$1
+               end=$2
+               while [ $dpt -le $end ]; do
+                       echo "$dpt"
+                       dpt=$(( $dpt + 1))
+               done
+       }
+fi
 
 [ -r $basedir/$SERVERNAME.pid ] && {
     for i in $(seq 2 100); do
 
 [ -r $basedir/$SERVERNAME.pid ] && {
     for i in $(seq 2 100); do
@@ -19,13 +33,13 @@ rm -f $basedir/$SERVERNAME.*
 
 # set most of the environment vars we have in the screen session too
 _ENV=""
 
 # set most of the environment vars we have in the screen session too
 _ENV=""
-vars=$(mktemp)
 printenv |
   egrep -v '^TERMCAP|^WINDOW|^SHELL|^STY|^SHLVL|^SAMBA_VALGRIND|\$' |
   egrep '^[A-Z]' |
   sed "s/\(^[^=]*=\)\(.*\)/export \1'\2'/g" > $basedir/$SERVERNAME.vars
 
 cat <<EOF > $basedir/$SERVERNAME.launch
 printenv |
   egrep -v '^TERMCAP|^WINDOW|^SHELL|^STY|^SHLVL|^SAMBA_VALGRIND|\$' |
   egrep '^[A-Z]' |
   sed "s/\(^[^=]*=\)\(.*\)/export \1'\2'/g" > $basedir/$SERVERNAME.vars
 
 cat <<EOF > $basedir/$SERVERNAME.launch
+cd $PWD
  echo \$\$ > $basedir/$SERVERNAME.pid
  . $basedir/$SERVERNAME.vars
  echo "\$(date) starting $SERVERNAME" >> $basedir/$SERVERNAME.log
  echo \$\$ > $basedir/$SERVERNAME.pid
  . $basedir/$SERVERNAME.vars
  echo "\$(date) starting $SERVERNAME" >> $basedir/$SERVERNAME.log
@@ -55,7 +69,11 @@ cleanup() {
 rm -f $basedir/$SERVERNAME.status $basedir/$SERVERNAME.log
 echo $$ > $basedir/$SERVERNAME.parent.pid
 trap cleanup SIGINT SIGTERM SIGPIPE
 rm -f $basedir/$SERVERNAME.status $basedir/$SERVERNAME.log
 echo $$ > $basedir/$SERVERNAME.parent.pid
 trap cleanup SIGINT SIGTERM SIGPIPE
-screen -r -X screen -t test:$SERVERNAME bash $basedir/$SERVERNAME.launch
+if [[ "$TMUX" ]]; then
+    tmux new-window -n test:$SERVERNAME "bash $basedir/$SERVERNAME.launch"
+else
+    screen -r -X screen -t test:$SERVERNAME bash $basedir/$SERVERNAME.launch
+fi
 echo "$(date) waiting in $$" >> $basedir/$SERVERNAME.log
 read stdin_var
 echo "$(date) EOF on stdin" >> $basedir/$SERVERNAME.log
 echo "$(date) waiting in $$" >> $basedir/$SERVERNAME.log
 read stdin_var
 echo "$(date) EOF on stdin" >> $basedir/$SERVERNAME.log