Enable sites that are disabled after certs are deployed

This commit is contained in:
James Kasten 2012-08-12 18:05:21 -04:00
parent 6db2e9d6b3
commit 9dd5842c6d
2 changed files with 14 additions and 6 deletions

View file

@ -263,7 +263,6 @@ def authenticate():
print "Generating key:", key_file
print "Creating CSR:", req_file
k=chocolatemessage()
m=chocolatemessage()
init(k)
@ -355,6 +354,14 @@ def authenticate():
#cert_chain_abspath = os.path.abspath(chain_file)
for host in vhost:
config.deploy_cert(host, os.path.abspath(cert_file), os.path.abspath(key_file), cert_chain_abspath)
# Enable any vhost that was issued to, but not enabled
if not config.is_site_enabled(host.file):
if curses:
shower.add("Enabling Site " + host.file)
else:
print "Enabling Site", host.file
config.enable_site(host.file)
sni_challenge.apache_restart(quiet=curses)
elif r.failure.IsInitialized():
print "Server reported failure."

View file

@ -11,7 +11,8 @@ SERVER_ROOT = "/etc/apache2/"
#TODO - Stop Augeas from loading up backup emacs files in sites-available
class VH(object):
def __init__(self, vh_path, vh_addrs):
def __init__(self, filename_path, vh_path, vh_addrs):
self.file = filename_path
self.path = vh_path
self.addrs = vh_addrs
self.names = []
@ -164,7 +165,7 @@ class Configurator(object):
args = self.aug.match(p + "/arg")
for arg in args:
addrs.append(self.aug.get(arg))
vhs.append(VH(p, addrs))
vhs.append(VH(self.get_file_path(p), p, addrs))
for host in vhs:
self.__add_servernames(host)
@ -472,9 +473,9 @@ class Configurator(object):
return vh
return None
def get_file_path(self, vhost):
def get_file_path(self, vhost_path):
# Strip off /files
avail_fp = vhost.path[6:]
avail_fp = vhost_path[6:]
# This can be optimized...
while True:
find_if = avail_fp.find("/IfModule")
@ -598,7 +599,7 @@ class Configurator(object):
def main():
config = Configurator()
for v in config.vhosts:
print config.get_file_path(v)
print v.file
print v.addrs
for name in v.names:
print name