diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-10-02 14:23:43 -0700 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-10-02 21:11:53 -0700 |
commit | dfb664a1822f41cbd4f1f5a8ce6fcac4e1547bf6 (patch) | |
tree | c4271f8edf108c8d4e4b353be3c67f9fb68a7ca1 /selftest/in_screen | |
parent | 29e1a847ddb28aee8ae04578b74cb8ab97427b96 (diff) | |
download | samba-dfb664a1822f41cbd4f1f5a8ce6fcac4e1547bf6.tar.gz samba-dfb664a1822f41cbd4f1f5a8ce6fcac4e1547bf6.tar.bz2 samba-dfb664a1822f41cbd4f1f5a8ce6fcac4e1547bf6.zip |
s4-selftest: support 'make testenv SCREEN=1'
this can be used to start a test envioronment in screen windows.
Use:
make testenv SCREEN=1 SELFTEST_TESTENV=dc
to launch just one environment (in this case, "dc")
Diffstat (limited to 'selftest/in_screen')
-rwxr-xr-x | selftest/in_screen | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/selftest/in_screen b/selftest/in_screen index 0704ae5390..8a3cc5c601 100755 --- a/selftest/in_screen +++ b/selftest/in_screen @@ -6,6 +6,17 @@ SERVERNAME="$ENVNAME" [ -z "$SERVERNAME" ] && SERVERNAME="base" basedir=$TMPDIR +[ -r $basedir/$SERVERNAME.pid ] && { + for i in $(seq 2 100); do + if [ ! -r "$basedir/${SERVERNAME}-$i.pid" ]; then + SERVERNAME="${SERVERNAME}-$i" + break + fi + done +} + +rm -f $basedir/$SERVERNAME.* + # set most of the environment vars we have in the screen session too _ENV="" vars=$(mktemp) @@ -17,7 +28,7 @@ printenv | cat <<EOF > $basedir/$SERVERNAME.launch echo \$\$ > $basedir/$SERVERNAME.pid . $basedir/$SERVERNAME.vars - echo "\$(date) starting $@" >> $basedir/$SERVERNAME.log + echo "\$(date) starting $SERVERNAME" >> $basedir/$SERVERNAME.log $@ echo \$? > $basedir/$SERVERNAME.status read parent < $basedir/$SERVERNAME.parent.pid @@ -26,17 +37,18 @@ EOF pid=$$ cleanup() { + trap "exit 1" SIGINT SIGTERM SIGPIPE [ -r $basedir/$SERVERNAME.status ] && { read status < $basedir/$SERVERNAME.status echo "$(date) samba exited with status $status" >> $basedir/$SERVERNAME.log exit $status } read pid < $basedir/$SERVERNAME.pid - echo "$(date) Killing samba pid $pid" >> $basedir/$SERVERNAME.log + echo "$(date) Killing samba pid $pid from $$" >> $basedir/$SERVERNAME.log if [ "$pid" = "$$" ]; then exit 1 fi - kill $pid 2>&1 + kill -9 $pid 2>&1 exit 1 } |