summaryrefslogtreecommitdiff
path: root/invoke_session_oe
blob: e1cb956a4c613ffa8795176c79aa85ddbfe5497f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
# Usage ./invoke_session <gateway>

# Hack for now until lava-test-shell is smart enough to know it's dispatcher ip
gateway=$1
listener_addr=$2
listener_port=$3
echo "Target's Gateway: $gateway"

# Copy invoke session
cp /bin/invoke_session /etc/init.d/invoke_session

# Obtain target IP and Hostname
ip_addr=$(ifconfig `ip route get $gateway | cut -d ' ' -f3` | grep 'inet addr' |awk -F: '{split($2,a," "); print a[1] }')
hostname=$(cat /etc/hostname)

# Set the PATH to use the LAVA api
echo "export PATH=/lava/bin/:$PATH" > ~/.shrc

echo ""
echo ""
echo "*********************************************************************************************"
echo -n "Please connect to: "
echo -n "ssh "
echo -n "-o UserKnownHostsFile=/dev/null "
echo -n "-o StrictHostKeyChecking=no "
echo -n "root@"
echo -n $ip_addr
echo -n " "
echo -n "("
echo -n $hostname
echo ")"
echo "*********************************************************************************************"
echo ""
echo ""
mkdir -p /run
mkdir -p /run/hacking
echo $$ > /run/hacking/hacking.pid

echo "${ip_addr}" | nc "${listener_addr}" "${listener_port}"

#suspend in a way that is portable across shells and doesn't involve a busy-wait
pid=
trap 'kill $pid
      trap - SIGCONT' SIGCONT
echo "Benchmarking session active..."
sleep 999d& #timeout after 2 or 3 years... the job is likely to have a rather shorter timeout associated with it
pid=$!
wait

echo "Benchmarking session ended..."
echo "<LAVA_TEST_RUNNER>: exiting"