From 5265e26397597a5333c179842d3e0a41b769de96 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 24 Jul 2015 23:52:47 +0300 Subject: Check hostname --- yarns/100-willikins.yarn | 2 ++ yarns/900-implements.yarn | 21 +++++++++++++++++++++ yarns/run.sh | 5 ++++- 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'yarns') diff --git a/yarns/100-willikins.yarn b/yarns/100-willikins.yarn index 8f20cdc..d12e45e 100644 --- a/yarns/100-willikins.yarn +++ b/yarns/100-willikins.yarn @@ -7,3 +7,5 @@ backups. It is only ever accessed over ssh (including sftp). GIVEN server name is willikins THEN server responds to ping + WHEN running ssh willikins hostname + THEN output matches willikins diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn index 5b9d0f9..d4b1ee5 100644 --- a/yarns/900-implements.yarn +++ b/yarns/900-implements.yarn @@ -15,3 +15,24 @@ Does the server respond to a ping? IMPLEMENTS THEN server responds to ping . "$DATADIR/config.sh" ping -c1 "$SERVER" + +## Running command over ssh + +Run a command on the server over ssh, capturing stdout and stderr and +exit code for later inspection. + + IMPLEMENTS WHEN running ssh (.*) + if ssh $MATCH_1 > "$DATADIR/stdout" 2> "$DATADIR/stderr" + then + echo 0 > "$DATADIR/exit" + else + echo $? > "$DATADIR/exit" + fi + +## Inspect results of running a command + +The stdout, stderr, and exit code have been saved. Inspect them. + + IMPLEMENTS THEN output matches (.+) + cat "$DATADIR/stdout" + grep "$MATCH_1" "$DATADIR/stdout" diff --git a/yarns/run.sh b/yarns/run.sh index 4f7f7af..f34bb6d 100755 --- a/yarns/run.sh +++ b/yarns/run.sh @@ -1,4 +1,7 @@ #!/bin/sh cd "$(dirname "$0")" -yarn *.yarn +yarn \ + --env "SSH_AGENT_PID=$SSH_AGENT_PID" \ + --env "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" \ + *.yarn -- cgit v1.2.1