sr / beadmin

Python scripts hacked together to manage bearnaise.net

This URL has Read+Write access

Jordan Bracco (author)
Tue Dec 23 12:37:28 -0800 2008
Simon Rozet (committer)
Tue Dec 23 12:52:28 -0800 2008
beadmin / lighttpd-mysql-config.py
100755 29 lines (23 sloc) 0.815 kb
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
#!/usr/bin/env python
#-*- coding: utf-8 -*-
 
from dbconf import *
import database as db
import os
import re
 
confs = db.query("""SELECT domains.name, websites.config, users.login
FROM domains, websites, users
WHERE domains.id = websites.id_domains
AND users.id = websites.id_users
AND websites.enabled = 'yes'""")
 
for conf in confs:
path = '/home/%s/%s' % (conf.login, conf.name)
        log_path = '/home/%s/logs/%s' % (conf.login, conf.name)
 
os.system('mkdir -p "%s"' % log_path)
os.system('chown -R %s:www-data "/home/%s/logs/"' % (conf.login, conf.login))
os.system('chmod -R ug+rwx,o-rwx "/home/%s/logs/"' % conf.login)
 
print """
$HTTP["host"] == "%s" {
server.document-root = "%s/"
accesslog.filename = "%s/access.log"
%s
}""" % (conf.name, path, log_path, re.sub("\n", "\n\t", conf.config))