summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@gentoo.org>2010-11-27 00:31:57 +0000
committerDiego Elio Pettenò <flameeyes@gentoo.org>2010-11-27 00:31:57 +0000
commit9841cd620d3f0f8aaea692b47743573e15dcbea7 (patch)
tree3e3a4424118f86c4c150aaa0b9a9570fa791d88e /app-admin
parentAutomated update of use.local.desc (diff)
downloadgentoo-2-9841cd620d3f0f8aaea692b47743573e15dcbea7.tar.gz
gentoo-2-9841cd620d3f0f8aaea692b47743573e15dcbea7.tar.bz2
gentoo-2-9841cd620d3f0f8aaea692b47743573e15dcbea7.zip
Initial import of the init script for Amazon EC2 metadata.
(Portage version: 2.2.0_alpha5/cvs/Linux x86_64)
Diffstat (limited to 'app-admin')
-rw-r--r--app-admin/amazon-ec2-init/ChangeLog10
-rw-r--r--app-admin/amazon-ec2-init/amazon-ec2-init-20101127.ebuild30
-rw-r--r--app-admin/amazon-ec2-init/files/amazon-ec2.init35
-rw-r--r--app-admin/amazon-ec2-init/metadata.xml8
4 files changed, 83 insertions, 0 deletions
diff --git a/app-admin/amazon-ec2-init/ChangeLog b/app-admin/amazon-ec2-init/ChangeLog
new file mode 100644
index 000000000000..79eda7458fef
--- /dev/null
+++ b/app-admin/amazon-ec2-init/ChangeLog
@@ -0,0 +1,10 @@
+# ChangeLog for app-admin/amazon-ec2-init
+# Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/app-admin/amazon-ec2-init/ChangeLog,v 1.1 2010/11/27 00:31:57 flameeyes Exp $
+
+*amazon-ec2-init-20101127 (27 Nov 2010)
+
+ 27 Nov 2010; Diego E. Pettenò <flameeyes@gentoo.org> +files/amazon-ec2.init,
+ +amazon-ec2-init-20101127.ebuild, +metadata.xml:
+ Initial import of the init script for Amazon EC2 metadata.
+
diff --git a/app-admin/amazon-ec2-init/amazon-ec2-init-20101127.ebuild b/app-admin/amazon-ec2-init/amazon-ec2-init-20101127.ebuild
new file mode 100644
index 000000000000..9246c92e72e9
--- /dev/null
+++ b/app-admin/amazon-ec2-init/amazon-ec2-init-20101127.ebuild
@@ -0,0 +1,30 @@
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-admin/amazon-ec2-init/amazon-ec2-init-20101127.ebuild,v 1.1 2010/11/27 00:31:57 flameeyes Exp $
+
+EAPI="2"
+
+DESCRIPTION="Init script to setup Amazon EC2 instance parameters."
+HOMEPAGE="http://www.gentoo.org/"
+SRC_URI=""
+
+# Amazon only provides x86 and amd64 Linux Xen guests, possibly FreeBSD,
+# so just don't go adding further keywords.
+KEYWORDS="-* ~amd64 ~x86"
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE=""
+
+RDEPEND="net-misc/wget"
+DEPEND=""
+
+src_install() {
+ newinitd "${FILESDIR}/amazon-ec2.init" || die
+}
+
+pkg_postinst() {
+ elog "Remember to add amazon-ec2 init script to your boot runlevel"
+ elog "otherwise it won't bring up the correct interfaces and won't."
+ elog "start before the hostname has been set."
+}
diff --git a/app-admin/amazon-ec2-init/files/amazon-ec2.init b/app-admin/amazon-ec2-init/files/amazon-ec2.init
new file mode 100644
index 000000000000..7aa512a30821
--- /dev/null
+++ b/app-admin/amazon-ec2-init/files/amazon-ec2.init
@@ -0,0 +1,35 @@
+#!/sbin/runscript
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-admin/amazon-ec2-init/files/amazon-ec2.init,v 1.1 2010/11/27 00:31:57 flameeyes Exp $
+
+depend() {
+ before hostname
+ need net.eth0
+}
+
+start() {
+ einfo "Fetching metadata from EC2 servers"
+
+ ebegin " hostname"
+ local hostname=$(wget -t 2 -T 5 -q -O - http://169.254.169.254/latest/meta-data/local-hostname)
+ echo "hostname=${hostname}" >> /etc/conf.d/hostname
+ eend $?
+
+ ebegin " SSH keys"
+
+ mkdir -p /root/.ssh
+
+ local keys=$(wget -t 2 -T 5 -q -O - http://169.254.169.254/latest/meta-data/public-keys/ | cut -d = -f 1 | xargs echo)
+ [ -n "${keys}" ] && \
+ wget -t 2 -T 5 -q -O - $(for key in $keys; do echo "http://169.254.169.254/latest/meta-data/public-keys/$key/openssh-key"; done) \
+ >> /root/.ssh/authorized_keys \
+ 2>/dev/null
+
+ if [ -f /root/.ssh/authorized_keys ]; then
+ chown root:root /root/.ssh/authorized_keys
+ chmod 0600 /root/.ssh/authorized_keys
+ fi
+
+ eend $?
+}
diff --git a/app-admin/amazon-ec2-init/metadata.xml b/app-admin/amazon-ec2-init/metadata.xml
new file mode 100644
index 000000000000..2d083ce3bc66
--- /dev/null
+++ b/app-admin/amazon-ec2-init/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>no-herd</herd>
+ <maintainer>
+ <email>flameeyes@gentoo.org</email>
+ </maintainer>
+</pkgmetadata>