From 42dc93dc92cac8477bfc1d5a5d173bbfe09cafa8 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 12 Aug 2013 19:13:40 -0400 Subject: [PATCH] fix(coreos-base/oem-ami): Simplify ssh key install Use the new update-ssh-keys script to make the script a lot simpler. :) --- .../oem-ami/files/install-ec2-key.sh | 21 ------------------- .../coreos-base/oem-ami/files/run | 8 +++++++ .../coreos-base/oem-ami/files/run.sh | 3 --- ....0.1-r8.ebuild => oem-ami-0.0.1-r9.ebuild} | 0 .../coreos-base/oem-ami/oem-ami-0.0.1.ebuild | 4 +--- 5 files changed, 9 insertions(+), 27 deletions(-) delete mode 100755 sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/install-ec2-key.sh create mode 100755 sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/run delete mode 100755 sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/run.sh rename sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/{oem-ami-0.0.1-r8.ebuild => oem-ami-0.0.1-r9.ebuild} (100%) diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/install-ec2-key.sh b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/install-ec2-key.sh deleted file mode 100755 index 6144e1b120..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/install-ec2-key.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -/usr/bin/block-until-url http://169.254.169.254/ - -USER_DIR="/home/core" - -if [ ! -d ${USER_DIR}/.ssh ] ; then - mkdir -p ${USER_DIR}/.ssh - chmod 700 ${USER_DIR}/.ssh -fi -curl -s http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key > /tmp/my-key -if [ $? -eq 0 ] ; then - cat /tmp/my-key >> ${USER_DIR}/.ssh/authorized_keys - chmod 700 ${USER_DIR}/.ssh/authorized_keys - rm /tmp/my-key -else - echo unable to download key - rm /tmp/my-key - exit 1 -fi -chown -R core: $USER_DIR/.ssh diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/run b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/run new file mode 100755 index 0000000000..f46ae9d631 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/run @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +KEY_URL="http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key" + +block-until-url "$KEY_URL" +curl --fail -s "$KEY_URL" | update-ssh-keys -a ec2 diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/run.sh b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/run.sh deleted file mode 100755 index 69c0f1858a..0000000000 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/files/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -/usr/share/oem/usr/bin/install-ec2-key.sh diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1-r8.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1-r9.ebuild similarity index 100% rename from sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1-r8.ebuild rename to sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1-r9.ebuild diff --git a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild index 8db3190479..567f5321b4 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/coreos-base/oem-ami/oem-ami-0.0.1.ebuild @@ -16,10 +16,8 @@ IUSE="" S="${WORKDIR}" src_install() { - dobin "${FILESDIR}"/install-ec2-key.sh - exeinto "/" - doexe ${FILESDIR}/run.sh + doexe ${FILESDIR}/run insinto "/" doins ${FILESDIR}/oem-release