This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/conf/init/nginx_conf_create.sh

54 lines
1.2 KiB
Bash
Raw Normal View History

2017-02-13 19:14:44 +00:00
#!/venv/bin/python
import os.path
import yaml
import jinja2
def write_config(filename, **kwargs):
with open(filename + ".jnj") as f:
template = jinja2.Template(f.read())
rendered = template.render(kwargs)
with open(filename, 'w') as f:
f.write(rendered)
2017-02-13 19:14:44 +00:00
def generate_nginx_config():
"""
Generates nginx config from the app config
"""
use_https = os.path.exists('conf/stack/ssl.key')
write_config('conf/nginx/nginx.conf',
use_https=use_https)
2017-02-13 19:14:44 +00:00
def generate_server_config(config):
"""
Generates server config from the app config
"""
if config:
tuf_server = config.get('TUF_SERVER', None)
tuf_host = config.get('TUF_HOST', None)
signing_enabled = config.get('FEATURE_SIGNING', False)
else:
tuf_server = None
tuf_host = None
signing_enabled = False
2017-02-13 19:14:44 +00:00
write_config('conf/nginx/server-base.conf',
tuf_server=tuf_server,
tuf_host=tuf_host,
signing_enabled=signing_enabled)
2017-02-13 19:14:44 +00:00
if __name__ == "__main__":
if os.path.exists('conf/stack/config.yaml'):
with open('conf/stack/config.yaml', 'r') as f:
config = yaml.load(f)
else:
config = None
generate_server_config(config)
generate_nginx_config()