summaryrefslogtreecommitdiffstats
path: root/fooconf-apache
blob: 92aafbb8723ac895949e337a24389f161c17f7ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
# Hey Emacs, this is -*-python-*- code!

from fooconflib import *
from sys import stdout

def generateApacheFragment(ctx = FooConfContext()):
    cursor = ctx.db.cursor()
    cursor.execute("SELECT domain.name AS name, origin_email, account.email AS email, account.id AS id, account.name AS owner "+
                   "FROM domain, domain_vhost, account "+
                   "WHERE domain.owner = account.id "+
                   "AND domain.name = domain_vhost.name "+
                   "AND domain_vhost.enabled = \"t\" "+
                   "AND account.enabled = \"t\"")

    subcursor = ctx.db.cursor();

    while 1:
        row = cursor.fetchone()
        if row is None: break

        
#         subcursor.execute("SELECT domain_alias.name AS NAME"+
#                           "FROM domain, domain_alias, account "+
#                           "WHERE domain.owner = account.id "+
#                           "AND domain.name = domain_alias.name "+
#                           "AND vhost=\"%s\" "+
#                           "AND account.enabled = \"t\"")
        alias = ""

        stdout.write(("<VirtualHost *:80>\n"+
                      "\tServerName %s\n"+
                      "\tServerAlias %s\n"+
                      "\tServerAdmin %s\n"+
                      "\tDocumentRoot %s\n"+
                      "</VirtualHost>\n") % (row["name"], alias, row["email"], ctx.makeHomeDir(row["owner"])+"/www/"+row["name"]))

if __name__ == "__main__":
    generateApacheFragment()