summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChuck Short <zulcss@ubuntu.com>2009-03-18 20:14:26 +0000
committerBazaar Package Importer <jamesw@ubuntu.com>2009-03-18 20:14:26 +0000
commit58f82c2220b3137c97a377b01da04a14c64b0a1d (patch)
treeec0958d5e572538923ea969b9fc9a577a0f3cf4d
parent2d667f57536a532d84872404e19e777820692665 (diff)
downloadcloud-init-ubuntu-0.3.3ubuntu5.tar.gz
* debian/ec2-config.cfg:ubuntu-0.3.3ubuntu5
- Add disable root option. * debian/ec2-init.rightscale-init.init: - Add rightscale detection script. * ec2-get-info.py: - Display the information about an AMI instance.
-rw-r--r--debian/changelog11
-rw-r--r--debian/ec2-config.cfg1
-rw-r--r--debian/ec2-init.rightscale-init.init113
-rwxr-xr-xdebian/rules2
-rwxr-xr-xec2-get-info.py124
5 files changed, 251 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 7f8f947f..814c6a7b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,14 @@
+ec2-init (0.3.3ubuntu5) jaunty; urgency=low
+
+ * debian/ec2-config.cfg:
+ - Add disable root option.
+ * debian/ec2-init.rightscale-init.init:
+ - Add rightscale detection script.
+ * ec2-get-info.py:
+ - Display the information about an AMI instance.
+
+ -- Chuck Short <zulcss@ubuntu.com> Mon, 16 Mar 2009 08:54:49 -0400
+
ec2-init (0.3.3ubuntu4) jaunty; urgency=low
* ec2-fetch-credentials.py:
diff --git a/debian/ec2-config.cfg b/debian/ec2-config.cfg
index 4af39f0c..cd38d598 100644
--- a/debian/ec2-config.cfg
+++ b/debian/ec2-config.cfg
@@ -1,2 +1,3 @@
user="ubuntu"
distro="intrepid"
+DISABLE_ROOT="1"
diff --git a/debian/ec2-init.rightscale-init.init b/debian/ec2-init.rightscale-init.init
new file mode 100644
index 00000000..4a1c52af
--- /dev/null
+++ b/debian/ec2-init.rightscale-init.init
@@ -0,0 +1,113 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: rightscale
+# Required-Start:
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 1
+# Sort-Description: Setup Righscale
+
+# This script will configure an Ubuntu server for use with RightScale
+
+set -e
+
+start() {
+ ## First check to see if we were launched through RightScale. Exit and remove if not...
+ user_data=`curl -s -S -f -L --retry 7 -w ' %{http_code}' http://169.254.169.254/latest/user-data`
+ if `echo $user_data | grep -v "RS_token=" 1>/dev/null 2>&1` ; then
+ ## Remove this init script so that it does not run again
+ remove
+ exit 0
+ fi
+
+ ## ok, we were launched through RightScale, so let's continue
+ echo "Detected a RightScale instance..."
+ echo "Beginning configuration..."
+
+ ## figure out which version of RightScale to install...
+ export rs_release=Ubuntu_`lsb_release -rs`
+
+ ## Install some necessary packages
+ echo "Installing necessary packages..."
+ export DEBIAN_FRONTEND=NONINTERACTIVE
+ apt-get update
+ apt-get install -y binutils sysv-rc-conf unzip ruby1.8-dev autoconf automake libtool logrotate rsync openssl ca-certificates
+
+ ## Add rightscale customizations
+ echo "Installing RightScale"
+ curl -s -S -f -L --retry 7 -w ' %{http_code}' -o /tmp/rightscale_scripts.tgz http://s3.amazonaws.com/rightscale_scripts/rightscale_scripts_"$rs_release".tgz
+ tar -xzf /tmp/rightscale_scripts.tgz -C /opt/
+ ln -f /opt/rightscale/etc/init.d/rightscale /etc/init.d/rightscale
+ chmod +x /opt/rightscale/etc/init.d/rightscale
+ chmod +x /etc/init.d/rightscale
+ mkdir -p /etc/rightscale.d
+ update-rc.d rightscale start 98 2 3 4 5 . stop 1 0 1 6 .
+ ln -sf /usr/bin/ruby1.8 /usr/bin/ruby
+ ln -f /opt/rightscale/etc/motd /etc/motd
+ echo $rs_release > /etc/rightscale-release
+
+ ## Add rubygems 1.8
+ echo "Installing RubyGems 1.8..."
+ curl -s -S -f -L --retry 7 -w ' %{http_code}' -o /tmp/rubygems.tgz http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
+ mkdir -p /tmp/rubygems
+ tar -xzvf /tmp/rubygems.tgz -C $root/tmp/rubygems
+ cd /tmp/rubygems/rubygems-1.3.1/
+ ruby setup.rb --no-rdoc --no-ri
+ ln -s /usr/bin/gem1.8 /usr/bin/gem
+ gem source -a http://ec2-us-east-mirror.rightscale.com/rubygems/archive/latest/
+ gem source -r http://mirror.rightscale.com
+ gem install --no-rdoc --no-ri xml-simple net-ssh net-sftp s3sync
+ updatedb
+
+ ## Add some links to keep things inline
+ ln -s /usr/lib/site_ruby/aes /usr/local/lib/site_ruby/1.8/aes
+ ln -s /usr/lib/site_ruby/ec2 /usr/local/lib/site_ruby/1.8/ec2
+ ln -s /usr/bin/env /bin/env
+
+ ## Insert 'ec2' as the cloud
+ echo "ec2" > /etc/rightscale.d/cloud
+
+ ## Enable root logins
+ echo "Enabling root logins..."
+ cp -f /home/ubuntu/.ssh/authorized_keys /root/.ssh/.
+
+ ## Remove the default sources.list becasue RightScale will create a better one anyways...
+ rm -f /etc/apt/sources.list.d/amazon.list
+
+ ## Remove this init script so that it does not run again
+ remove
+
+ ## Start the rightscale service
+ echo "Starting RightScale..."
+ /etc/init.d/rightscale start
+ echo "RightScale services started properly"
+
+}
+
+stop() {
+ exit 0
+}
+
+remove() {
+ my_name=`basename $0`
+ init_script_name=${my_name:3}
+ update-rc.d -f $init_script_name remove
+ rm -f /etc/init.d/$init_script_name
+}
+
+
+# See how we were called.
+case "$1" in
+ start)
+ start >>/var/log/install 2>&1
+ ;;
+ stop)
+ stop >>/var/log/install 2>&1
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop}"
+ exit 1
+esac
+
+exit $?
diff --git a/debian/rules b/debian/rules
index dbdd8253..4d362f5b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -12,3 +12,5 @@ build/ec2-init::
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
install -m 755 ec2-set-apt-sources.py debian/tmp/usr/sbin/ec2-set-apt-sources
+ install -m755 ec2-get-info.py debian/tmp/usr/sbin/ec2-get-info
+ dh_installinit -p ec2-init --name rightscale-init -- defaults 20 21
diff --git a/ec2-get-info.py b/ec2-get-info.py
new file mode 100755
index 00000000..b05e2408
--- /dev/null
+++ b/ec2-get-info.py
@@ -0,0 +1,124 @@
+#!/usr/bin/python
+#
+# Fetch the information about an AMI instance.
+# Copyright 2009 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/>.
+#
+
+from optparse import OptionParser
+import urllib
+
+ec2Data = ['ami-id',
+ 'ami-launch-index',
+ 'ami-manifest-path',
+ 'ancestor-ami-id',
+ 'block-device-mapping',
+ 'instance-id',
+ 'instance-type',
+ 'local-hostname',
+ 'local-ipv4',
+ 'kernel-id',
+ 'product-codes',
+ 'public-hostname',
+ 'public-ipv4',
+ 'ramdisk-id',
+ 'reserveration-id',
+ 'security-groups']
+
+def ec2Version():
+ os.system("cat /etc/ec2_version")
+
+def getData(ec2data):
+ api_ver = '2008-02-01'
+ metadata = None
+ base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
+ data = urllib.urlopen('%s/%s/' %(base_url,ec2data)).read()
+ print "%s: %s" %(ec2data,data)
+
+def showAllData(ec2Data):
+ api_ver = '2008-02-01'
+ metadata = None
+ base_url = 'http://169.254.169.254/%s/meta-data' % api_ver
+ for x in ec2Data:
+ data = urllib.urlopen('%s/%s/' %(base_url,x)).read()
+ print "%s: %s" %(ec2data,data)
+
+def main():
+ usage = "usage: %prog [options]"
+
+ parser = OptionParser(prog='ec2-get-info', usage=usage)
+ parser.add_option('--ami-id', dest='amiid', action='store_true', help='Display the ami-id.')
+ parser.add_option('--launch-index', dest='launch', action='store_true', help='Display the AMI launch index.')
+ parser.add_option('--manifest', dest='manifest', action='store_true', help='Display the AMI manifest path.')
+ parser.add_option('--ancestor-id', dest='ancestor', action='store_true', help='Display the AMI ancestor id.')
+ parser.add_option('--block-device', dest='block', action='store_true', help='Display the block device id.')
+ parser.add_option('--instance-id', dest='id', action='store_true', help='Display the instance id.')
+ parser.add_option('--instance-type', dest='type', action='store_true', help='Display the instance type.')
+ parser.add_option('--local-hostname', dest='lhostname', action='store_true', help='Display the local hostname.')
+ parser.add_option('--local-ipv4', dest='lipv4', action='store_true', help='Display the local ipv4 IP address.')
+ parser.add_option('--kernel-id', dest='aki', action='store_true', help='List the AKI.')
+ parser.add_option('--product-codes', dest='code', action='store_true', help='List the product codes associated with thsi AMI.')
+ parser.add_option('--public-hostname', dest='phostname', action='store_true', help='Show the public hostname.')
+ parser.add_option('--public_ipv4', dest='pipv4', action='store_true', help='Show the public IPV4 IP address.')
+ parser.add_option('--ramdisk-id', dest='ari', action='store_true', help='Display the ARI.')
+ parser.add_option('--reservation-id', dest='rid', action='store_true', help='Display the reservation id.')
+ parser.add_option('--security-groups', dest='security', action='store_true', help='Display the security groups.')
+ parser.add_option('--ec2-version', dest='ec2', action='store_true', help='Display the current Ubuntu EC2 version')
+ parser.add_option('--all',dest='all', action='store_true', help='Display all informantion.')
+
+ options, args = parser.parse_args()
+
+ if options.amiid:
+ getData(ec2Data[0])
+ if options.launch:
+ getData(ec2Data[1])
+ if options.manifest:
+ getData(ec2Data[2])
+ if options.ancestor:
+ getData(ec2Data[3])
+ if options.block:
+ getData(ec2Data[4])
+ if options.id:
+ getData(ec2Data[5])
+ if options.type:
+ getData(ec2Data[6])
+ if options.lhostname:
+ getData(ec2Data[7])
+ if options.lipv4:
+ getData(ec2Data[8])
+ if options.aki:
+ getData(ec2Data[9])
+ if options.code:
+ getData(ec2Data[10])
+ if options.phostname:
+ getData(ec2Data[11])
+ if options.pipv4:
+ getData(ec2Data[12])
+ if options.ari:
+ getData(ec2Data[13])
+ if options.rid:
+ getData(ec2Data[14])
+ if options.security:
+ getData(ec2Data[15])
+ if options.ec2:
+ ec2Version()
+ if options.all:
+ for i in range(0,15):
+ getData(ec2Data[i])
+
+if __name__ == "__main__":
+ main()