12345678910111213141516171819202122232425262728293031 |
- #!/usr/bin/lua
- function replace_patterns(value, subst)
- for k, v in pairs(subst) do
- value = value:gsub(k, v)
- end
- return value
- end
- local site_dir = os.getenv('GLUON_SITEDIR')
- dofile(site_dir .. '/extra/sites.conf')
- dofile(site_dir .. '/extra/groups.conf')
- local template = io.open(site_dir .. '/domain.tmpl'):read('*a')
- os.execute('mkdir -p ' .. site_dir .. '/domains')
- for _, site in pairs(sites) do
- local path = site_dir .. '/domains/' .. site.site_code .. '.conf'
- local subst = {
- ['%%CO'] = site.site_code,
- ['%%NA'] = site.site_name,
- ['%%MI'] = site.site_select.group,
- ['%%HI'] = (site.site_select or {}).hidden and 'true' or 'false',
- }
- local config = replace_patterns(template, subst)
- config = replace_patterns(config, site.subst)
- config = replace_patterns(config, groups[site.site_select.group].subst)
- io.open(path, 'w'):write(config)
- end
|