summaryrefslogtreecommitdiffstats
path: root/fooconf-apache
diff options
context:
space:
mode:
Diffstat (limited to 'fooconf-apache')
-rwxr-xr-xfooconf-apache39
1 files changed, 39 insertions, 0 deletions
diff --git a/fooconf-apache b/fooconf-apache
new file mode 100755
index 0000000..92aafbb
--- /dev/null
+++ b/fooconf-apache
@@ -0,0 +1,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()