summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog6
-rw-r--r--debian/init12
-rwxr-xr-xdebian/rules1
-rwxr-xr-xec2-run-user-data.py10
4 files changed, 22 insertions, 7 deletions
diff --git a/debian/changelog b/debian/changelog
index ff4199bd..e87676e7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ec2-init (0.3) jaunty; urgency=low
+
+ * ec2-run-user-data: Fix python error when writing a file to the disk.
+
+ -- Chuck Short <zulcss@ubuntu.com> Thu, 15 Jan 2009 11:49:08 -0500
+
ec2-init (0.2) jaunty; urgency=low
* debian/init: Run fetch-credentials before anything else.
diff --git a/debian/init b/debian/init
index e1deee83..24db3845 100644
--- a/debian/init
+++ b/debian/init
@@ -27,11 +27,17 @@ case "$1" in
fi
log_daemon_msg "Running EC2 user data"
- if ec2-run-user-data 2> /dev/null
+ if [ -f /var/ec2/.already_ran ]
then
- log_end_msg 0
+ echo "Already ran";
else
- log_end_msg 1
+ if ec2-run-user-data 2> /dev/null
+ then
+ log_end_msg 0
+ touch /var/ec2/.already_ran
+ else
+ log_end_msg 1
+ fi
fi
if pgrep nash-hotplug > /dev/null
diff --git a/debian/rules b/debian/rules
index e5f924ef..b3812f7e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,6 +6,7 @@ DEB_UPDATE_RCD_PARAMS:=start 90 S .
build/ec2-init::
install -d debian/tmp/usr/sbin
+ mkdir -p debian/tmp/var/ec2
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-run-user-data.py b/ec2-run-user-data.py
index 6638ef37..c41b9724 100755
--- a/ec2-run-user-data.py
+++ b/ec2-run-user-data.py
@@ -3,7 +3,7 @@
# Fetch and run user-data from EC2
# Copyright 2008 Canonical Ltd.
#
-# Author: Soren Hansen <soren@canonical.com>
+# Original-Author: Soren Hansen <soren@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
@@ -23,6 +23,7 @@ import os
import sys
import tempfile
import urllib
+from time import gmtime, strftime
api_ver = '2008-02-01'
metadata = None
@@ -37,12 +38,13 @@ def get_user_data():
user_data = get_user_data()
if user_data.startswith('#!'):
+ # run it
(fp, path) = tempfile.mkstemp()
- fp.write(data)
- fp.close()
+ os.write(fp,user_data)
+ os.close(fp);
os.chmod(path, 0700)
+ os.system('cp %s /var/ec2/user-data.%s' %(path, strftime("%Y%m%d%H%I", gmtime())))
status = os.system('%s' % path)
os.unlink(path)
- sys.exit(os.WIFEXITSTATUS(status))
sys.exit(0)