aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy.Anzaku <timothy.anzaku@linaro.org>2014-06-23 22:56:42 +0900
committeresla <slacowr@gmail.com>2014-07-17 13:52:49 +0900
commitce682ddd4488e2e65b836bce91be4a1237d2676f (patch)
tree10a1264740f11b3385246b9095c389e2df8b8158
parentd894fa61d2bcfe4b6d48f2faeea2781ecf3a7036 (diff)
Add hacking session for Fedora
Change-Id: I1bcff3b0e6550022cb7a98ab393aca5c37fb01d7
-rw-r--r--hacking-session-fedora.yaml15
-rwxr-xr-xinvoke_session_fedora42
-rwxr-xr-xsetup_session_fedora14
-rwxr-xr-xstop_hacking_fedora4
4 files changed, 75 insertions, 0 deletions
diff --git a/hacking-session-fedora.yaml b/hacking-session-fedora.yaml
new file mode 100644
index 0000000..87fdafc
--- /dev/null
+++ b/hacking-session-fedora.yaml
@@ -0,0 +1,15 @@
+metadata:
+ name: hacking-session-fedora
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "SSH Hacking Session"
+params:
+ PUB_KEY: None
+ GATEWAY: 10.0.0.1
+install:
+ deps:
+ - openssh-server
+ - net-tools
+run:
+ steps:
+ - ./setup_session_fedora "$PUB_KEY"
+ - ./invoke_session_fedora "$GATEWAY"
diff --git a/invoke_session_fedora b/invoke_session_fedora
new file mode 100755
index 0000000..99a45d7
--- /dev/null
+++ b/invoke_session_fedora
@@ -0,0 +1,42 @@
+#!/bin/bash
+# Usage ./invoke_session <gateway>
+
+# Hack for now until lava-test-shell is smart enough to know it's dispatcher ip
+gateway=$1
+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 ' | awk '{print $2}')
+hostname=$(cat /etc/hostname)
+
+# Set the PATH to use the LAVA api
+echo "export PATH=/lava/bin/:$PATH" > ~/.bashrc
+
+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/hacking
+echo $$ > /run/hacking/hacking.pid
+echo "Hacking session active..."
+while [ -f /run/hacking/hacking.pid ]
+do
+ sleep 10
+done
+echo "Hacking session ended..."
+echo "<LAVA_TEST_RUNNER>: exiting"
diff --git a/setup_session_fedora b/setup_session_fedora
new file mode 100755
index 0000000..c90449b
--- /dev/null
+++ b/setup_session_fedora
@@ -0,0 +1,14 @@
+#!/bin/bash
+# Usage ./setup_session <pub_key>
+
+chmod a+x stop_hacking_fedora
+cp stop_hacking_fedora /bin/stop_hacking
+chmod a+x invoke_session_fedora
+cp invoke_session_fedora /bin/invoke_session
+
+mkdir -p ~/.ssh/
+echo $1 >> ~/.ssh/authorized_keys
+echo "Public Key Installed: $1"
+
+service sshd restart
+echo "sshd re-started"
diff --git a/stop_hacking_fedora b/stop_hacking_fedora
new file mode 100755
index 0000000..9fa2e47
--- /dev/null
+++ b/stop_hacking_fedora
@@ -0,0 +1,4 @@
+#!/bin/bash
+rm /run/hacking/hacking.pid
+rm ~/.ssh/authorized_keys
+service sshd stop