aboutsummaryrefslogtreecommitdiff
path: root/invoke_session_oe
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2015-02-13 03:17:15 +0000
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2015-02-19 12:33:58 +0000
commit2c58c1e4396555054be7f4859f3e0848d5dec9a3 (patch)
tree2356b3f23b1227fea107cf3a9a56bf2fea55a9c2 /invoke_session_oe
parent3b3432653c19b99d81b4c4651907b7ee36a192ca (diff)
hacking-session: close session in case of inactivityHEADmaster
If user doesn't log in to hacking session within 60 minutes, the session is terminated. Also default behavior is changed and the session is terminated upon logging out. When user would like to continue hacking session the 'continue_hacking' command is provided. Android multinode hacking session was fixed and it closes both nodes properly. Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org> Change-Id: I2936067fcdc17616a2dd85bf8dd58c1d76b6f26c
Diffstat (limited to 'invoke_session_oe')
-rwxr-xr-xinvoke_session_oe44
1 files changed, 41 insertions, 3 deletions
diff --git a/invoke_session_oe b/invoke_session_oe
index 59b7847..8b6fe0c 100755
--- a/invoke_session_oe
+++ b/invoke_session_oe
@@ -1,8 +1,13 @@
#!/bin/sh
# Usage ./invoke_session <gateway>
-# Hack for now until lava-test-shell is smart enough to know it's dispatcher ip
-gateway=$1
+# If gateway isn't set we will guess it based on the default route
+if [ -z "$1" ]; then
+ gateway=`ip route get 8.8.8.8 | grep via | cut -d ' ' -f3`
+else
+ gateway=$1
+fi
+
echo "Target's Gateway: $gateway"
# Copy invoke session
@@ -31,13 +36,46 @@ echo ")"
echo "*********************************************************************************************"
echo ""
echo ""
+
+cat <<EOF > ~/.bash_logout
+stop_hacking
+EOF
+
mkdir -p /run
mkdir -p /run/hacking
echo $$ > /run/hacking/hacking.pid
+TIMESTAMP=`stat -c %Y /run/hacking/hacking.pid`
+STARTED=false
+TERMINATED=false
echo "Hacking session active..."
+lava-test-case hacking-session-active --result pass
+tail -f /var/log/syslog &
+echo $! > /run/hacking/tail.pid
while [ -f /run/hacking/hacking.pid ]
do
+ date
+ echo "===================="
+ who
+ echo "===================="
+ echo ""
sleep 10
+ LOGGEDIN=`who | grep pts | wc -l`
+ if ! $STARTED && [ $LOGGEDIN -gt 0 ]; then
+ STARTED=true
+ elif ! $STARTED && [ $LOGGEDIN -eq 0 ]; then
+ NOW=`date +%s`
+ ELAPSED=`expr $NOW - $TIMESTAMP`
+ if [ $ELAPSED -gt 3600 ]; then
+ TERMINATED=true
+ echo "No user logged in. Terminating session..."
+ lava-test-case hacking-session-terminated --result fail --measurement ${ELAPSED} --units seconds
+ stop_hacking
+ fi
+ fi
done
+kill `cat /run/hacking/tail.pid`
+rm /run/hacking/tail.pid
echo "Hacking session ended..."
-echo "<LAVA_TEST_RUNNER>: exiting"
+if ! ${TERMINATED}; then
+ lava-test-case hacking-session-terminated --result pass
+fi