summaryrefslogtreecommitdiff
path: root/ec2-run-user-data.py
diff options
context:
space:
mode:
authorChuck Short <zulcss@ubuntu.com>2009-01-19 18:56:02 +0000
committerBazaar Package Importer <jamesw@ubuntu.com>2009-01-19 18:56:02 +0000
commit2be0869fc100cc12f304192552d799e3232f6d2e (patch)
tree2628504bc76a623d443a9cff7a7c8375d4e3400b /ec2-run-user-data.py
parentb7d4c2c4a45c83d7e4a0c5ca7271c4ae13cd1f84 (diff)
downloadvyos-cloud-init-2be0869fc100cc12f304192552d799e3232f6d2e.tar.gz
vyos-cloud-init-2be0869fc100cc12f304192552d799e3232f6d2e.zip
ec2-run-user-data: Fix python error when writing a file to the disk.
Diffstat (limited to 'ec2-run-user-data.py')
-rwxr-xr-xec2-run-user-data.py10
1 files changed, 6 insertions, 4 deletions
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)