aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemi Duraffort <remi.duraffort@linaro.org>2014-07-18 14:31:49 +0000
committerLinaro Code Review <review@review.linaro.org>2014-07-18 14:31:49 +0000
commit1b8efa4ff108b20bcded0f01499b54d19b44853c (patch)
treea6bc27ed6f913659cf889a4d135c69b849f01af1
parent8fd79485f8bf2d8a3750110e16c2ad835495e25f (diff)
parentce682ddd4488e2e65b836bce91be4a1237d2676f (diff)
downloadhacking-sessions-1b8efa4ff108b20bcded0f01499b54d19b44853c.tar.gz
Merge "Add hacking session for Fedora"
-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