summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuck Short <zulcss@ubuntu.com>2009-01-14 00:57:58 +0000
committerBazaar Package Importer <jamesw@ubuntu.com>2009-01-14 00:57:58 +0000
commitb7d4c2c4a45c83d7e4a0c5ca7271c4ae13cd1f84 (patch)
tree8f56065e530f0e0515d26ae36dfd9064d71d7703
parentd61ffd7fb8434e76d2be555de834420232d2006e (diff)
downloadcloud-init-ubuntu-0.2.tar.gz
* debian/init: Run fetch-credentials before anything else.ubuntu-0.2
(LP: #308533) * Add ec2-set-hostname.py: Queries ec2 metdada for public-hostname and then sets it (LP: #316201)
-rw-r--r--debian/changelog9
-rw-r--r--debian/control2
-rw-r--r--debian/init16
-rwxr-xr-xdebian/rules1
-rwxr-xr-xec2-set-hostname.py29
5 files changed, 52 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog
index 7a90e732..ff4199bd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+ec2-init (0.2) jaunty; urgency=low
+
+ * debian/init: Run fetch-credentials before anything else.
+ (LP: #308533)
+ * Add ec2-set-hostname.py: Queries ec2 metdada for public-hostname
+ and then sets it (LP: #316201)
+
+ -- Chuck Short <zulcss@ubuntu.com> Tue, 13 Jan 2009 15:20:21 -0500
+
ec2-init (0.1) intrepid; urgency=low
* Initial release (LP: #269434).
diff --git a/debian/control b/debian/control
index c579e89e..4505cbaf 100644
--- a/debian/control
+++ b/debian/control
@@ -6,7 +6,7 @@ Build-Depends: cdbs, debhelper (>= 5)
Standards-Version: 3.8.0
Package: ec2-init
-Architecture: all
+Architecture: i386 amd64
Depends: python, procps
Description: Init scripts for EC2 instances
EC2 instances need special scripts to run during initialisation
diff --git a/debian/init b/debian/init
index d084c568..e1deee83 100644
--- a/debian/init
+++ b/debian/init
@@ -18,16 +18,16 @@ NAME=ec2-init
case "$1" in
start)
- log_daemon_msg "Running EC2 user data"
- if ec2-run-user-data 2> /dev/null
+ log_daemon_msg "Fetching EC2 login credentials"
+ if ec2-fetch-credentials 2> /dev/null
then
log_end_msg 0
else
log_end_msg 1
fi
- log_daemon_msg "Fetching EC2 login credentials"
- if ec2-fetch-credentials 2> /dev/null
+ log_daemon_msg "Running EC2 user data"
+ if ec2-run-user-data 2> /dev/null
then
log_end_msg 0
else
@@ -44,6 +44,14 @@ case "$1" in
log_end_msg 1
fi
fi
+ log_daemon_msg "Setting hostname to EC2 public_hostname"
+ if ec2-set-hostname 2> /dev/null
+ then
+ log_end_msg 0
+ else
+ log_end_msg 1
+ fi
+
;;
stop)
exit 0
diff --git a/debian/rules b/debian/rules
index 8c9f1074..e5f924ef 100755
--- a/debian/rules
+++ b/debian/rules
@@ -8,3 +8,4 @@ build/ec2-init::
install -d debian/tmp/usr/sbin
install -m 775 ec2-fetch-credentials.py debian/tmp/usr/sbin/ec2-fetch-credentials
install -m 775 ec2-run-user-data.py debian/tmp/usr/sbin/ec2-run-user-data
+ install -m 755 ec2-set-hostname.py debian/tmp/usr/sbin/ec2-set-hostname
diff --git a/ec2-set-hostname.py b/ec2-set-hostname.py
new file mode 100755
index 00000000..4c8d7416
--- /dev/null
+++ b/ec2-set-hostname.py
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+#
+# Fetch login credentials for EC2
+# Copyright 2008 Canonical Ltd.
+#
+# Author: Chuck Short <chuck.short@canonical.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+import urllib
+import os
+
+api_ver = '2008-02-01'
+metadata = None
+
+base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
+my_hostname = urllib.urlopen('%s/public-hostname/' % base_url).read()
+os.system('hostname %s' % my_hostname)