v6helper/build.py

32 lines
565 B
Python
Raw Normal View History

2015-02-03 00:30:51 +01:00
#!/usr/bin/env python
from glob import glob
import json
import os
DOMAIN = 'ff-hh.net'
OUT = '/etc/nginx/v6helper.d/'
template = '''
server {
listen 80;
listen [::]:80;
server_name %%s.%s;
access_log off;
error_log /dev/null crit;
location / {
proxy_pass http://[%%s];
include /etc/nginx/proxy_params;
}
}
''' % DOMAIN
for path in glob('db/*'):
with open(path) as f:
x = json.load(f)
with open(os.path.join(OUT, x['name']), 'w') as f:
pass
f.write(template % (x['name'], x['ipv6']))