add(coreos-base/oem-gce): Add support for ssh keys on GCE

This commit is contained in:
Michael Marineau 2013-11-30 17:26:49 -08:00
parent 640c2e354e
commit 4032ba5ede
3 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,23 @@
#!/bin/bash
set -e
URL_PREFIX="http://metadata/computeMetadata/v1beta1/"
update_keys() {
local id="$1"
local url="${URL_PREFIX}${id}/attributes/sshKeys"
# The key may have a username: prerix which must be stripped
local keys=$(curl --fail -s "$url" | sed -re 's/^\w*://')
if [[ -n "$keys" ]]; then
echo "$keys"
update-ssh-keys -a "gce-$id" <<<"$keys"
fi
}
block-until-url "$URL_PREFIX"
# Generally sshKeys is only defined per-project
# but might as well support per-instance too.
update_keys project
update_keys instance

View File

@ -0,0 +1,24 @@
# Copyright (c) 2013 CoreOS, Inc.. All rights reserved.
# Distributed under the terms of the GNU General Public License v2
EAPI=5
DESCRIPTION="OEM suite for Google Compute Engine images"
HOMEPAGE=""
SRC_URI=""
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="amd64"
IUSE=""
# no source directory
S="${WORKDIR}"
src_install() {
exeinto "/"
doexe ${FILESDIR}/run
insinto "/"
doins ${FILESDIR}/oem-release
}