blob: ce0ec6da7df265ea769f7022e3bf55615db4b3b2 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#! /usr/bin/python2
#Helper program that generates gen_is.xml thats custom to linhes.
#Contents of gen_is.xml are read from /etc/gen_is_xml.d
#This script should be run everytime a is.xml entry is added or removed
import os, sys
import glob
def read_snippets(dir_name):
conf_snippets=""
try:
os.chdir(dir_name)
except:
print " gen_light_conf: Couldn't change dir to %s" %dir_name
print " Exiting"
sys.exit(0)
file_list=glob.glob("*.conf")
for conf_file in file_list:
try:
print " gen_light_conf: reading in %s" %conf_file
f=open(conf_file,'r')
lines=f.readlines()
f.close()
except:
print " gen_light_conf: Couldn't open %s for reading" %conf_file
print " Exiting"
sys.exit(1)
for line in lines:
conf_snippets+=line
if len(file_list) == 0:
print " gen_light_conf: no conf files found"
conf_snippets=""
return conf_snippets
def write_conf(conf,filename):
try:
f=open(filename, 'w')
except:
print " gen_light_conf: Couldn't open %s" %(filename)
print " Exiting"
sys.exit(2)
f.write(conf)
f.close()
def main():
filename="/etc/lighttpd/conf.include"
light_conf_dir="/etc/gen_light_conf.d/"
conf_snippets=read_snippets(light_conf_dir)
write_conf(conf_snippets,filename)
if __name__ == "__main__":
main()
|