diff options
author | Soren Hansen <soren@canonical.com> | 2009-06-27 20:05:31 +0200 |
---|---|---|
committer | Soren Hansen <soren@canonical.com> | 2009-06-27 20:05:31 +0200 |
commit | 762239981d70e209c69e9d00f6204fd2d9343bf0 (patch) | |
tree | 940267b07f8ed3ba9a36e0ffd2c7230e3f3c0c16 | |
parent | dd38fbcbb5b8489bd90d2bde3ce13599701f1e13 (diff) | |
download | vyos-cloud-init-762239981d70e209c69e9d00f6204fd2d9343bf0.tar.gz vyos-cloud-init-762239981d70e209c69e9d00f6204fd2d9343bf0.zip |
Make the paths constants.
-rwxr-xr-x | ec2-set-apt-sources.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ec2-set-apt-sources.py b/ec2-set-apt-sources.py index 39f25ee6..8bc89312 100755 --- a/ec2-set-apt-sources.py +++ b/ec2-set-apt-sources.py @@ -24,24 +24,28 @@ from Cheetah.Template import Template import ec2init +SOURCES_LIST = '/etc/apt/sources.list' +GENERATED_SOURCES_LIST = '/var/run/ec2/sources.list' +OUT_OF_THE_WAY_SOURCES_LIST = '/etc/apt/sources.list.moved-by-ec2-init' + def main(): ec2 = ec2init.EC2Init() mirror = ec2.get_mirror_for_availability_zone() - if not os.path.exists("/var/run/ec2/sources.lists"): + if not os.path.exists(GENERATED_SOURCES_LIST): t = os.popen("lsb_release -cs").read() codename = t.strip() mp = { 'mirror' : mirror, 'codename' : codename } t = Template(file='/etc/ec2-init/templates/sources.list.tmpl', searchList=[mp]) - f = open("/var/run/ec2/sources.list", "w") + f = open(GENERATED_SOURCES_LIST, 'w') f.write(t.respond()) f.close() - if not os.path.exists("/etc/apt/sources.list-ec2-init"): - os.rename('/etc/apt/sources.list', '/etc/apt/sources.list-ec2-init') - os.symlink('/var/run/ec2/sources.list', '/etc/apt/sources.list') + if not os.path.exists(OUT_OF_THE_WAY_SOURCES_LIST): + os.rename(SOURCES_LIST, OUT_OF_THE_WAY_SOURCES_LIST) + os.symlink(GENERATED_SOURCES_LIST, SOURCES_LIST) aptget = subprocess.Popen(['apt-get', 'update']) aptget.communicate() |