From e2453db94fee4a4f8fec4c814c8044e50f8af88e Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 24 Jan 2014 16:21:42 +0000 Subject: [PATCH] Add apache helper, fixup site handling --- hooks/hooks.py | 10 +++++++--- hooks/utils.py | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hooks/hooks.py b/hooks/hooks.py index de94a940..7a8f8c08 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -33,7 +33,8 @@ from charmhelpers.fetch import ( from utils import ( render_template, get_host_ip, - enable_pocket + enable_pocket, + is_apache_24 ) from charmhelpers.payload.execd import execd_preinstall @@ -91,12 +92,15 @@ def emit_apacheconf(): apachecontext = { "hostname": unit_get('private-address') } - with open('/etc/apache2/sites-available/rgw.conf', 'w') as apacheconf: + site_conf = '/etc/apache2/sites-available/rgw' + if is_apache_24(): + site_conf = '/etc/apache2/sites-available/rgw.conf' + with open(site_conf, 'w') as apacheconf: apacheconf.write(render_template('rgw', apachecontext)) def apache_sites(): - if os.path.exists('/etc/apache2/sites-available/000-default.conf'): + if is_apache_24(): subprocess.check_call(['a2dissite', '000-default']) else: subprocess.check_call(['a2dissite', 'default']) diff --git a/hooks/utils.py b/hooks/utils.py index 2a9a9c71..b8e16623 100644 --- a/hooks/utils.py +++ b/hooks/utils.py @@ -9,6 +9,7 @@ import socket import re +import os from charmhelpers.core.hookenv import unit_get from charmhelpers.fetch import apt_install @@ -59,3 +60,10 @@ def get_host_ip(hostname=unit_get('private-address')): answers = dns.resolver.query(hostname, 'A') if answers: return answers[0].address + + +def is_apache_24(): + if os.path.exists('/etc/apache2/conf-available'): + return True + else: + return False