diff options
author | Chuck Short <zulcss@ubuntu.com> | 2009-04-06 23:04:48 +0100 |
---|---|---|
committer | Bazaar Package Importer <jamesw@ubuntu.com> | 2009-04-06 23:04:48 +0100 |
commit | 6dddf16cb8dea2e1a96b3d613b81087df247fd3d (patch) | |
tree | b8945a128e4eca03b25b1dd0d93368c797bd9a9c /ec2-set-hostname.py | |
parent | 406eb2f8e235c7e24b7eeb1c044ef64741f0569b (diff) | |
download | vyos-cloud-init-6dddf16cb8dea2e1a96b3d613b81087df247fd3d.tar.gz vyos-cloud-init-6dddf16cb8dea2e1a96b3d613b81087df247fd3d.zip |
* ec2-set-hostname.py:
- Use template for /etc/hosts creation.
- Dont use public_hostname in /etc/hosts. (LP: #352745)
* debian/control:
- Add python-cheetah as a depends.
* templates/sources.list.tmpl:
- Update template.
* debian/init:
- Run the ec2-user-data script last so that the users
get a stable system before running the user scripts.
Diffstat (limited to 'ec2-set-hostname.py')
-rwxr-xr-x | ec2-set-hostname.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ec2-set-hostname.py b/ec2-set-hostname.py index f12a4a30..6858a8b0 100755 --- a/ec2-set-hostname.py +++ b/ec2-set-hostname.py @@ -20,6 +20,7 @@ # import urllib import os +from Cheetah.Template import Template api_ver = '2008-02-01' metadata = None @@ -29,11 +30,10 @@ my_hostname = urllib.urlopen('%s/local-hostname/' % base_url).read() os.system('hostname %s' % my_hostname) # replace the ubuntu hostname in /etc/hosts -my_public_hostname = urllib.urlopen('%s/public-hostname/' % base_url).read() +mp = {'hostname': my_hostname} +t = Template(file="/etc/ec2-init/templates/hosts.tmpl", searchList=[mp]) -f = open("/etc/hosts", "r") -lines = f.read() +os.system("rm /etc/hosts") +f = open("/etc/hosts", "w") +f.write('%s' %(t)) f.close() -file = open("/etc/hosts", "w") -file.write(lines.replace("127.0.1.1 ubuntu. ubuntu", "127.0.1.1 "+ my_public_hostname +" "+ my_hostname)) -file.close() |