From 67cc68699dc0a12c912d5a759692463e713eb27d Mon Sep 17 00:00:00 2001 From: Chandan kumar Date: Fri, 22 Nov 2013 14:52:58 +0530 Subject: [PATCH] Fixes the custom script to fetch the public key. Change-Id: If25d854d66b8084ea3618770e50e90ccc93b46aa Closes-Bug: #1253912 --- doc/image-guide/ch_openstack_images.xml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/image-guide/ch_openstack_images.xml b/doc/image-guide/ch_openstack_images.xml index acd7521b4e..2bfabb8d1b 100644 --- a/doc/image-guide/ch_openstack_images.xml +++ b/doc/image-guide/ch_openstack_images.xml @@ -244,10 +244,10 @@ fi # Fetch public key using HTTP ATTEMPTS=30 -FAILED=0subl +FAILED=0 while [ ! -f /root/.ssh/authorized_keys ]; do curl -f http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/metadata-key 2>/dev/null - if [ \$? -eq 0 ]; then + if [ $? -eq 0 ]; then cat /tmp/metadata-key >> /root/.ssh/authorized_keys chmod 0600 /root/.ssh/authorized_keys restorecon /root/.ssh/authorized_keys @@ -258,6 +258,15 @@ while [ ! -f /root/.ssh/authorized_keys ]; do echo "*****************" cat /root/.ssh/authorized_keys echo "*****************" + else + FAILED=`expr $FAILED + 1` + if [ $FAILED -ge $ATTEMPTS ]; then + echo "Failed to retrieve public key from instance metadata after $FAILED attempts, quitting" + break + fi + echo "Could not retrieve public key from instance metadata (attempt #$FAILED/$ATTEMPTS), retrying in 5 seconds..." + sleep 5 + fi done Some VNC clients replace : (colon) with ; (semicolon) and _ (underscore) with