I was looking at autobuild.sh and spotted a few nits. Also (but I didn't do anything about this), it currently requires the existence of ~/.ssh/id_rsa.pub. That doesn't work for me, since my file happens to be named id_rsa-2008.pub. An alternative would be to run "ssh-add -L" first, and if that gets anything to simply use that, and fall back on the hard-coded default file name, for those who don't have a usable agent. Here are two patches:>From 43274e2aa766ab7ecad4ef24a11ad006ee401697 Mon Sep 17 00:00:00 2001From: Jim Meyering <meyering at redhat.com> Date: Tue, 29 Jul 2008 10:09:05 +0200 Subject: [PATCH] autobuild.sh clean up split some long lines always print diagnostics to stderr use "die msg" rather than "echo msg; exit 1" use "$ssh_cmd exit && break" instead of 4-line equivalent use quotes that do not require escaping --- autobuild.sh | 36 +++++++++++++++++------------------- 1 files changed, 17 insertions(+), 19 deletions(-) diff --git a/autobuild.sh b/autobuild.sh index ed4a201..9bf0275 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -17,20 +17,23 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. A copy of the GNU General Public License is # also available at http://www.gnu.org/copyleft/gpl.html. -# + +ME=$(basename "$0") +warn() { printf "$ME: $@\n" >&2; } +die() { warn "$@"; exit 1; } echo "Running oVirt Autobuild" -ssh_cmd="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root at 192.168.50.2" +ssh_cmd="ssh -o StrictHostKeyChecking=no \ + -o UserKnownHostsFile=/dev/null root at 192.168.50.2" # implant local ssh key into appliance for autobuild only -if [ ! -e ~/.ssh/id_rsa.pub ]; then - echo "$0 requires default SSH key to be generated. Please run ssh-keygen -t rsa" - exit 1 +if [ ! -r ~/.ssh/id_rsa.pub ]; then + die "requires default SSH key to be generated. Please run ssh-keygen -t rsa" fi cat >> wui-appliance/common-post.ks << \KS -mkdir -p /root/.ssh/ -chmod 700 /root/.ssh/ +mkdir -p /root/.ssh +chmod 700 /root/.ssh cat > /root/.ssh/authorized_keys << \EOF KS cat ~/.ssh/id_rsa.pub >> wui-appliance/common-post.ks @@ -40,7 +43,7 @@ chmod 600 /root/.ssh/authorized_keys KS # move sshd to start last (after ovirt*first-run scripts) cat >> wui-appliance/common-post.ks << \KS -mkdir -p /etc/chkconfig.d/ +mkdir -p /etc/chkconfig.d cat > /etc/chkconfig.d/sshd << \EOF # chkconfig: 2345 99 01 EOF @@ -48,25 +51,20 @@ chkconfig --override sshd KS # create appliance -./build-all.sh -ac -if [ $? -ne 0 ]; then - echo "./build-all.sh failed, appliance not created" - exit 1 -fi +./build-all.sh -ac \ + || die "./build-all.sh failed, appliance not created" # start appliance virsh start ovirt-appliance # wait until started for i in $(seq 1 60); do - $ssh_cmd "exit" - if [ $? -eq 0 ]; then - break - fi + $ssh_cmd exit && break sleep 10 done echo "Running the wui tests" $ssh_cmd \ - "curl -i --negotiate -u : management.priv.ovirt.org/ovirt/ | grep \"HTTP/1.1 200 OK\" && \ - cd /usr/share/ovirt-wui/ && rake test" + "curl -i --negotiate -u : management.priv.ovirt.org/ovirt/ | \ + grep 'HTTP/1.1 200 OK' && \ + cd /usr/share/ovirt-wui && rake test" -- 1.5.6.4.435.g780ea>From d5ae733b891103e754032b287137b9511e7a0855 Mon Sep 17 00:00:00 2001From: Jim Meyering <meyering at redhat.com> Date: Tue, 29 Jul 2008 10:17:20 +0200 Subject: [PATCH] autobuild.sh: simply appending to wui-appliance/common-post.ks Use a single unquoted here-doc in place of two quoted ones with a "cat" between them. --- autobuild.sh | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/autobuild.sh b/autobuild.sh index 9bf0275..189cb03 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -31,16 +31,15 @@ ssh_cmd="ssh -o StrictHostKeyChecking=no \ if [ ! -r ~/.ssh/id_rsa.pub ]; then die "requires default SSH key to be generated. Please run ssh-keygen -t rsa" fi -cat >> wui-appliance/common-post.ks << \KS +cat >> wui-appliance/common-post.ks << KS mkdir -p /root/.ssh chmod 700 /root/.ssh cat > /root/.ssh/authorized_keys << \EOF -KS -cat ~/.ssh/id_rsa.pub >> wui-appliance/common-post.ks -cat >> wui-appliance/common-post.ks << \KS +$(cat ~/.ssh/id_rsa.pub) EOF chmod 600 /root/.ssh/authorized_keys KS + # move sshd to start last (after ovirt*first-run scripts) cat >> wui-appliance/common-post.ks << \KS mkdir -p /etc/chkconfig.d -- 1.5.6.4.435.g780ea
Alan Pevec
2008-Jul-29 09:59 UTC
[Ovirt-devel] [PATCH] generate separate SSH key for Autobuild
Signed-off-by: Alan Pevec <apevec at redhat.com> --- autobuild.sh | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/autobuild.sh b/autobuild.sh index 189cb03..b87d205 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -1,3 +1,4 @@ +#!/bin/sh #oVirt autobuild script # # Copyright (C) 2008 Red Hat, Inc. @@ -24,18 +25,19 @@ die() { warn "$@"; exit 1; } echo "Running oVirt Autobuild" -ssh_cmd="ssh -o StrictHostKeyChecking=no \ +SSHKEY=~/.ssh/id_autobuild +ssh_cmd="ssh -i $SSHKEY -o StrictHostKeyChecking=no \ -o UserKnownHostsFile=/dev/null root at 192.168.50.2" -# implant local ssh key into appliance for autobuild only -if [ ! -r ~/.ssh/id_rsa.pub ]; then - die "requires default SSH key to be generated. Please run ssh-keygen -t rsa" +# implant Autobuild SSH key into appliance +if [ ! -r $SSHKEY ]; then + ssh-keygen -q -t rsa -N "" -f $SSHKEY fi cat >> wui-appliance/common-post.ks << KS mkdir -p /root/.ssh chmod 700 /root/.ssh cat > /root/.ssh/authorized_keys << \EOF -$(cat ~/.ssh/id_rsa.pub) +$(ssh-keygen -y -f $SSHKEY) EOF chmod 600 /root/.ssh/authorized_keys KS @@ -54,7 +56,8 @@ KS || die "./build-all.sh failed, appliance not created" # start appliance -virsh start ovirt-appliance +virsh start ovirt-appliance \ + || die "virsh start failed, appliance not started" # wait until started for i in $(seq 1 60); do -- 1.5.5.1